From 1142b0e41de39010de7845cf70d71dbb001fc1dc Mon Sep 17 00:00:00 2001 From: Shireesh Anjal Date: Fri, 25 Nov 2011 20:13:35 +0530 Subject: Renamed projects / packages com.gluster.* to org.gluster.* --- .../.classpath | 12 - src/com.gluster.storage.management.client/.project | 34 - .../.settings/org.eclipse.jdt.core.prefs | 8 - .../META-INF/MANIFEST.MF | 17 - .../build.properties | 14 - .../keystore/gmc-trusted.keystore | Bin 81843 -> 0 bytes .../lib/jersey-1.5/jersey-client-1.5.jar | Bin 128096 -> 0 bytes .../lib/jersey-1.5/jersey-core-1.5.jar | Bin 455665 -> 0 bytes .../lib/jersey-1.5/jersey-multipart-1.5.jar | Bin 49330 -> 0 bytes .../storage/management/client/AbstractClient.java | 428 -- .../storage/management/client/ClustersClient.java | 72 - .../management/client/DiscoveredServersClient.java | 87 - .../management/client/GlusterServersClient.java | 139 - .../storage/management/client/KeysClient.java | 55 - .../storage/management/client/TasksClient.java | 103 - .../storage/management/client/UsersClient.java | 96 - .../storage/management/client/VolumesClient.java | 281 -- .../client/constants/ClientConstants.java | 39 - .../management/client/utils/ClientUtil.java | 20 - .../.project | 17 - .../buckminster.cspex | 41 - .../build.properties | 2 - .../build/glustermc.ant | 30 - .../feature.xml | 229 - .../rootfiles/gluster-management-console.jnlp | 44 - .../rootfiles/splash.png | Bin 121581 -> 0 bytes .../.project | 17 - .../build.properties | 1 - .../feature.xml | 942 ---- .../.project | 22 - .../.settings/org.eclipse.core.resources.prefs | 8 - .../.settings/org.eclipse.wst.css.core.prefs | 4 - .../META-INF/MANIFEST.MF | 9 - .../build.properties | 8 - .../html/concepts/about_gmc.html | 21 - .../html/concepts/about_gmg.html | 16 - .../html/concepts/common_terms.html | 50 - .../html/concepts/gluster_fs.html | 19 - .../html/concepts/maintopic.html | 13 - .../html/concepts/subtopic.html | 13 - .../html/concepts/subtopic2.html | 13 - .../html/css/Builder/style.css | 939 ---- .../html/css/builder-gluster/style.css | 1341 ------ .../html/gettingstarted/ subtopic3.html | 13 - .../html/gettingstarted/access_gmc_jws.html | 43 - .../html/gettingstarted/alerts.html | 24 - .../html/gettingstarted/change_password.html | 38 - .../html/gettingstarted/check_req_client.html | 27 - .../html/gettingstarted/check_req_gmg.html | 23 - .../html/gettingstarted/cifs_service.html | 42 - .../html/gettingstarted/configure_cifs.html | 15 - .../html/gettingstarted/explore_gmc.html | 30 - .../html/gettingstarted/gmc_install_overview.html | 15 - .../html/gettingstarted/gmc_terminal_window.html | 20 - .../html/gettingstarted/gmc_toolbar.html | 98 - .../html/gettingstarted/gmg_install_overview.html | 15 - .../html/gettingstarted/install_gmg.html | 49 - .../html/gettingstarted/install_gmg_backend.html | 47 - .../html/gettingstarted/maintopic (4).html | 13 - .../html/gettingstarted/maintopic - Copy (3).html | 13 - .../html/gettingstarted/maintopic - Copy (4).html | 13 - .../html/gettingstarted/maintopic - Copy.html | 13 - .../html/gettingstarted/maintopic.html | 13 - .../html/gettingstarted/manage_bricks.html | 19 - .../html/gettingstarted/manage_cluster.html | 30 - .../html/gettingstarted/manage_logs.html | 28 - .../html/gettingstarted/manage_servers.html | 22 - .../html/gettingstarted/manage_volumes.html | 34 - .../html/gettingstarted/monitor_resources.html | 34 - .../html/gettingstarted/resetting_pwd.html | 20 - .../html/gettingstarted/security_keys.html | 32 - .../html/gettingstarted/setting_alerts_prefs.html | 27 - .../html/gettingstarted/setting_charts_prefs.html | 29 - .../html/gettingstarted/setting_gluster_prefs.html | 25 - .../html/gettingstarted/setting_preferences.html | 22 - .../gettingstarted/setting_terminal_prefs.html | 26 - .../html/gettingstarted/setting_the_gmc.html | 15 - .../html/gettingstarted/subtopic (3) - Copy.html | 13 - .../html/gettingstarted/subtopic (3).html | 13 - .../html/gettingstarted/subtopic.html | 13 - .../html/gettingstarted/subtopic2 (2).html | 13 - .../html/gettingstarted/subtopic2 (3).html | 13 - .../html/gettingstarted/subtopic2.html | 13 - .../html/gettingstarted/tasks.html | 17 - .../html/help_home.html | 29 - .../html/images/Delete-brick.png | Bin 125545 -> 0 bytes .../html/images/GMC-Preferences-alerts .jpg | Bin 55125 -> 0 bytes .../html/images/GMC-Preferences-charts.jpg | Bin 62538 -> 0 bytes .../html/images/GMC-Preferences-gluster .jpg | Bin 52380 -> 0 bytes .../html/images/GMC_02.jpg | Bin 39901 -> 0 bytes .../html/images/GMC_03.jpg | Bin 14542 -> 0 bytes .../html/images/GMC_04.jpg | Bin 18303 -> 0 bytes .../html/images/GMC_05.jpg | Bin 16557 -> 0 bytes .../html/images/GMC_06.jpg | Bin 16959 -> 0 bytes .../html/images/GMC_07.jpg | Bin 93914 -> 0 bytes .../html/images/GMC_09.jpg | Bin 52606 -> 0 bytes .../html/images/GMC_1.0_Add_Brick.jpg | Bin 101781 -> 0 bytes .../html/images/GMC_1.0_Add_Brick_confirm.jpg | Bin 28654 -> 0 bytes .../html/images/GMC_1.0_Add_Server_Confirm.jpg | Bin 18572 -> 0 bytes .../html/images/GMC_1.0_Create_Vol.jpg | Bin 40060 -> 0 bytes .../html/images/GMC_1.0_Discovered_Server_Add.jpg | Bin 92039 -> 0 bytes .../html/images/GMC_1.0_Display_log_criteria.jpg | Bin 333591 -> 0 bytes .../html/images/GMC_1.0_Remove_Brick_confirm.jpg | Bin 19105 -> 0 bytes .../html/images/GMC_1.0_Remove_Bricks.jpg | Bin 28865 -> 0 bytes .../html/images/GMC_1.0_Remove_Bricks_success.jpg | Bin 18917 -> 0 bytes .../html/images/GMC_1.0_Remove_Server.jpg | Bin 15948 -> 0 bytes .../html/images/GMC_1.0_Remove_Server_1.jpg | Bin 20426 -> 0 bytes .../html/images/GMC_1.0_Select_FS_Type.jpg | Bin 19850 -> 0 bytes .../html/images/GMC_1.0_create_cluster.jpg | Bin 12353 -> 0 bytes .../html/images/GMC_1.0_login.jpg | Bin 14542 -> 0 bytes .../html/images/GMC_1.0_multiple_vols.jpg | Bin 12508 -> 0 bytes .../html/images/GMC_1.0_multiple_vols_confirm.jpg | Bin 11321 -> 0 bytes .../html/images/GMC_1.0_register_cluster.jpg | Bin 15437 -> 0 bytes .../html/images/GMC_1.0_removeBrick_confirm.jpg | Bin 29142 -> 0 bytes .../html/images/GMC_1.0_select_cluster.jpg | Bin 18303 -> 0 bytes .../html/images/GMC_1.0_server_add_success.jpg | Bin 10640 -> 0 bytes .../html/images/GMC_1.0_vol_success.jpg | Bin 18866 -> 0 bytes .../html/images/GMC_10.jpg | Bin 70046 -> 0 bytes .../html/images/GMC_Add_Brick.jpg | Bin 89897 -> 0 bytes .../html/images/GMC_Add_Brick_confirm.jpg | Bin 21385 -> 0 bytes .../html/images/GMC_Add_Brick_icon.jpg | Bin 1536 -> 0 bytes .../html/images/GMC_Add_Server_Manual.jpg | Bin 11525 -> 0 bytes .../html/images/GMC_Add_brick.jpg | Bin 68440 -> 0 bytes .../html/images/GMC_Add_brick_confirm.jpg | Bin 15084 -> 0 bytes .../html/images/GMC_Alerts.jpg | Bin 52402 -> 0 bytes .../html/images/GMC_Bricks_Tab.jpg | Bin 115478 -> 0 bytes .../html/images/GMC_Change_Password.jpg | Bin 22096 -> 0 bytes .../html/images/GMC_Change_Password_Confirm.jpg | Bin 17204 -> 0 bytes .../html/images/GMC_Charts.jpg | Bin 60205 -> 0 bytes .../html/images/GMC_Clear_task_icon.jpg | Bin 1276 -> 0 bytes .../html/images/GMC_Cluster_Summary.jpg | Bin 106434 -> 0 bytes .../html/images/GMC_Cluster_Summary_tab.jpg | Bin 212681 -> 0 bytes .../html/images/GMC_Cluster_Summary_tab_new.jpg | Bin 172135 -> 0 bytes .../html/images/GMC_Create_Cluster.jpg | Bin 19986 -> 0 bytes .../html/images/GMC_Create_Vol_icon.jpg | Bin 1340 -> 0 bytes .../html/images/GMC_Create_Volume.jpg | Bin 63917 -> 0 bytes .../html/images/GMC_Create_Volume_success.jpg | Bin 19385 -> 0 bytes .../html/images/GMC_Delete_Vol.jpg | Bin 26774 -> 0 bytes .../html/images/GMC_Delete_Vol_Confirm.jpg | Bin 17356 -> 0 bytes .../html/images/GMC_Delete_Vol_multiple.jpg | Bin 30788 -> 0 bytes .../images/GMC_Delete_Vol_multiple_success.jpg | Bin 19616 -> 0 bytes .../html/images/GMC_Delete_Vol_success.jpg | Bin 18884 -> 0 bytes .../html/images/GMC_Disk_tab.jpg | Bin 224966 -> 0 bytes .../html/images/GMC_Landing_Page.jpg | Bin 163592 -> 0 bytes .../html/images/GMC_Log_list.jpg | Bin 171345 -> 0 bytes .../html/images/GMC_Login_Change_Pwd.jpg | Bin 22584 -> 0 bytes .../html/images/GMC_Login_Window.jpg | Bin 28664 -> 0 bytes .../html/images/GMC_Migrate_Brick.jpg | Bin 107849 -> 0 bytes .../html/images/GMC_Migrate_Brick_success.jpg | Bin 17196 -> 0 bytes .../html/images/GMC_Preferences_alerts.jpg | Bin 55125 -> 0 bytes .../html/images/GMC_Preferences_charts.jpg | Bin 62538 -> 0 bytes .../html/images/GMC_Preferences_gluster.jpg | Bin 51110 -> 0 bytes .../html/images/GMC_Preferences_terminal.jpg | Bin 52304 -> 0 bytes .../html/images/GMC_Rebalance_icon.jpg | Bin 1559 -> 0 bytes .../html/images/GMC_Refresh.jpg | Bin 1572 -> 0 bytes .../html/images/GMC_Register_Cluster.jpg | Bin 21831 -> 0 bytes .../html/images/GMC_Remove_Brick_Confirm.jpg | Bin 19955 -> 0 bytes .../html/images/GMC_Remove_Brick_icon.jpg | Bin 1567 -> 0 bytes .../html/images/GMC_Remove_Server_icon.jpg | Bin 1506 -> 0 bytes .../html/images/GMC_Remove_server.jpg | Bin 20022 -> 0 bytes .../html/images/GMC_Remove_server_success.jpg | Bin 17303 -> 0 bytes .../html/images/GMC_Select_Cluster.jpg | Bin 23467 -> 0 bytes .../html/images/GMC_Select_Cluster_progess.jpg | Bin 19762 -> 0 bytes .../html/images/GMC_Server_Disk.jpg | Bin 222242 -> 0 bytes .../html/images/GMC_Server_Summ.jpg | Bin 165858 -> 0 bytes .../html/images/GMC_Server_Summary_tab.jpg | Bin 100798 -> 0 bytes .../html/images/GMC_Server_Tab.jpg | Bin 109711 -> 0 bytes .../html/images/GMC_Single_Vol.jpg | Bin 13304 -> 0 bytes .../html/images/GMC_Start_task_icon.jpg | Bin 1298 -> 0 bytes .../html/images/GMC_Stop_Multiple_Vol.jpg | Bin 14017 -> 0 bytes .../html/images/GMC_Stop_Vol.jpg | Bin 12503 -> 0 bytes .../html/images/GMC_Stop_icon.jpg | Bin 1103 -> 0 bytes .../html/images/GMC_Task_tab.jpg | Bin 101601 -> 0 bytes .../html/images/GMC_Terminal_window.jpg | Bin 135724 -> 0 bytes .../html/images/GMC_Toolbar.jpg | Bin 15211 -> 0 bytes .../html/images/GMC_Vol_List.jpg | Bin 67235 -> 0 bytes .../html/images/GMC_Vol_Options.jpg | Bin 80035 -> 0 bytes .../html/images/GMC_Vol_rebalance_success.jpg | Bin 12603 -> 0 bytes .../html/images/GMC_Volume_Options.jpg | Bin 135662 -> 0 bytes .../html/images/GMC_Volume_Summary.jpg | Bin 113645 -> 0 bytes .../html/images/GMC_Volume_Summary_tab.jpg | Bin 97314 -> 0 bytes .../html/images/GMC_Volume_logs.jpg | Bin 314494 -> 0 bytes .../html/images/GMC_Volume_properties.jpg | Bin 145098 -> 0 bytes .../html/images/GMC_Volumes_tab.jpg | Bin 115212 -> 0 bytes .../html/images/GMC_add_server_icon.jpg | Bin 1391 -> 0 bytes .../html/images/GMC_change_pwd.jpg | Bin 16076 -> 0 bytes .../html/images/GMC_create_vol (2).jpg | Bin 44511 -> 0 bytes .../html/images/GMC_create_vol.jpg | Bin 44511 -> 0 bytes .../html/images/GMC_download_log_icon.jpg | Bin 1611 -> 0 bytes .../html/images/GMC_landing_page.jpg | Bin 106427 -> 0 bytes .../html/images/GMC_log_criteria.jpg | Bin 117809 -> 0 bytes .../html/images/GMC_migrate_brick.jpg | Bin 60009 -> 0 bytes .../html/images/GMC_migrate_brick_icon.jpg | Bin 1647 -> 0 bytes .../html/images/GMC_pause_icon.jpg | Bin 1262 -> 0 bytes .../html/images/GMC_pwd_change_success.jpg | Bin 11852 -> 0 bytes .../html/images/GMC_rebalance_vol.jpg | Bin 18396 -> 0 bytes .../html/images/GMC_remove_server_confirm.jpg | Bin 11560 -> 0 bytes .../html/images/GMC_remove_volume_icon.jpg | Bin 1517 -> 0 bytes .../html/images/GMC_server_summary.jpg | Bin 70046 -> 0 bytes .../html/images/GMC_setting_icon.jpg | Bin 1619 -> 0 bytes .../html/images/GMC_settings.jpg | Bin 1596 -> 0 bytes .../html/images/GMC_start_vol_Multiple.jpg | Bin 19551 -> 0 bytes .../html/images/GMC_start_vol_icon.jpg | Bin 1540 -> 0 bytes .../html/images/GMC_start_vol_success.jpg | Bin 18795 -> 0 bytes .../html/images/GMC_stop_vol_Multiple.jpg | Bin 19551 -> 0 bytes .../html/images/GMC_stop_vol_icon.jpg | Bin 1545 -> 0 bytes .../html/images/GMC_terminal_Settings.jpg | Bin 34801 -> 0 bytes .../html/images/GMC_terminal_toolbar.jpg | Bin 1371 -> 0 bytes .../html/images/GMG_Architecture.jpg | Bin 46322 -> 0 bytes .../html/images/GlusterFS_3.2_Architecture.jpg | Bin 62893 -> 0 bytes .../html/images/GlusterFS_3.2_Architecture.png | Bin 133597 -> 0 bytes .../html/images/GlusterMC_Architecture.jpg | Bin 69990 -> 0 bytes .../html/images/Migration.png | Bin 126167 -> 0 bytes .../html/images/Preferences-alerts .png | Bin 33540 -> 0 bytes .../html/images/Preferences-charts.png | Bin 43267 -> 0 bytes .../html/images/Preferences-gluster .png | Bin 29612 -> 0 bytes .../html/images/Running tasks & alerts.png | Bin 131944 -> 0 bytes .../html/images/Stop_Vol.jpg | Bin 20638 -> 0 bytes .../html/images/Stop_Vol_confirm.jpg | Bin 18391 -> 0 bytes .../html/images/Stop_Vol_multiple.jpg | Bin 20979 -> 0 bytes .../html/images/Stop_Vol_multiple_confirm.jpg | Bin 19308 -> 0 bytes .../html/images/discovered_servers.png | Bin 80490 -> 0 bytes .../html/images/java-web-start.jpg | Bin 33899 -> 0 bytes .../html/images/java_web_start.jpg | Bin 33899 -> 0 bytes .../html/images/login-dialog.png | Bin 67859 -> 0 bytes .../html/reference/maintopic.html | 13 - .../html/reference/subtopic.html | 13 - .../html/reference/subtopic2.html | 13 - .../html/tasks/access_gmc_jws.html | 32 - .../html/tasks/add_brick.html | 34 - .../html/tasks/add_servers.html | 31 - .../html/tasks/configure_gmc.html | 19 - .../html/tasks/create_cluster.html | 25 - .../html/tasks/create_volume.html | 47 - .../html/tasks/delete_brick.html | 40 - .../html/tasks/delete_volume.html | 34 - .../html/tasks/deploy_gmc_dedicated_host.html | 36 - .../html/tasks/display_log.html | 26 - .../html/tasks/download_log.html | 23 - .../html/tasks/initialize_disk.html | 25 - .../html/tasks/logging.html | 16 - .../html/tasks/maintopic (3).html | 13 - .../html/tasks/maintopic.html | 13 - .../html/tasks/migrate_brick.html | 30 - .../html/tasks/rebalance_vol.html | 24 - .../html/tasks/register_cluster.html | 23 - .../html/tasks/remove_brick.html | 38 - .../html/tasks/remove_server.html | 27 - .../html/tasks/select_cluster.html | 26 - .../html/tasks/start_vol.html | 28 - .../html/tasks/starting_gmc.html | 15 - .../html/tasks/stop_vol.html | 26 - .../html/tasks/subtopic.html | 13 - .../html/tasks/subtopic2 (3).html | 13 - .../html/tasks/subtopic2.html | 13 - .../html/tasks/subtopic3.html | 13 - .../html/tasks/subtopic4.html | 13 - .../html/tasks/subtopic5.html | 13 - .../html/tasks/subtopic6.html | 13 - .../html/tasks/tune_vol_opt.html | 24 - .../html/tasks/volumes.html | 38 - .../html/toc.html | 15 - .../plugin.xml | 26 - .../toc.xml | 14 - .../tocconcepts.xml | 12 - .../tocgettingstarted.xml | 52 - .../tocreference.xml | 11 - .../toctasks.xml | 40 - .../.classpath | 7 - .../.project | 34 - .../.settings/org.eclipse.jdt.core.prefs | 8 - .../META-INF/MANIFEST.MF | 33 - .../build.properties | 18 - .../icons/tango/16x16/arrow-down.png | Bin 683 -> 0 bytes .../icons/tango/16x16/arrow-up.png | Bin 652 -> 0 bytes .../icons/tango/16x16/bricks.png | Bin 807 -> 0 bytes .../icons/tango/16x16/close_task.png | Bin 588 -> 0 bytes .../icons/tango/16x16/cluster.png | Bin 622 -> 0 bytes .../icons/tango/16x16/disk-available.png | Bin 769 -> 0 bytes .../icons/tango/16x16/disk-error.png | Bin 801 -> 0 bytes .../icons/tango/16x16/disk-initialisation.png | Bin 817 -> 0 bytes .../icons/tango/16x16/disk-inuse.png | Bin 798 -> 0 bytes .../icons/tango/16x16/disk-uninitialized.png | Bin 809 -> 0 bytes .../icons/tango/16x16/disk.png | Bin 717 -> 0 bytes .../icons/tango/16x16/gluster_icon.png | Bin 3131 -> 0 bytes .../icons/tango/16x16/help.png | Bin 932 -> 0 bytes .../icons/tango/16x16/logs.png | Bin 796 -> 0 bytes .../icons/tango/16x16/offline-brick.png | Bin 621 -> 0 bytes .../icons/tango/16x16/online-brick.png | Bin 532 -> 0 bytes .../icons/tango/16x16/pause.png | Bin 729 -> 0 bytes .../icons/tango/16x16/question.png | Bin 766 -> 0 bytes .../icons/tango/16x16/running-task.png | Bin 858 -> 0 bytes .../icons/tango/16x16/server.png | Bin 725 -> 0 bytes .../icons/tango/16x16/servers.png | Bin 393 -> 0 bytes .../icons/tango/16x16/settings.png | Bin 588 -> 0 bytes .../icons/tango/16x16/start.png | Bin 734 -> 0 bytes .../icons/tango/16x16/status-offline.png | Bin 945 -> 0 bytes .../icons/tango/16x16/status-online.png | Bin 689 -> 0 bytes .../icons/tango/16x16/stop.png | Bin 690 -> 0 bytes .../icons/tango/16x16/task-completed.png | Bin 767 -> 0 bytes .../icons/tango/16x16/task-error.png | Bin 768 -> 0 bytes .../icons/tango/16x16/utilities-terminal.png | Bin 668 -> 0 bytes .../icons/tango/16x16/view-refresh.png | Bin 912 -> 0 bytes .../icons/tango/16x16/volume-create.png | Bin 635 -> 0 bytes .../icons/tango/16x16/volume-options.png | Bin 713 -> 0 bytes .../icons/tango/16x16/volume.png | Bin 774 -> 0 bytes .../icons/tango/16x16/volumes.png | Bin 830 -> 0 bytes .../icons/tango/22x22/disk-initialisation.png | Bin 1100 -> 0 bytes .../icons/tango/22x22/high-memory-usage.png | Bin 834 -> 0 bytes .../icons/tango/22x22/low-diskspace.png | Bin 1042 -> 0 bytes .../icons/tango/22x22/migrate-brick.png | Bin 1213 -> 0 bytes .../icons/tango/22x22/offline-brick.png | Bin 835 -> 0 bytes .../icons/tango/22x22/offline-server.png | Bin 1276 -> 0 bytes .../icons/tango/22x22/offline-volume.png | Bin 1034 -> 0 bytes .../icons/tango/22x22/server-warning.png | Bin 806 -> 0 bytes .../icons/tango/22x22/system-search.png | Bin 1267 -> 0 bytes .../icons/tango/22x22/utilities-terminal.png | Bin 1026 -> 0 bytes .../icons/tango/22x22/volume-rebalance.png | Bin 955 -> 0 bytes .../icons/tango/32x32/add-brick-disabled.png | Bin 2063 -> 0 bytes .../icons/tango/32x32/add-brick.png | Bin 2105 -> 0 bytes .../icons/tango/32x32/add-server.png | Bin 2137 -> 0 bytes .../icons/tango/32x32/clear-task-disabled.png | Bin 1416 -> 0 bytes .../icons/tango/32x32/clear-task.png | Bin 1424 -> 0 bytes .../icons/tango/32x32/commit-task-disabled.png | Bin 1246 -> 0 bytes .../icons/tango/32x32/commit-task.png | Bin 1294 -> 0 bytes .../icons/tango/32x32/create-volume-disabled.png | Bin 1929 -> 0 bytes .../icons/tango/32x32/create-volume.png | Bin 1788 -> 0 bytes .../icons/tango/32x32/disk.png | Bin 1155 -> 0 bytes .../icons/tango/32x32/download-log.png | Bin 2065 -> 0 bytes .../icons/tango/32x32/help.png | Bin 2231 -> 0 bytes .../icons/tango/32x32/log-rotate.png | Bin 1839 -> 0 bytes .../icons/tango/32x32/logs.png | Bin 1886 -> 0 bytes .../icons/tango/32x32/migrate-brick-disabled.png | Bin 2591 -> 0 bytes .../icons/tango/32x32/migrate-brick.png | Bin 2343 -> 0 bytes .../icons/tango/32x32/pause-disabled.png | Bin 1001 -> 0 bytes .../icons/tango/32x32/pause.png | Bin 1037 -> 0 bytes .../icons/tango/32x32/remove-brick-disabled.png | Bin 2206 -> 0 bytes .../icons/tango/32x32/remove-brick.png | Bin 1988 -> 0 bytes .../icons/tango/32x32/remove-server-disabled.png | Bin 1907 -> 0 bytes .../icons/tango/32x32/remove-server.png | Bin 2143 -> 0 bytes .../icons/tango/32x32/remove-volume-disabled.png | Bin 1644 -> 0 bytes .../icons/tango/32x32/remove-volume.png | Bin 1712 -> 0 bytes .../tango/32x32/reset-volume-option-disabled.png | Bin 2273 -> 0 bytes .../icons/tango/32x32/reset-volume-option.png | Bin 2303 -> 0 bytes .../icons/tango/32x32/server.png | Bin 1591 -> 0 bytes .../icons/tango/32x32/servers.png | Bin 1264 -> 0 bytes .../icons/tango/32x32/settings.png | Bin 2544 -> 0 bytes .../icons/tango/32x32/start-disabled.png | Bin 1181 -> 0 bytes .../icons/tango/32x32/start-volume-disabled.png | Bin 1968 -> 0 bytes .../icons/tango/32x32/start-volume.png | Bin 1818 -> 0 bytes .../icons/tango/32x32/start.png | Bin 1207 -> 0 bytes .../icons/tango/32x32/stop-disabled.png | Bin 532 -> 0 bytes .../icons/tango/32x32/stop-volume-disabled.png | Bin 1851 -> 0 bytes .../icons/tango/32x32/stop-volume.png | Bin 1754 -> 0 bytes .../icons/tango/32x32/stop.png | Bin 540 -> 0 bytes .../icons/tango/32x32/utilities-terminal.png | Bin 1488 -> 0 bytes .../icons/tango/32x32/view-refresh.png | Bin 2024 -> 0 bytes .../tango/32x32/volume-rebalance-disabled.png | Bin 1927 -> 0 bytes .../icons/tango/32x32/volume-rebalance.png | Bin 1969 -> 0 bytes .../icons/tango/32x32/volume.png | Bin 1446 -> 0 bytes .../icons/tango/48x48/add-server.png | Bin 3606 -> 0 bytes .../icons/tango/48x48/create-volume.png | Bin 2898 -> 0 bytes .../icons/tango/48x48/remove-brick-disabled.png | Bin 3186 -> 0 bytes .../icons/tango/48x48/server.png | Bin 3295 -> 0 bytes .../icons/tango/48x48/start-volume-disabled.png | Bin 2742 -> 0 bytes .../icons/tango/48x48/stop-volume-disabled.png | Bin 2470 -> 0 bytes .../icons/tango/8x8/offline.png | Bin 381 -> 0 bytes .../icons/tango/8x8/online.png | Bin 315 -> 0 bytes .../icons/tango/8x8/star.png | Bin 244 -> 0 bytes .../icons/tango/scalable/add_brick.svg | 4155 ------------------ .../icons/tango/scalable/add_volume.svg | 3235 -------------- .../icons/tango/scalable/brick.svg | 652 --- .../icons/tango/scalable/brick_migration.svg | 3697 ---------------- .../icons/tango/scalable/bricks.svg | 684 --- .../icons/tango/scalable/cloud.svg | 425 -- .../tango/scalable/create-volume-disabled.svg | 3044 ------------- .../icons/tango/scalable/create-volume.svg | 3006 ------------- .../icons/tango/scalable/disk (32-32).svg | 1088 ----- .../icons/tango/scalable/disk (48-48).svg | 2263 ---------- .../icons/tango/scalable/disk.svg | 850 ---- .../icons/tango/scalable/disk_available.svg | 1983 --------- .../icons/tango/scalable/disk_error.svg | 1991 --------- .../icons/tango/scalable/disk_initialisation.svg | 2302 ---------- .../icons/tango/scalable/disk_inuse.svg | 1848 -------- .../icons/tango/scalable/disk_uninitialised.svg | 2585 ----------- .../icons/tango/scalable/download_log.svg | 1187 ------ .../icons/tango/scalable/high_CPU_usage.svg | 1661 -------- .../icons/tango/scalable/high_memory_usage.svg | 589 --- .../icons/tango/scalable/log.svg | 1160 ----- .../icons/tango/scalable/low_diskspace.svg | 1790 -------- .../icons/tango/scalable/offline-8x8.svg | 154 - .../icons/tango/scalable/offline.svg | 1637 ------- .../icons/tango/scalable/offline_brick.svg | 4413 ------------------- .../icons/tango/scalable/offline_brick_alert.svg | 713 ---- .../icons/tango/scalable/offline_server.svg | 838 ---- .../icons/tango/scalable/offline_volume.svg | 3171 -------------- .../icons/tango/scalable/online-8x8.svg | 246 -- .../icons/tango/scalable/online.svg | 1410 ------ .../icons/tango/scalable/remove-server.svg | 141 - .../icons/tango/scalable/remove_brick.svg | 4483 -------------------- .../icons/tango/scalable/remove_volume.svg | 3248 -------------- .../icons/tango/scalable/reset_volume_option.svg | 2946 ------------- .../icons/tango/scalable/running_task.svg | 1498 ------- .../icons/tango/scalable/star-8x8.svg | 15 - .../icons/tango/scalable/start-volume-disabled.svg | 3350 --------------- .../icons/tango/scalable/start_volume.svg | 3312 --------------- .../icons/tango/scalable/stop_volume.svg | 3268 -------------- .../icons/tango/scalable/task_clear.svg | 845 ---- .../icons/tango/scalable/task_commit.svg | 310 -- .../icons/tango/scalable/task_pause.svg | 821 ---- .../icons/tango/scalable/task_paused.svg | 812 ---- .../icons/tango/scalable/task_resume.svg | 395 -- .../icons/tango/scalable/task_running.svg | 796 ---- .../icons/tango/scalable/task_status_completed.svg | 577 --- .../icons/tango/scalable/task_status_error.svg | 654 --- .../icons/tango/scalable/task_stop.svg | 748 ---- .../icons/tango/scalable/task_stopped.svg | 784 ---- .../icons/tango/scalable/utilities-terminal.svg | 500 --- .../icons/tango/scalable/view-refresh.svg | 393 -- .../icons/tango/scalable/volume.svg | 2917 ------------- .../icons/tango/scalable/volume_option.svg | 2875 ------------- .../icons/tango/scalable/volume_rebalance.svg | 3713 ---------------- .../icons/tango/scalable/volumes.svg | 2949 ------------- .../images/gauge.png | Bin 45242 -> 0 bytes .../images/gauge_small.png | Bin 13875 -> 0 bytes .../images/gluster-about.png | Bin 34661 -> 0 bytes .../images/login-screen-with-text.psd | Bin 4367373 -> 0 bytes .../images/login-screen.psd | Bin 1512790 -> 0 bytes .../images/splash-dialog.bmp | Bin 248192 -> 0 bytes .../images/splash-screen.psd | Bin 2004782 -> 0 bytes .../plugin.properties | 7 - .../plugin.xml | 1658 -------- .../preferences.ini | 3 - .../splash.bmp | Bin 381054 -> 0 bytes .../storage/management/console/Activator.java | 83 - .../storage/management/console/AlertsManager.java | 216 - .../storage/management/console/Application.java | 135 - .../console/ApplicationActionBarAdvisor.java | 102 - .../console/ApplicationWorkbenchAdvisor.java | 98 - .../console/ApplicationWorkbenchWindowAdvisor.java | 63 - .../console/BrickTableLabelProvider.java | 85 - .../management/console/ConsoleConstants.java | 29 - .../console/DeviceTableLabelProvider.java | 160 - .../console/EntityGroupContentProvider.java | 45 - .../console/GlusterDataModelManager.java | 1036 ----- .../console/GlusterServerTableLabelProvider.java | 77 - .../storage/management/console/ICommandIds.java | 33 - .../management/console/IEntityListener.java | 37 - .../storage/management/console/IImageKeys.java | 97 - .../NetworkInterfaceTableLabelProvider.java | 43 - .../storage/management/console/Perspective.java | 36 - .../console/ServerDiskTableLabelProvider.java | 133 - .../console/ServerTableLabelProvider.java | 52 - .../console/TableLabelProviderAdapter.java | 58 - .../console/TasksTableLabelProvider.java | 71 - .../console/VolumeLogTableLabelProvider.java | 40 - .../console/VolumeOptionsContentProvider.java | 47 - .../console/VolumeOptionsTableLabelProvider.java | 38 - .../console/VolumeTableLabelProvider.java | 82 - .../console/actions/AbstractActionDelegate.java | 103 - .../actions/AbstractMonitoredActionDelegate.java | 56 - .../console/actions/ActionConstants.java | 36 - .../management/console/actions/AddBrickAction.java | 64 - .../console/actions/AddServerAction.java | 124 - .../console/actions/ChangePasswordAction.java | 23 - .../console/actions/ClearTaskAction.java | 46 - .../console/actions/CommitTaskAction.java | 72 - .../console/actions/CreateVolumeAction.java | 53 - .../console/actions/DeleteVolumeAction.java | 210 - .../console/actions/DownloadVolumeLogsAction.java | 61 - .../console/actions/EditVolumeAction.java | 33 - .../console/actions/ExportSshKeysAction.java | 61 - .../console/actions/ForceStartVolumeAction.java | 71 - .../console/actions/ImportSshKeysAction.java | 44 - .../console/actions/MigrateBrickAction.java | 69 - .../console/actions/MigrateVolumeAction.java | 33 - .../console/actions/PauseTaskAction.java | 67 - .../console/actions/PreferencesAction.java | 36 - .../console/actions/RebalanceVolumeAction.java | 82 - .../console/actions/RefreshDataAction.java | 43 - .../console/actions/RemoveBrickAction.java | 91 - .../console/actions/RemoveServerAction.java | 159 - .../console/actions/ResetVolumeOptionsAction.java | 62 - .../console/actions/ResumeTaskAction.java | 45 - .../console/actions/ServerAdditionAction.java | 28 - .../console/actions/StartVolumeAction.java | 171 - .../management/console/actions/StopTaskAction.java | 46 - .../console/actions/StopVolumeAction.java | 229 - .../management/console/actions/SupportAction.java | 48 - .../management/console/actions/TerminalAction.java | 44 - .../console/actions/TestPopupMenuAction.java | 63 - .../console/actions/VolumeLogRotateAction.java | 64 - .../management/console/dialogs/AddBrickPage.java | 171 - .../management/console/dialogs/AddBrickWizard.java | 96 - .../console/dialogs/BricksSelectionPage.java | 336 -- .../console/dialogs/ChangePasswordDialog.java | 284 -- .../console/dialogs/ClusterSelectionDialog.java | 474 --- .../console/dialogs/CreateVolumePage1.java | 473 --- .../console/dialogs/CreateVolumeWizard.java | 158 - .../console/dialogs/GlusterSupportDialog.java | 139 - .../management/console/dialogs/InitDiskDialog.java | 212 - .../management/console/dialogs/LoginDialog.java | 359 -- .../console/dialogs/MigrateBrickPage1.java | 302 -- .../console/dialogs/MigrateBrickWizard.java | 106 - .../console/dialogs/SelectDisksDialog.java | 113 - .../console/dialogs/ServerAdditionDialog.java | 197 - .../management/console/jobs/DataSyncJob.java | 68 - .../console/preferences/AlertsPreferencePage.java | 38 - .../console/preferences/ChartsPreferencePage.java | 65 - .../console/preferences/GlusterPreferencePage.java | 90 - .../console/preferences/PreferenceConstants.java | 40 - .../console/preferences/PreferenceInitializer.java | 60 - .../console/toolbar/GlusterToolbarManager.java | 105 - .../management/console/toolbar/ToolbarManager.java | 35 - .../management/console/utils/ChartUtil.java | 339 -- .../console/utils/ChartViewerComposite.java | 475 --- .../console/utils/EntityViewerFilter.java | 78 - .../management/console/utils/GUIHelper.java | 481 --- .../console/utils/GlusterChartPalette.java | 479 --- .../management/console/utils/GlusterLogger.java | 67 - .../management/console/utils/ImageUtil.java | 52 - .../console/utils/TableViewerComparator.java | 73 - .../validators/StringRequiredValidator.java | 61 - .../console/views/ClusterAdapterFactory.java | 101 - .../console/views/ClusterSummaryView.java | 469 -- .../console/views/DiscoveredServerView.java | 90 - .../console/views/DiscoveredServersView.java | 83 - .../management/console/views/DisksView.java | 45 - .../console/views/GlusterServerDisksView.java | 84 - .../console/views/GlusterServerLogsView.java | 59 - .../console/views/GlusterServerSummaryView.java | 544 --- .../console/views/GlusterServersSummaryView.java | 290 -- .../console/views/GlusterServersView.java | 78 - .../console/views/GlusterViewsManager.java | 130 - .../views/NavigationTreeLabelDecorator.java | 87 - .../management/console/views/NavigationView.java | 161 - .../management/console/views/TasksView.java | 39 - .../management/console/views/ViewsManager.java | 38 - .../management/console/views/VolumeBricksView.java | 39 - .../management/console/views/VolumeLogsView.java | 58 - .../console/views/VolumeOptionsView.java | 36 - .../console/views/VolumeSummaryView.java | 859 ---- .../management/console/views/VolumeView.java | 90 - .../console/views/VolumesSummaryView.java | 301 -- .../management/console/views/VolumesView.java | 80 - .../console/views/pages/AbstractDisksPage.java | 335 -- .../views/pages/AbstractTableTreeViewerPage.java | 191 - .../views/pages/AbstractTableViewerPage.java | 263 -- .../management/console/views/pages/BricksPage.java | 123 - .../views/pages/DiskTreeContentProvider.java | 119 - .../management/console/views/pages/DisksPage.java | 70 - .../console/views/pages/GlusterServersPage.java | 138 - .../views/pages/OptionKeyEditingSupport.java | 120 - .../views/pages/OptionValueEditingSupport.java | 110 - .../console/views/pages/ServerDisksPage.java | 66 - .../console/views/pages/ServerLogsPage.java | 199 - .../console/views/pages/ServersPage.java | 138 - .../management/console/views/pages/TasksPage.java | 151 - .../console/views/pages/VolumeLogsPage.java | 431 -- .../console/views/pages/VolumeOptionsPage.java | 360 -- .../console/views/pages/VolumesPage.java | 135 - .../src/test.xml | 1 - src/com.gluster.storage.management.core/.classpath | 9 - src/com.gluster.storage.management.core/.project | 34 - .../.settings/org.eclipse.jdt.core.prefs | 8 - .../META-INF/MANIFEST.MF | 15 - .../build.properties | 7 - .../storage/management/core/model/AlertTest.java | 82 - .../storage/management/core/model/BrickTest.java | 304 -- .../storage/management/core/model/ClusterTest.java | 205 - .../storage/management/core/model/DiskTest.java | 483 --- .../storage/management/core/model/TestAll.java | 35 - .../management/core/utils/DateUtilTest.java | 217 - .../management/core/utils/FileUtilTest.java | 481 --- .../management/core/utils/StringUtilTest.java | 309 -- .../junit/core.junit.launch | 15 - .../junit/test/test.txt | 1 - .../management/core/constants/CoreConstants.java | 40 - .../core/constants/GlusterConstants.java | 47 - .../management/core/constants/RESTConstants.java | 125 - .../core/exceptions/ConnectionException.java | 37 - .../core/exceptions/GlusterRuntimeException.java | 31 - .../exceptions/GlusterValidationException.java | 27 - .../storage/management/core/model/Alert.java | 75 - .../storage/management/core/model/Brick.java | 122 - .../storage/management/core/model/Cluster.java | 196 - .../management/core/model/ClusterListener.java | 57 - .../management/core/model/ConnectionDetails.java | 64 - .../core/model/DefaultClusterListener.java | 118 - .../storage/management/core/model/Device.java | 227 - .../storage/management/core/model/Disk.java | 194 - .../storage/management/core/model/Entity.java | 88 - .../storage/management/core/model/EntityGroup.java | 47 - .../storage/management/core/model/Event.java | 62 - .../storage/management/core/model/Filterable.java | 37 - .../management/core/model/GlusterDataModel.java | 46 - .../management/core/model/GlusterDummyModel.java | 251 -- .../management/core/model/GlusterServer.java | 81 - .../core/model/InitDiskStatusResponse.java | 89 - .../management/core/model/NetworkInterface.java | 112 - .../storage/management/core/model/Partition.java | 35 - .../storage/management/core/model/Response.java | 37 - .../storage/management/core/model/Server.java | 247 -- .../storage/management/core/model/ServerStats.java | 73 - .../management/core/model/ServerStatsRow.java | 69 - .../management/core/model/StatsMetadata.java | 84 - .../storage/management/core/model/Status.java | 92 - .../storage/management/core/model/TaskInfo.java | 140 - .../storage/management/core/model/TaskStatus.java | 64 - .../storage/management/core/model/User.java | 43 - .../storage/management/core/model/Version.java | 65 - .../storage/management/core/model/Volume.java | 367 -- .../management/core/model/VolumeLogMessage.java | 92 - .../management/core/model/VolumeOption.java | 66 - .../management/core/model/VolumeOptionInfo.java | 66 - .../management/core/model/VolumeOptions.java | 113 - .../core/model/adapters/VolumeLogDateAdapter.java | 53 - .../management/core/response/AbstractResponse.java | 35 - .../core/response/ClusterNameListResponse.java | 46 - .../core/response/FsTypeListResponse.java | 47 - .../core/response/GlusterServerListResponse.java | 54 - .../core/response/GlusterServerResponse.java | 35 - .../core/response/LogMessageListResponse.java | 33 - .../core/response/ServerListResponse.java | 48 - .../core/response/ServerNameListResponse.java | 46 - .../core/response/StringListResponse.java | 48 - .../management/core/response/TaskIdResponse.java | 46 - .../core/response/TaskInfoListResponse.java | 51 - .../management/core/response/TaskResponse.java | 52 - .../core/response/VolumeListResponse.java | 31 - .../response/VolumeOptionInfoListResponse.java | 44 - .../storage/management/core/utils/DateUtil.java | 119 - .../storage/management/core/utils/FileUtil.java | 137 - .../management/core/utils/GlusterCoreUtil.java | 205 - .../storage/management/core/utils/JavaUtil.java | 41 - .../storage/management/core/utils/LRUCache.java | 55 - .../gluster/storage/management/core/utils/MD5.java | 504 --- .../storage/management/core/utils/MD5Crypt.java | 339 -- .../storage/management/core/utils/NumberUtil.java | 30 - .../management/core/utils/ProcessResult.java | 69 - .../storage/management/core/utils/ProcessUtil.java | 108 - .../storage/management/core/utils/StringUtil.java | 120 - .../management/core/utils/ValidationUtil.java | 95 - .../org.python.pydev.PyDevBuilder.launch | 7 - .../.project | 22 - .../src/backend/DiskUtils.py | 198 - .../src/backend/FsTabUtils.py | 83 - .../src/backend/NetworkUtils.py | 152 - .../src/backend/VolumeUtils.py | 95 - .../src/backend/add_user_cifs.py | 65 - .../src/backend/clear_volume_directory.py | 48 - .../src/backend/create_volume_cifs.py | 47 - .../src/backend/delete_user_cifs.py | 31 - .../src/backend/delete_volume_cifs.py | 40 - .../src/backend/format_device.py | 108 - .../src/backend/format_device_background.py | 128 - .../src/backend/get_brick_status.py | 46 - .../src/backend/get_filesystem_type.py | 22 - .../src/backend/get_format_device_status.py | 93 - .../src/backend/get_rrd_cpu_details.py | 47 - .../src/backend/get_rrd_memory_details.py | 48 - .../src/backend/get_rrd_net_details.py | 41 - .../src/backend/get_server_details.py | 267 -- .../src/backend/get_server_status.py | 28 - .../src/backend/get_volume_brick_log.py | 97 - .../src/backend/gluster-provision-block | 171 - .../src/backend/gluster-volume-settings.init.d | 20 - .../src/backend/gluster_cifs_volume_startup.py | 114 - .../src/backend/modify_volume_cifs.py | 36 - .../src/backend/multicast-discoverd.init.d | 48 - .../src/backend/multicast-discoverd.py | 103 - .../src/backend/rrd_cpu.pl | 84 - .../src/backend/rrd_mem.pl | 100 - .../src/backend/rrd_net.pl | 75 - .../src/backend/setup_cifs_config.py | 108 - .../src/backend/start_volume_cifs.py | 53 - .../src/backend/stop_volume_cifs.py | 48 - .../src/backend/update-rrd.sh | 6 - .../src/backend/update_volume_cifs.py | 37 - .../src/common/Globals.py | 35 - .../src/common/Utils.py | 329 -- .../src/common/XmlHandler.py | 332 -- .../src/gateway/add_user_cifs_all.py | 78 - .../src/gateway/create_volume_cifs_all.py | 62 - .../src/gateway/delete_user_cifs_all.py | 52 - .../src/gateway/delete_volume_cifs_all.py | 51 - .../src/gateway/get_volume_user_cifs.py | 38 - .../src/gateway/gmg-reset-password.sh | 26 - .../src/gateway/grun.py | 21 - .../src/gateway/multicast-discover-servers.py | 112 - .../gateway/remove_server_volume_cifs_config.py | 68 - .../src/gateway/setup_cifs_config_all.py | 29 - .../src/gateway/update_volume_cifs_all.py | 63 - .../.classpath | 15 - .../.project | 36 - .../.settings/.jsdtscope | 12 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 8 - .../org.eclipse.ltk.core.refactoring.prefs | 3 - .../.settings/org.eclipse.wst.common.component | 10 - .../org.eclipse.wst.common.project.facet.core.xml | 20 - .../org.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - .../org.eclipse.wst.ws.service.policy.prefs | 3 - .../WebContent/META-INF/MANIFEST.MF | 3 - .../WebContent/WEB-INF/lib/Jersey-LICENSE.txt | 135 - .../lib/Jersey-third-party-license-readme.txt | 188 - .../WebContent/WEB-INF/lib/antlr-2.7.6.jar | Bin 443432 -> 0 bytes .../WebContent/WEB-INF/lib/aopalliance-1.0.jar | Bin 4467 -> 0 bytes .../WebContent/WEB-INF/lib/asm-3.1.jar | Bin 43033 -> 0 bytes .../WEB-INF/lib/commons-collections-3.1.jar | Bin 559366 -> 0 bytes .../WEB-INF/lib/commons-logging-1.1.1.jar | Bin 60841 -> 0 bytes .../WebContent/WEB-INF/lib/derby.jar | Bin 2512189 -> 0 bytes .../WebContent/WEB-INF/lib/derbytools.jar | Bin 165188 -> 0 bytes .../WebContent/WEB-INF/lib/dom4j-1.6.1.jar | Bin 313898 -> 0 bytes .../WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt | 87 - .../WEB-INF/lib/ganymed-ssh2-build250.jar | Bin 248915 -> 0 bytes .../lib/hibernate-jpa-2.0-api-1.0.0.Final.jar | Bin 100884 -> 0 bytes .../WebContent/WEB-INF/lib/hibernate3.jar | Bin 4133342 -> 0 bytes .../WEB-INF/lib/jackson-core-asl-1.5.5.jar | Bin 171958 -> 0 bytes .../WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar | Bin 17065 -> 0 bytes .../WEB-INF/lib/jackson-mapper-asl-1.5.5.jar | Bin 485699 -> 0 bytes .../WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar | Bin 24745 -> 0 bytes .../WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar | Bin 633312 -> 0 bytes .../WebContent/WEB-INF/lib/jersey-client-1.5.jar | Bin 128096 -> 0 bytes .../WebContent/WEB-INF/lib/jersey-core-1.5.jar | Bin 455665 -> 0 bytes .../WebContent/WEB-INF/lib/jersey-json-1.5.jar | Bin 144810 -> 0 bytes .../WEB-INF/lib/jersey-multipart-1.5.jar | Bin 49330 -> 0 bytes .../WebContent/WEB-INF/lib/jersey-server-1.5.jar | Bin 681117 -> 0 bytes .../WebContent/WEB-INF/lib/jersey-spring-1.5.jar | Bin 17079 -> 0 bytes .../WebContent/WEB-INF/lib/jettison-1.1.jar | Bin 67758 -> 0 bytes .../WebContent/WEB-INF/lib/jnlp-servlet.jar | Bin 61712 -> 0 bytes .../WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar | Bin 46367 -> 0 bytes .../WebContent/WEB-INF/lib/jta-1.1.jar | Bin 10899 -> 0 bytes .../WebContent/WEB-INF/lib/log4j-1.2.16.jar | Bin 481534 -> 0 bytes .../WebContent/WEB-INF/lib/mimepull-1.3.jar | Bin 38683 -> 0 bytes .../org.eclipse.equinox.common_3.6.0.v20100503.jar | Bin 101958 -> 0 bytes .../lib/org.springframework.aop-3.0.5.RELEASE.jar | Bin 321190 -> 0 bytes .../lib/org.springframework.asm-3.0.5.RELEASE.jar | Bin 53082 -> 0 bytes .../org.springframework.aspects-3.0.5.RELEASE.jar | Bin 35548 -> 0 bytes .../org.springframework.beans-3.0.5.RELEASE.jar | Bin 555410 -> 0 bytes .../org.springframework.context-3.0.5.RELEASE.jar | Bin 668861 -> 0 bytes ...ringframework.context.support-3.0.5.RELEASE.jar | Bin 100870 -> 0 bytes .../lib/org.springframework.core-3.0.5.RELEASE.jar | Bin 382442 -> 0 bytes ...rg.springframework.expression-3.0.5.RELEASE.jar | Bin 169752 -> 0 bytes ...rg.springframework.instrument-3.0.5.RELEASE.jar | Bin 1810 -> 0 bytes ...ngframework.instrument.tomcat-3.0.5.RELEASE.jar | Bin 5728 -> 0 bytes .../lib/org.springframework.jdbc-3.0.5.RELEASE.jar | Bin 385712 -> 0 bytes .../lib/org.springframework.jms-3.0.5.RELEASE.jar | Bin 185312 -> 0 bytes .../lib/org.springframework.orm-3.0.5.RELEASE.jar | Bin 334327 -> 0 bytes .../lib/org.springframework.oxm-3.0.5.RELEASE.jar | Bin 61379 -> 0 bytes ...ringframework.spring-library-3.0.5.RELEASE.libd | 21 - .../lib/org.springframework.test-3.0.5.RELEASE.jar | Bin 205278 -> 0 bytes ...g.springframework.transaction-3.0.5.RELEASE.jar | Bin 231922 -> 0 bytes .../lib/org.springframework.web-3.0.5.RELEASE.jar | Bin 395587 -> 0 bytes ...g.springframework.web.portlet-3.0.5.RELEASE.jar | Bin 175412 -> 0 bytes ...g.springframework.web.servlet-3.0.5.RELEASE.jar | Bin 418977 -> 0 bytes ...rg.springframework.web.struts-3.0.5.RELEASE.jar | Bin 31404 -> 0 bytes .../WebContent/WEB-INF/lib/servlet-api.jar | Bin 176386 -> 0 bytes .../WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar | Bin 25496 -> 0 bytes .../lib/spring-framework-3.0.5.RELEASE-LICENSE.txt | 201 - .../lib/spring-security-3.0.5.RELEASE-LICENSE.txt | 201 - .../lib/spring-security-config-3.0.5.RELEASE.jar | Bin 185716 -> 0 bytes .../lib/spring-security-core-3.0.5.RELEASE.jar | Bin 311038 -> 0 bytes .../lib/spring-security-web-3.0.5.RELEASE.jar | Bin 242833 -> 0 bytes .../WebContent/WEB-INF/web.xml | 76 - .../WebContent/data/scripts/1.0.0/0-version.sql | 2 - .../data/scripts/1.0.0/1-security-schema.sql | 26 - .../scripts/1.0.0/2-users-authorities-groups.sql | 18 - .../data/scripts/1.0.0/3-cluster-servers.sql | 16 - .../WebContent/index.html | 158 - .../WebContent/scripts/Globals.py | 1 - .../WebContent/scripts/Protocol.py | 1 - .../WebContent/scripts/Utils.py | 1 - .../WebContent/scripts/XmlHandler.py | 1 - .../WebContent/scripts/add_user_cifs_all.py | 1 - .../WebContent/scripts/create_volume_cifs_all.py | 1 - .../WebContent/scripts/delete_user_cifs_all.py | 1 - .../WebContent/scripts/delete_volume_cifs_all.py | 1 - .../WebContent/scripts/get_volume_user_cifs.py | 1 - .../WebContent/scripts/gmg-reset-password.sh | 1 - .../WebContent/scripts/grun.py | 1 - .../scripts/multicast-discover-servers.py | 1 - .../scripts/remove_server_volume_cifs_config.py | 1 - .../WebContent/scripts/setup_cifs_config_all.py | 1 - .../WebContent/scripts/update_volume_cifs_all.py | 1 - .../WebContent/ssl/gmg-ssl.keystore | Bin 1380 -> 0 bytes .../buckminster.cspex | 37 - .../build/glusterserver.ant | 70 - .../src/META-INF/persistence.xml | 5 - .../management/gateway/data/ClusterInfo.java | 79 - .../management/gateway/data/GlusterDataSource.java | 48 - .../management/gateway/data/PersistenceDao.java | 113 - .../management/gateway/data/ServerInfo.java | 72 - .../management/gateway/filters/AuditFilter.java | 48 - .../filters/AuthenticationFailureFilter.java | 105 - .../filters/GlusterResourceFilterFactory.java | 31 - .../gateway/listeners/ShutdownListener.java | 47 - .../gateway/resources/v1_0/AbstractResource.java | 177 - .../gateway/resources/v1_0/ClustersResource.java | 126 - .../resources/v1_0/DiscoveredServersResource.java | 101 - .../resources/v1_0/GenericExceptionMapper.java | 60 - .../resources/v1_0/GlusterServersResource.java | 343 -- .../gateway/resources/v1_0/KeysResource.java | 155 - .../gateway/resources/v1_0/TasksResource.java | 226 - .../gateway/resources/v1_0/UsersResource.java | 124 - .../gateway/resources/v1_0/VolumesResource.java | 383 -- .../security/GlusterUserDetailsService.java | 31 - .../management/gateway/security/UserAuthDao.java | 57 - .../gateway/services/AbstractGlusterInterface.java | 38 - .../gateway/services/ClusterService.java | 269 -- .../gateway/services/DiscoveredServerService.java | 130 - .../services/Gluster323InterfaceService.java | 598 --- .../gateway/services/GlusterInterface.java | 368 -- .../gateway/services/GlusterInterfaceService.java | 256 -- .../gateway/services/GlusterServerService.java | 530 --- .../management/gateway/services/VolumeService.java | 984 ----- .../management/gateway/tasks/InitServerTask.java | 161 - .../gateway/tasks/InitializeDiskTask.java | 198 - .../management/gateway/tasks/MigrateBrickTask.java | 220 - .../gateway/tasks/RebalanceVolumeTask.java | 141 - .../management/gateway/tasks/ServerSyncTask.java | 168 - .../storage/management/gateway/tasks/Task.java | 112 - .../gateway/utils/AbstractStatsFactory.java | 162 - .../management/gateway/utils/CpuStatsFactory.java | 36 - .../storage/management/gateway/utils/DBUtil.java | 84 - .../gateway/utils/MemoryStatsFactory.java | 68 - .../gateway/utils/NetworkStatsFactory.java | 173 - .../management/gateway/utils/PasswordManager.java | 83 - .../management/gateway/utils/ServerUtil.java | 370 -- .../storage/management/gateway/utils/SshUtil.java | 463 -- .../management/gateway/utils/StatsFactory.java | 31 - .../src/log4j.properties | 20 - .../src/rebel.xml | 16 - .../src/spring/gluster-server-base.xml | 100 - .../src/spring/gluster-server-security.xml | 49 - .../.classpath | 12 + src/org.gluster.storage.management.client/.project | 34 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 17 + .../build.properties | 14 + .../keystore/gmc-trusted.keystore | Bin 0 -> 81843 bytes .../lib/jersey-1.5/jersey-client-1.5.jar | Bin 0 -> 128096 bytes .../lib/jersey-1.5/jersey-core-1.5.jar | Bin 0 -> 455665 bytes .../lib/jersey-1.5/jersey-multipart-1.5.jar | Bin 0 -> 49330 bytes .../storage/management/client/AbstractClient.java | 429 ++ .../storage/management/client/ClustersClient.java | 73 + .../management/client/DiscoveredServersClient.java | 88 + .../management/client/GlusterServersClient.java | 140 + .../storage/management/client/KeysClient.java | 56 + .../storage/management/client/TasksClient.java | 104 + .../storage/management/client/UsersClient.java | 97 + .../storage/management/client/VolumesClient.java | 282 ++ .../client/constants/ClientConstants.java | 39 + .../management/client/utils/ClientUtil.java | 21 + .../.project | 17 + .../buckminster.cspex | 41 + .../build.properties | 2 + .../build/glustermc.ant | 30 + .../feature.xml | 229 + .../rootfiles/gluster-management-console.jnlp | 44 + .../rootfiles/splash.png | Bin 0 -> 121581 bytes .../.project | 17 + .../build.properties | 1 + .../feature.xml | 942 ++++ .../.project | 22 + .../.settings/org.eclipse.core.resources.prefs | 8 + .../.settings/org.eclipse.wst.css.core.prefs | 4 + .../META-INF/MANIFEST.MF | 9 + .../build.properties | 8 + .../html/concepts/about_gmc.html | 21 + .../html/concepts/about_gmg.html | 16 + .../html/concepts/common_terms.html | 50 + .../html/concepts/gluster_fs.html | 19 + .../html/concepts/maintopic.html | 13 + .../html/concepts/subtopic.html | 13 + .../html/concepts/subtopic2.html | 13 + .../html/css/Builder/style.css | 939 ++++ .../html/css/builder-gluster/style.css | 1341 ++++++ .../html/gettingstarted/ subtopic3.html | 13 + .../html/gettingstarted/access_gmc_jws.html | 43 + .../html/gettingstarted/alerts.html | 24 + .../html/gettingstarted/change_password.html | 38 + .../html/gettingstarted/check_req_client.html | 27 + .../html/gettingstarted/check_req_gmg.html | 23 + .../html/gettingstarted/cifs_service.html | 42 + .../html/gettingstarted/configure_cifs.html | 15 + .../html/gettingstarted/explore_gmc.html | 30 + .../html/gettingstarted/gmc_install_overview.html | 15 + .../html/gettingstarted/gmc_terminal_window.html | 20 + .../html/gettingstarted/gmc_toolbar.html | 98 + .../html/gettingstarted/gmg_install_overview.html | 15 + .../html/gettingstarted/install_gmg.html | 49 + .../html/gettingstarted/install_gmg_backend.html | 47 + .../html/gettingstarted/maintopic (4).html | 13 + .../html/gettingstarted/maintopic - Copy (3).html | 13 + .../html/gettingstarted/maintopic - Copy (4).html | 13 + .../html/gettingstarted/maintopic - Copy.html | 13 + .../html/gettingstarted/maintopic.html | 13 + .../html/gettingstarted/manage_bricks.html | 19 + .../html/gettingstarted/manage_cluster.html | 30 + .../html/gettingstarted/manage_logs.html | 28 + .../html/gettingstarted/manage_servers.html | 22 + .../html/gettingstarted/manage_volumes.html | 34 + .../html/gettingstarted/monitor_resources.html | 34 + .../html/gettingstarted/resetting_pwd.html | 20 + .../html/gettingstarted/security_keys.html | 32 + .../html/gettingstarted/setting_alerts_prefs.html | 27 + .../html/gettingstarted/setting_charts_prefs.html | 29 + .../html/gettingstarted/setting_gluster_prefs.html | 25 + .../html/gettingstarted/setting_preferences.html | 22 + .../gettingstarted/setting_terminal_prefs.html | 26 + .../html/gettingstarted/setting_the_gmc.html | 15 + .../html/gettingstarted/subtopic (3) - Copy.html | 13 + .../html/gettingstarted/subtopic (3).html | 13 + .../html/gettingstarted/subtopic.html | 13 + .../html/gettingstarted/subtopic2 (2).html | 13 + .../html/gettingstarted/subtopic2 (3).html | 13 + .../html/gettingstarted/subtopic2.html | 13 + .../html/gettingstarted/tasks.html | 17 + .../html/help_home.html | 29 + .../html/images/Delete-brick.png | Bin 0 -> 125545 bytes .../html/images/GMC-Preferences-alerts .jpg | Bin 0 -> 55125 bytes .../html/images/GMC-Preferences-charts.jpg | Bin 0 -> 62538 bytes .../html/images/GMC-Preferences-gluster .jpg | Bin 0 -> 52380 bytes .../html/images/GMC_02.jpg | Bin 0 -> 39901 bytes .../html/images/GMC_03.jpg | Bin 0 -> 14542 bytes .../html/images/GMC_04.jpg | Bin 0 -> 18303 bytes .../html/images/GMC_05.jpg | Bin 0 -> 16557 bytes .../html/images/GMC_06.jpg | Bin 0 -> 16959 bytes .../html/images/GMC_07.jpg | Bin 0 -> 93914 bytes .../html/images/GMC_09.jpg | Bin 0 -> 52606 bytes .../html/images/GMC_1.0_Add_Brick.jpg | Bin 0 -> 101781 bytes .../html/images/GMC_1.0_Add_Brick_confirm.jpg | Bin 0 -> 28654 bytes .../html/images/GMC_1.0_Add_Server_Confirm.jpg | Bin 0 -> 18572 bytes .../html/images/GMC_1.0_Create_Vol.jpg | Bin 0 -> 40060 bytes .../html/images/GMC_1.0_Discovered_Server_Add.jpg | Bin 0 -> 92039 bytes .../html/images/GMC_1.0_Display_log_criteria.jpg | Bin 0 -> 333591 bytes .../html/images/GMC_1.0_Remove_Brick_confirm.jpg | Bin 0 -> 19105 bytes .../html/images/GMC_1.0_Remove_Bricks.jpg | Bin 0 -> 28865 bytes .../html/images/GMC_1.0_Remove_Bricks_success.jpg | Bin 0 -> 18917 bytes .../html/images/GMC_1.0_Remove_Server.jpg | Bin 0 -> 15948 bytes .../html/images/GMC_1.0_Remove_Server_1.jpg | Bin 0 -> 20426 bytes .../html/images/GMC_1.0_Select_FS_Type.jpg | Bin 0 -> 19850 bytes .../html/images/GMC_1.0_create_cluster.jpg | Bin 0 -> 12353 bytes .../html/images/GMC_1.0_login.jpg | Bin 0 -> 14542 bytes .../html/images/GMC_1.0_multiple_vols.jpg | Bin 0 -> 12508 bytes .../html/images/GMC_1.0_multiple_vols_confirm.jpg | Bin 0 -> 11321 bytes .../html/images/GMC_1.0_register_cluster.jpg | Bin 0 -> 15437 bytes .../html/images/GMC_1.0_removeBrick_confirm.jpg | Bin 0 -> 29142 bytes .../html/images/GMC_1.0_select_cluster.jpg | Bin 0 -> 18303 bytes .../html/images/GMC_1.0_server_add_success.jpg | Bin 0 -> 10640 bytes .../html/images/GMC_1.0_vol_success.jpg | Bin 0 -> 18866 bytes .../html/images/GMC_10.jpg | Bin 0 -> 70046 bytes .../html/images/GMC_Add_Brick.jpg | Bin 0 -> 89897 bytes .../html/images/GMC_Add_Brick_confirm.jpg | Bin 0 -> 21385 bytes .../html/images/GMC_Add_Brick_icon.jpg | Bin 0 -> 1536 bytes .../html/images/GMC_Add_Server_Manual.jpg | Bin 0 -> 11525 bytes .../html/images/GMC_Add_brick.jpg | Bin 0 -> 68440 bytes .../html/images/GMC_Add_brick_confirm.jpg | Bin 0 -> 15084 bytes .../html/images/GMC_Alerts.jpg | Bin 0 -> 52402 bytes .../html/images/GMC_Bricks_Tab.jpg | Bin 0 -> 115478 bytes .../html/images/GMC_Change_Password.jpg | Bin 0 -> 22096 bytes .../html/images/GMC_Change_Password_Confirm.jpg | Bin 0 -> 17204 bytes .../html/images/GMC_Charts.jpg | Bin 0 -> 60205 bytes .../html/images/GMC_Clear_task_icon.jpg | Bin 0 -> 1276 bytes .../html/images/GMC_Cluster_Summary.jpg | Bin 0 -> 106434 bytes .../html/images/GMC_Cluster_Summary_tab.jpg | Bin 0 -> 212681 bytes .../html/images/GMC_Cluster_Summary_tab_new.jpg | Bin 0 -> 172135 bytes .../html/images/GMC_Create_Cluster.jpg | Bin 0 -> 19986 bytes .../html/images/GMC_Create_Vol_icon.jpg | Bin 0 -> 1340 bytes .../html/images/GMC_Create_Volume.jpg | Bin 0 -> 63917 bytes .../html/images/GMC_Create_Volume_success.jpg | Bin 0 -> 19385 bytes .../html/images/GMC_Delete_Vol.jpg | Bin 0 -> 26774 bytes .../html/images/GMC_Delete_Vol_Confirm.jpg | Bin 0 -> 17356 bytes .../html/images/GMC_Delete_Vol_multiple.jpg | Bin 0 -> 30788 bytes .../images/GMC_Delete_Vol_multiple_success.jpg | Bin 0 -> 19616 bytes .../html/images/GMC_Delete_Vol_success.jpg | Bin 0 -> 18884 bytes .../html/images/GMC_Disk_tab.jpg | Bin 0 -> 224966 bytes .../html/images/GMC_Landing_Page.jpg | Bin 0 -> 163592 bytes .../html/images/GMC_Log_list.jpg | Bin 0 -> 171345 bytes .../html/images/GMC_Login_Change_Pwd.jpg | Bin 0 -> 22584 bytes .../html/images/GMC_Login_Window.jpg | Bin 0 -> 28664 bytes .../html/images/GMC_Migrate_Brick.jpg | Bin 0 -> 107849 bytes .../html/images/GMC_Migrate_Brick_success.jpg | Bin 0 -> 17196 bytes .../html/images/GMC_Preferences_alerts.jpg | Bin 0 -> 55125 bytes .../html/images/GMC_Preferences_charts.jpg | Bin 0 -> 62538 bytes .../html/images/GMC_Preferences_gluster.jpg | Bin 0 -> 51110 bytes .../html/images/GMC_Preferences_terminal.jpg | Bin 0 -> 52304 bytes .../html/images/GMC_Rebalance_icon.jpg | Bin 0 -> 1559 bytes .../html/images/GMC_Refresh.jpg | Bin 0 -> 1572 bytes .../html/images/GMC_Register_Cluster.jpg | Bin 0 -> 21831 bytes .../html/images/GMC_Remove_Brick_Confirm.jpg | Bin 0 -> 19955 bytes .../html/images/GMC_Remove_Brick_icon.jpg | Bin 0 -> 1567 bytes .../html/images/GMC_Remove_Server_icon.jpg | Bin 0 -> 1506 bytes .../html/images/GMC_Remove_server.jpg | Bin 0 -> 20022 bytes .../html/images/GMC_Remove_server_success.jpg | Bin 0 -> 17303 bytes .../html/images/GMC_Select_Cluster.jpg | Bin 0 -> 23467 bytes .../html/images/GMC_Select_Cluster_progess.jpg | Bin 0 -> 19762 bytes .../html/images/GMC_Server_Disk.jpg | Bin 0 -> 222242 bytes .../html/images/GMC_Server_Summ.jpg | Bin 0 -> 165858 bytes .../html/images/GMC_Server_Summary_tab.jpg | Bin 0 -> 100798 bytes .../html/images/GMC_Server_Tab.jpg | Bin 0 -> 109711 bytes .../html/images/GMC_Single_Vol.jpg | Bin 0 -> 13304 bytes .../html/images/GMC_Start_task_icon.jpg | Bin 0 -> 1298 bytes .../html/images/GMC_Stop_Multiple_Vol.jpg | Bin 0 -> 14017 bytes .../html/images/GMC_Stop_Vol.jpg | Bin 0 -> 12503 bytes .../html/images/GMC_Stop_icon.jpg | Bin 0 -> 1103 bytes .../html/images/GMC_Task_tab.jpg | Bin 0 -> 101601 bytes .../html/images/GMC_Terminal_window.jpg | Bin 0 -> 135724 bytes .../html/images/GMC_Toolbar.jpg | Bin 0 -> 15211 bytes .../html/images/GMC_Vol_List.jpg | Bin 0 -> 67235 bytes .../html/images/GMC_Vol_Options.jpg | Bin 0 -> 80035 bytes .../html/images/GMC_Vol_rebalance_success.jpg | Bin 0 -> 12603 bytes .../html/images/GMC_Volume_Options.jpg | Bin 0 -> 135662 bytes .../html/images/GMC_Volume_Summary.jpg | Bin 0 -> 113645 bytes .../html/images/GMC_Volume_Summary_tab.jpg | Bin 0 -> 97314 bytes .../html/images/GMC_Volume_logs.jpg | Bin 0 -> 314494 bytes .../html/images/GMC_Volume_properties.jpg | Bin 0 -> 145098 bytes .../html/images/GMC_Volumes_tab.jpg | Bin 0 -> 115212 bytes .../html/images/GMC_add_server_icon.jpg | Bin 0 -> 1391 bytes .../html/images/GMC_change_pwd.jpg | Bin 0 -> 16076 bytes .../html/images/GMC_create_vol (2).jpg | Bin 0 -> 44511 bytes .../html/images/GMC_create_vol.jpg | Bin 0 -> 44511 bytes .../html/images/GMC_download_log_icon.jpg | Bin 0 -> 1611 bytes .../html/images/GMC_landing_page.jpg | Bin 0 -> 106427 bytes .../html/images/GMC_log_criteria.jpg | Bin 0 -> 117809 bytes .../html/images/GMC_migrate_brick.jpg | Bin 0 -> 60009 bytes .../html/images/GMC_migrate_brick_icon.jpg | Bin 0 -> 1647 bytes .../html/images/GMC_pause_icon.jpg | Bin 0 -> 1262 bytes .../html/images/GMC_pwd_change_success.jpg | Bin 0 -> 11852 bytes .../html/images/GMC_rebalance_vol.jpg | Bin 0 -> 18396 bytes .../html/images/GMC_remove_server_confirm.jpg | Bin 0 -> 11560 bytes .../html/images/GMC_remove_volume_icon.jpg | Bin 0 -> 1517 bytes .../html/images/GMC_server_summary.jpg | Bin 0 -> 70046 bytes .../html/images/GMC_setting_icon.jpg | Bin 0 -> 1619 bytes .../html/images/GMC_settings.jpg | Bin 0 -> 1596 bytes .../html/images/GMC_start_vol_Multiple.jpg | Bin 0 -> 19551 bytes .../html/images/GMC_start_vol_icon.jpg | Bin 0 -> 1540 bytes .../html/images/GMC_start_vol_success.jpg | Bin 0 -> 18795 bytes .../html/images/GMC_stop_vol_Multiple.jpg | Bin 0 -> 19551 bytes .../html/images/GMC_stop_vol_icon.jpg | Bin 0 -> 1545 bytes .../html/images/GMC_terminal_Settings.jpg | Bin 0 -> 34801 bytes .../html/images/GMC_terminal_toolbar.jpg | Bin 0 -> 1371 bytes .../html/images/GMG_Architecture.jpg | Bin 0 -> 46322 bytes .../html/images/GlusterFS_3.2_Architecture.jpg | Bin 0 -> 62893 bytes .../html/images/GlusterFS_3.2_Architecture.png | Bin 0 -> 133597 bytes .../html/images/GlusterMC_Architecture.jpg | Bin 0 -> 69990 bytes .../html/images/Migration.png | Bin 0 -> 126167 bytes .../html/images/Preferences-alerts .png | Bin 0 -> 33540 bytes .../html/images/Preferences-charts.png | Bin 0 -> 43267 bytes .../html/images/Preferences-gluster .png | Bin 0 -> 29612 bytes .../html/images/Running tasks & alerts.png | Bin 0 -> 131944 bytes .../html/images/Stop_Vol.jpg | Bin 0 -> 20638 bytes .../html/images/Stop_Vol_confirm.jpg | Bin 0 -> 18391 bytes .../html/images/Stop_Vol_multiple.jpg | Bin 0 -> 20979 bytes .../html/images/Stop_Vol_multiple_confirm.jpg | Bin 0 -> 19308 bytes .../html/images/discovered_servers.png | Bin 0 -> 80490 bytes .../html/images/java-web-start.jpg | Bin 0 -> 33899 bytes .../html/images/java_web_start.jpg | Bin 0 -> 33899 bytes .../html/images/login-dialog.png | Bin 0 -> 67859 bytes .../html/reference/maintopic.html | 13 + .../html/reference/subtopic.html | 13 + .../html/reference/subtopic2.html | 13 + .../html/tasks/access_gmc_jws.html | 32 + .../html/tasks/add_brick.html | 34 + .../html/tasks/add_servers.html | 31 + .../html/tasks/configure_gmc.html | 19 + .../html/tasks/create_cluster.html | 25 + .../html/tasks/create_volume.html | 47 + .../html/tasks/delete_brick.html | 40 + .../html/tasks/delete_volume.html | 34 + .../html/tasks/deploy_gmc_dedicated_host.html | 36 + .../html/tasks/display_log.html | 26 + .../html/tasks/download_log.html | 23 + .../html/tasks/initialize_disk.html | 25 + .../html/tasks/logging.html | 16 + .../html/tasks/maintopic (3).html | 13 + .../html/tasks/maintopic.html | 13 + .../html/tasks/migrate_brick.html | 30 + .../html/tasks/rebalance_vol.html | 24 + .../html/tasks/register_cluster.html | 23 + .../html/tasks/remove_brick.html | 38 + .../html/tasks/remove_server.html | 27 + .../html/tasks/select_cluster.html | 26 + .../html/tasks/start_vol.html | 28 + .../html/tasks/starting_gmc.html | 15 + .../html/tasks/stop_vol.html | 26 + .../html/tasks/subtopic.html | 13 + .../html/tasks/subtopic2 (3).html | 13 + .../html/tasks/subtopic2.html | 13 + .../html/tasks/subtopic3.html | 13 + .../html/tasks/subtopic4.html | 13 + .../html/tasks/subtopic5.html | 13 + .../html/tasks/subtopic6.html | 13 + .../html/tasks/tune_vol_opt.html | 24 + .../html/tasks/volumes.html | 38 + .../html/toc.html | 15 + .../plugin.xml | 26 + .../toc.xml | 14 + .../tocconcepts.xml | 12 + .../tocgettingstarted.xml | 52 + .../tocreference.xml | 11 + .../toctasks.xml | 40 + .../.classpath | 7 + .../.project | 34 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 33 + .../build.properties | 18 + .../icons/tango/16x16/arrow-down.png | Bin 0 -> 683 bytes .../icons/tango/16x16/arrow-up.png | Bin 0 -> 652 bytes .../icons/tango/16x16/bricks.png | Bin 0 -> 807 bytes .../icons/tango/16x16/close_task.png | Bin 0 -> 588 bytes .../icons/tango/16x16/cluster.png | Bin 0 -> 622 bytes .../icons/tango/16x16/disk-available.png | Bin 0 -> 769 bytes .../icons/tango/16x16/disk-error.png | Bin 0 -> 801 bytes .../icons/tango/16x16/disk-initialisation.png | Bin 0 -> 817 bytes .../icons/tango/16x16/disk-inuse.png | Bin 0 -> 798 bytes .../icons/tango/16x16/disk-uninitialized.png | Bin 0 -> 809 bytes .../icons/tango/16x16/disk.png | Bin 0 -> 717 bytes .../icons/tango/16x16/gluster_icon.png | Bin 0 -> 3131 bytes .../icons/tango/16x16/help.png | Bin 0 -> 932 bytes .../icons/tango/16x16/logs.png | Bin 0 -> 796 bytes .../icons/tango/16x16/offline-brick.png | Bin 0 -> 621 bytes .../icons/tango/16x16/online-brick.png | Bin 0 -> 532 bytes .../icons/tango/16x16/pause.png | Bin 0 -> 729 bytes .../icons/tango/16x16/question.png | Bin 0 -> 766 bytes .../icons/tango/16x16/running-task.png | Bin 0 -> 858 bytes .../icons/tango/16x16/server.png | Bin 0 -> 725 bytes .../icons/tango/16x16/servers.png | Bin 0 -> 393 bytes .../icons/tango/16x16/settings.png | Bin 0 -> 588 bytes .../icons/tango/16x16/start.png | Bin 0 -> 734 bytes .../icons/tango/16x16/status-offline.png | Bin 0 -> 945 bytes .../icons/tango/16x16/status-online.png | Bin 0 -> 689 bytes .../icons/tango/16x16/stop.png | Bin 0 -> 690 bytes .../icons/tango/16x16/task-completed.png | Bin 0 -> 767 bytes .../icons/tango/16x16/task-error.png | Bin 0 -> 768 bytes .../icons/tango/16x16/utilities-terminal.png | Bin 0 -> 668 bytes .../icons/tango/16x16/view-refresh.png | Bin 0 -> 912 bytes .../icons/tango/16x16/volume-create.png | Bin 0 -> 635 bytes .../icons/tango/16x16/volume-options.png | Bin 0 -> 713 bytes .../icons/tango/16x16/volume.png | Bin 0 -> 774 bytes .../icons/tango/16x16/volumes.png | Bin 0 -> 830 bytes .../icons/tango/22x22/disk-initialisation.png | Bin 0 -> 1100 bytes .../icons/tango/22x22/high-memory-usage.png | Bin 0 -> 834 bytes .../icons/tango/22x22/low-diskspace.png | Bin 0 -> 1042 bytes .../icons/tango/22x22/migrate-brick.png | Bin 0 -> 1213 bytes .../icons/tango/22x22/offline-brick.png | Bin 0 -> 835 bytes .../icons/tango/22x22/offline-server.png | Bin 0 -> 1276 bytes .../icons/tango/22x22/offline-volume.png | Bin 0 -> 1034 bytes .../icons/tango/22x22/server-warning.png | Bin 0 -> 806 bytes .../icons/tango/22x22/system-search.png | Bin 0 -> 1267 bytes .../icons/tango/22x22/utilities-terminal.png | Bin 0 -> 1026 bytes .../icons/tango/22x22/volume-rebalance.png | Bin 0 -> 955 bytes .../icons/tango/32x32/add-brick-disabled.png | Bin 0 -> 2063 bytes .../icons/tango/32x32/add-brick.png | Bin 0 -> 2105 bytes .../icons/tango/32x32/add-server.png | Bin 0 -> 2137 bytes .../icons/tango/32x32/clear-task-disabled.png | Bin 0 -> 1416 bytes .../icons/tango/32x32/clear-task.png | Bin 0 -> 1424 bytes .../icons/tango/32x32/commit-task-disabled.png | Bin 0 -> 1246 bytes .../icons/tango/32x32/commit-task.png | Bin 0 -> 1294 bytes .../icons/tango/32x32/create-volume-disabled.png | Bin 0 -> 1929 bytes .../icons/tango/32x32/create-volume.png | Bin 0 -> 1788 bytes .../icons/tango/32x32/disk.png | Bin 0 -> 1155 bytes .../icons/tango/32x32/download-log.png | Bin 0 -> 2065 bytes .../icons/tango/32x32/help.png | Bin 0 -> 2231 bytes .../icons/tango/32x32/log-rotate.png | Bin 0 -> 1839 bytes .../icons/tango/32x32/logs.png | Bin 0 -> 1886 bytes .../icons/tango/32x32/migrate-brick-disabled.png | Bin 0 -> 2591 bytes .../icons/tango/32x32/migrate-brick.png | Bin 0 -> 2343 bytes .../icons/tango/32x32/pause-disabled.png | Bin 0 -> 1001 bytes .../icons/tango/32x32/pause.png | Bin 0 -> 1037 bytes .../icons/tango/32x32/remove-brick-disabled.png | Bin 0 -> 2206 bytes .../icons/tango/32x32/remove-brick.png | Bin 0 -> 1988 bytes .../icons/tango/32x32/remove-server-disabled.png | Bin 0 -> 1907 bytes .../icons/tango/32x32/remove-server.png | Bin 0 -> 2143 bytes .../icons/tango/32x32/remove-volume-disabled.png | Bin 0 -> 1644 bytes .../icons/tango/32x32/remove-volume.png | Bin 0 -> 1712 bytes .../tango/32x32/reset-volume-option-disabled.png | Bin 0 -> 2273 bytes .../icons/tango/32x32/reset-volume-option.png | Bin 0 -> 2303 bytes .../icons/tango/32x32/server.png | Bin 0 -> 1591 bytes .../icons/tango/32x32/servers.png | Bin 0 -> 1264 bytes .../icons/tango/32x32/settings.png | Bin 0 -> 2544 bytes .../icons/tango/32x32/start-disabled.png | Bin 0 -> 1181 bytes .../icons/tango/32x32/start-volume-disabled.png | Bin 0 -> 1968 bytes .../icons/tango/32x32/start-volume.png | Bin 0 -> 1818 bytes .../icons/tango/32x32/start.png | Bin 0 -> 1207 bytes .../icons/tango/32x32/stop-disabled.png | Bin 0 -> 532 bytes .../icons/tango/32x32/stop-volume-disabled.png | Bin 0 -> 1851 bytes .../icons/tango/32x32/stop-volume.png | Bin 0 -> 1754 bytes .../icons/tango/32x32/stop.png | Bin 0 -> 540 bytes .../icons/tango/32x32/utilities-terminal.png | Bin 0 -> 1488 bytes .../icons/tango/32x32/view-refresh.png | Bin 0 -> 2024 bytes .../tango/32x32/volume-rebalance-disabled.png | Bin 0 -> 1927 bytes .../icons/tango/32x32/volume-rebalance.png | Bin 0 -> 1969 bytes .../icons/tango/32x32/volume.png | Bin 0 -> 1446 bytes .../icons/tango/48x48/add-server.png | Bin 0 -> 3606 bytes .../icons/tango/48x48/create-volume.png | Bin 0 -> 2898 bytes .../icons/tango/48x48/remove-brick-disabled.png | Bin 0 -> 3186 bytes .../icons/tango/48x48/server.png | Bin 0 -> 3295 bytes .../icons/tango/48x48/start-volume-disabled.png | Bin 0 -> 2742 bytes .../icons/tango/48x48/stop-volume-disabled.png | Bin 0 -> 2470 bytes .../icons/tango/8x8/offline.png | Bin 0 -> 381 bytes .../icons/tango/8x8/online.png | Bin 0 -> 315 bytes .../icons/tango/8x8/star.png | Bin 0 -> 244 bytes .../icons/tango/scalable/add_brick.svg | 4155 ++++++++++++++++++ .../icons/tango/scalable/add_volume.svg | 3235 ++++++++++++++ .../icons/tango/scalable/brick.svg | 652 +++ .../icons/tango/scalable/brick_migration.svg | 3697 ++++++++++++++++ .../icons/tango/scalable/bricks.svg | 684 +++ .../icons/tango/scalable/cloud.svg | 425 ++ .../tango/scalable/create-volume-disabled.svg | 3044 +++++++++++++ .../icons/tango/scalable/create-volume.svg | 3006 +++++++++++++ .../icons/tango/scalable/disk (32-32).svg | 1088 +++++ .../icons/tango/scalable/disk (48-48).svg | 2263 ++++++++++ .../icons/tango/scalable/disk.svg | 850 ++++ .../icons/tango/scalable/disk_available.svg | 1983 +++++++++ .../icons/tango/scalable/disk_error.svg | 1991 +++++++++ .../icons/tango/scalable/disk_initialisation.svg | 2302 ++++++++++ .../icons/tango/scalable/disk_inuse.svg | 1848 ++++++++ .../icons/tango/scalable/disk_uninitialised.svg | 2585 +++++++++++ .../icons/tango/scalable/download_log.svg | 1187 ++++++ .../icons/tango/scalable/high_CPU_usage.svg | 1661 ++++++++ .../icons/tango/scalable/high_memory_usage.svg | 589 +++ .../icons/tango/scalable/log.svg | 1160 +++++ .../icons/tango/scalable/low_diskspace.svg | 1790 ++++++++ .../icons/tango/scalable/offline-8x8.svg | 154 + .../icons/tango/scalable/offline.svg | 1637 +++++++ .../icons/tango/scalable/offline_brick.svg | 4413 +++++++++++++++++++ .../icons/tango/scalable/offline_brick_alert.svg | 713 ++++ .../icons/tango/scalable/offline_server.svg | 838 ++++ .../icons/tango/scalable/offline_volume.svg | 3171 ++++++++++++++ .../icons/tango/scalable/online-8x8.svg | 246 ++ .../icons/tango/scalable/online.svg | 1410 ++++++ .../icons/tango/scalable/remove-server.svg | 141 + .../icons/tango/scalable/remove_brick.svg | 4483 ++++++++++++++++++++ .../icons/tango/scalable/remove_volume.svg | 3248 ++++++++++++++ .../icons/tango/scalable/reset_volume_option.svg | 2946 +++++++++++++ .../icons/tango/scalable/running_task.svg | 1498 +++++++ .../icons/tango/scalable/star-8x8.svg | 15 + .../icons/tango/scalable/start-volume-disabled.svg | 3350 +++++++++++++++ .../icons/tango/scalable/start_volume.svg | 3312 +++++++++++++++ .../icons/tango/scalable/stop_volume.svg | 3268 ++++++++++++++ .../icons/tango/scalable/task_clear.svg | 845 ++++ .../icons/tango/scalable/task_commit.svg | 310 ++ .../icons/tango/scalable/task_pause.svg | 821 ++++ .../icons/tango/scalable/task_paused.svg | 812 ++++ .../icons/tango/scalable/task_resume.svg | 395 ++ .../icons/tango/scalable/task_running.svg | 796 ++++ .../icons/tango/scalable/task_status_completed.svg | 577 +++ .../icons/tango/scalable/task_status_error.svg | 654 +++ .../icons/tango/scalable/task_stop.svg | 748 ++++ .../icons/tango/scalable/task_stopped.svg | 784 ++++ .../icons/tango/scalable/utilities-terminal.svg | 500 +++ .../icons/tango/scalable/view-refresh.svg | 393 ++ .../icons/tango/scalable/volume.svg | 2917 +++++++++++++ .../icons/tango/scalable/volume_option.svg | 2875 +++++++++++++ .../icons/tango/scalable/volume_rebalance.svg | 3713 ++++++++++++++++ .../icons/tango/scalable/volumes.svg | 2949 +++++++++++++ .../images/gauge.png | Bin 0 -> 45242 bytes .../images/gauge_small.png | Bin 0 -> 13875 bytes .../images/gluster-about.png | Bin 0 -> 34661 bytes .../images/login-screen-with-text.psd | Bin 0 -> 4367373 bytes .../images/login-screen.psd | Bin 0 -> 1512790 bytes .../images/splash-dialog.bmp | Bin 0 -> 248192 bytes .../images/splash-screen.psd | Bin 0 -> 2004782 bytes .../plugin.properties | 7 + .../plugin.xml | 1658 ++++++++ .../preferences.ini | 3 + .../splash.bmp | Bin 0 -> 381054 bytes .../storage/management/console/Activator.java | 83 + .../storage/management/console/AlertsManager.java | 216 + .../storage/management/console/Application.java | 135 + .../console/ApplicationActionBarAdvisor.java | 102 + .../console/ApplicationWorkbenchAdvisor.java | 98 + .../console/ApplicationWorkbenchWindowAdvisor.java | 63 + .../console/BrickTableLabelProvider.java | 85 + .../management/console/ConsoleConstants.java | 29 + .../console/DeviceTableLabelProvider.java | 160 + .../console/EntityGroupContentProvider.java | 45 + .../console/GlusterDataModelManager.java | 1036 +++++ .../console/GlusterServerTableLabelProvider.java | 77 + .../storage/management/console/ICommandIds.java | 33 + .../management/console/IEntityListener.java | 37 + .../storage/management/console/IImageKeys.java | 97 + .../NetworkInterfaceTableLabelProvider.java | 44 + .../storage/management/console/Perspective.java | 36 + .../console/ServerDiskTableLabelProvider.java | 134 + .../console/ServerTableLabelProvider.java | 53 + .../console/TableLabelProviderAdapter.java | 58 + .../console/TasksTableLabelProvider.java | 71 + .../console/VolumeLogTableLabelProvider.java | 41 + .../console/VolumeOptionsContentProvider.java | 47 + .../console/VolumeOptionsTableLabelProvider.java | 39 + .../console/VolumeTableLabelProvider.java | 82 + .../console/actions/AbstractActionDelegate.java | 103 + .../actions/AbstractMonitoredActionDelegate.java | 56 + .../console/actions/ActionConstants.java | 36 + .../management/console/actions/AddBrickAction.java | 64 + .../console/actions/AddServerAction.java | 124 + .../console/actions/ChangePasswordAction.java | 23 + .../console/actions/ClearTaskAction.java | 46 + .../console/actions/CommitTaskAction.java | 72 + .../console/actions/CreateVolumeAction.java | 53 + .../console/actions/DeleteVolumeAction.java | 210 + .../console/actions/DownloadVolumeLogsAction.java | 61 + .../console/actions/EditVolumeAction.java | 33 + .../console/actions/ExportSshKeysAction.java | 61 + .../console/actions/ForceStartVolumeAction.java | 71 + .../console/actions/ImportSshKeysAction.java | 44 + .../console/actions/MigrateBrickAction.java | 69 + .../console/actions/MigrateVolumeAction.java | 33 + .../console/actions/PauseTaskAction.java | 67 + .../console/actions/PreferencesAction.java | 36 + .../console/actions/RebalanceVolumeAction.java | 82 + .../console/actions/RefreshDataAction.java | 43 + .../console/actions/RemoveBrickAction.java | 91 + .../console/actions/RemoveServerAction.java | 159 + .../console/actions/ResetVolumeOptionsAction.java | 62 + .../console/actions/ResumeTaskAction.java | 45 + .../console/actions/ServerAdditionAction.java | 28 + .../console/actions/StartVolumeAction.java | 171 + .../management/console/actions/StopTaskAction.java | 46 + .../console/actions/StopVolumeAction.java | 229 + .../management/console/actions/SupportAction.java | 48 + .../management/console/actions/TerminalAction.java | 44 + .../console/actions/TestPopupMenuAction.java | 63 + .../console/actions/VolumeLogRotateAction.java | 64 + .../management/console/dialogs/AddBrickPage.java | 171 + .../management/console/dialogs/AddBrickWizard.java | 96 + .../console/dialogs/BricksSelectionPage.java | 336 ++ .../console/dialogs/ChangePasswordDialog.java | 284 ++ .../console/dialogs/ClusterSelectionDialog.java | 474 +++ .../console/dialogs/CreateVolumePage1.java | 473 +++ .../console/dialogs/CreateVolumeWizard.java | 158 + .../console/dialogs/GlusterSupportDialog.java | 139 + .../management/console/dialogs/InitDiskDialog.java | 212 + .../management/console/dialogs/LoginDialog.java | 359 ++ .../console/dialogs/MigrateBrickPage1.java | 302 ++ .../console/dialogs/MigrateBrickWizard.java | 106 + .../console/dialogs/SelectDisksDialog.java | 113 + .../console/dialogs/ServerAdditionDialog.java | 197 + .../management/console/jobs/DataSyncJob.java | 68 + .../console/preferences/AlertsPreferencePage.java | 38 + .../console/preferences/ChartsPreferencePage.java | 65 + .../console/preferences/GlusterPreferencePage.java | 90 + .../console/preferences/PreferenceConstants.java | 40 + .../console/preferences/PreferenceInitializer.java | 60 + .../console/toolbar/GlusterToolbarManager.java | 105 + .../management/console/toolbar/ToolbarManager.java | 35 + .../management/console/utils/ChartUtil.java | 339 ++ .../console/utils/ChartViewerComposite.java | 475 +++ .../console/utils/EntityViewerFilter.java | 78 + .../management/console/utils/GUIHelper.java | 481 +++ .../console/utils/GlusterChartPalette.java | 479 +++ .../management/console/utils/GlusterLogger.java | 67 + .../management/console/utils/ImageUtil.java | 52 + .../console/utils/TableViewerComparator.java | 73 + .../validators/StringRequiredValidator.java | 61 + .../console/views/ClusterAdapterFactory.java | 101 + .../console/views/ClusterSummaryView.java | 469 ++ .../console/views/DiscoveredServerView.java | 90 + .../console/views/DiscoveredServersView.java | 83 + .../management/console/views/DisksView.java | 45 + .../console/views/GlusterServerDisksView.java | 84 + .../console/views/GlusterServerLogsView.java | 59 + .../console/views/GlusterServerSummaryView.java | 544 +++ .../console/views/GlusterServersSummaryView.java | 290 ++ .../console/views/GlusterServersView.java | 78 + .../console/views/GlusterViewsManager.java | 130 + .../views/NavigationTreeLabelDecorator.java | 87 + .../management/console/views/NavigationView.java | 161 + .../management/console/views/TasksView.java | 39 + .../management/console/views/ViewsManager.java | 38 + .../management/console/views/VolumeBricksView.java | 39 + .../management/console/views/VolumeLogsView.java | 58 + .../console/views/VolumeOptionsView.java | 36 + .../console/views/VolumeSummaryView.java | 859 ++++ .../management/console/views/VolumeView.java | 90 + .../console/views/VolumesSummaryView.java | 301 ++ .../management/console/views/VolumesView.java | 80 + .../console/views/pages/AbstractDisksPage.java | 335 ++ .../views/pages/AbstractTableTreeViewerPage.java | 191 + .../views/pages/AbstractTableViewerPage.java | 263 ++ .../management/console/views/pages/BricksPage.java | 123 + .../views/pages/DiskTreeContentProvider.java | 119 + .../management/console/views/pages/DisksPage.java | 70 + .../console/views/pages/GlusterServersPage.java | 138 + .../views/pages/OptionKeyEditingSupport.java | 120 + .../views/pages/OptionValueEditingSupport.java | 110 + .../console/views/pages/ServerDisksPage.java | 66 + .../console/views/pages/ServerLogsPage.java | 199 + .../console/views/pages/ServersPage.java | 138 + .../management/console/views/pages/TasksPage.java | 151 + .../console/views/pages/VolumeLogsPage.java | 431 ++ .../console/views/pages/VolumeOptionsPage.java | 360 ++ .../console/views/pages/VolumesPage.java | 135 + .../src/test.xml | 1 + src/org.gluster.storage.management.core/.classpath | 9 + src/org.gluster.storage.management.core/.project | 34 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 15 + .../build.properties | 7 + .../junit/core.junit.launch | 15 + .../storage/management/core/model/AlertTest.java | 83 + .../storage/management/core/model/BrickTest.java | 305 ++ .../storage/management/core/model/ClusterTest.java | 211 + .../storage/management/core/model/DiskTest.java | 487 +++ .../storage/management/core/model/TestAll.java | 35 + .../management/core/utils/DateUtilTest.java | 218 + .../management/core/utils/FileUtilTest.java | 482 +++ .../management/core/utils/StringUtilTest.java | 310 ++ .../junit/test/test.txt | 1 + .../management/core/constants/CoreConstants.java | 40 + .../core/constants/GlusterConstants.java | 48 + .../management/core/constants/RESTConstants.java | 125 + .../core/exceptions/ConnectionException.java | 37 + .../core/exceptions/GlusterRuntimeException.java | 31 + .../exceptions/GlusterValidationException.java | 27 + .../storage/management/core/model/Alert.java | 75 + .../storage/management/core/model/Brick.java | 123 + .../storage/management/core/model/Cluster.java | 196 + .../management/core/model/ClusterListener.java | 57 + .../management/core/model/ConnectionDetails.java | 64 + .../core/model/DefaultClusterListener.java | 118 + .../storage/management/core/model/Device.java | 228 + .../storage/management/core/model/Disk.java | 195 + .../storage/management/core/model/Entity.java | 88 + .../storage/management/core/model/EntityGroup.java | 47 + .../storage/management/core/model/Event.java | 62 + .../storage/management/core/model/Filterable.java | 37 + .../management/core/model/GlusterDataModel.java | 46 + .../management/core/model/GlusterDummyModel.java | 252 ++ .../management/core/model/GlusterServer.java | 82 + .../core/model/InitDiskStatusResponse.java | 89 + .../management/core/model/NetworkInterface.java | 112 + .../storage/management/core/model/Partition.java | 35 + .../storage/management/core/model/Response.java | 37 + .../storage/management/core/model/Server.java | 248 ++ .../storage/management/core/model/ServerStats.java | 73 + .../management/core/model/ServerStatsRow.java | 69 + .../management/core/model/StatsMetadata.java | 84 + .../storage/management/core/model/Status.java | 93 + .../storage/management/core/model/TaskInfo.java | 141 + .../storage/management/core/model/TaskStatus.java | 64 + .../storage/management/core/model/User.java | 43 + .../storage/management/core/model/Version.java | 65 + .../storage/management/core/model/Volume.java | 368 ++ .../management/core/model/VolumeLogMessage.java | 93 + .../management/core/model/VolumeOption.java | 67 + .../management/core/model/VolumeOptionInfo.java | 66 + .../management/core/model/VolumeOptions.java | 113 + .../core/model/adapters/VolumeLogDateAdapter.java | 54 + .../management/core/response/AbstractResponse.java | 35 + .../core/response/ClusterNameListResponse.java | 46 + .../core/response/FsTypeListResponse.java | 47 + .../core/response/GlusterServerListResponse.java | 55 + .../core/response/GlusterServerResponse.java | 36 + .../core/response/LogMessageListResponse.java | 34 + .../core/response/ServerListResponse.java | 49 + .../core/response/ServerNameListResponse.java | 46 + .../core/response/StringListResponse.java | 49 + .../management/core/response/TaskIdResponse.java | 46 + .../core/response/TaskInfoListResponse.java | 52 + .../management/core/response/TaskResponse.java | 53 + .../core/response/VolumeListResponse.java | 32 + .../response/VolumeOptionInfoListResponse.java | 45 + .../storage/management/core/utils/DateUtil.java | 120 + .../storage/management/core/utils/FileUtil.java | 138 + .../management/core/utils/GlusterCoreUtil.java | 206 + .../storage/management/core/utils/JavaUtil.java | 41 + .../storage/management/core/utils/LRUCache.java | 55 + .../gluster/storage/management/core/utils/MD5.java | 504 +++ .../storage/management/core/utils/MD5Crypt.java | 339 ++ .../storage/management/core/utils/NumberUtil.java | 30 + .../management/core/utils/ProcessResult.java | 69 + .../storage/management/core/utils/ProcessUtil.java | 109 + .../storage/management/core/utils/StringUtil.java | 120 + .../management/core/utils/ValidationUtil.java | 95 + .../org.python.pydev.PyDevBuilder.launch | 7 + .../.project | 22 + .../src/backend/DiskUtils.py | 198 + .../src/backend/FsTabUtils.py | 83 + .../src/backend/NetworkUtils.py | 152 + .../src/backend/VolumeUtils.py | 95 + .../src/backend/add_user_cifs.py | 65 + .../src/backend/clear_volume_directory.py | 48 + .../src/backend/create_volume_cifs.py | 47 + .../src/backend/delete_user_cifs.py | 31 + .../src/backend/delete_volume_cifs.py | 40 + .../src/backend/format_device.py | 108 + .../src/backend/format_device_background.py | 128 + .../src/backend/get_brick_status.py | 46 + .../src/backend/get_filesystem_type.py | 22 + .../src/backend/get_format_device_status.py | 93 + .../src/backend/get_rrd_cpu_details.py | 47 + .../src/backend/get_rrd_memory_details.py | 48 + .../src/backend/get_rrd_net_details.py | 41 + .../src/backend/get_server_details.py | 267 ++ .../src/backend/get_server_status.py | 28 + .../src/backend/get_volume_brick_log.py | 97 + .../src/backend/gluster-provision-block | 171 + .../src/backend/gluster-volume-settings.init.d | 20 + .../src/backend/gluster_cifs_volume_startup.py | 114 + .../src/backend/modify_volume_cifs.py | 36 + .../src/backend/multicast-discoverd.init.d | 48 + .../src/backend/multicast-discoverd.py | 103 + .../src/backend/rrd_cpu.pl | 84 + .../src/backend/rrd_mem.pl | 100 + .../src/backend/rrd_net.pl | 75 + .../src/backend/setup_cifs_config.py | 108 + .../src/backend/start_volume_cifs.py | 53 + .../src/backend/stop_volume_cifs.py | 48 + .../src/backend/update-rrd.sh | 6 + .../src/backend/update_volume_cifs.py | 37 + .../src/common/Globals.py | 35 + .../src/common/Utils.py | 329 ++ .../src/common/XmlHandler.py | 332 ++ .../src/gateway/add_user_cifs_all.py | 78 + .../src/gateway/create_volume_cifs_all.py | 62 + .../src/gateway/delete_user_cifs_all.py | 52 + .../src/gateway/delete_volume_cifs_all.py | 51 + .../src/gateway/get_volume_user_cifs.py | 38 + .../src/gateway/gmg-reset-password.sh | 26 + .../src/gateway/grun.py | 21 + .../src/gateway/multicast-discover-servers.py | 112 + .../gateway/remove_server_volume_cifs_config.py | 68 + .../src/gateway/setup_cifs_config_all.py | 29 + .../src/gateway/update_volume_cifs_all.py | 63 + .../.classpath | 14 + .../.project | 36 + .../.settings/.jsdtscope | 12 + .../.settings/org.eclipse.core.resources.prefs | 3 + .../.settings/org.eclipse.jdt.core.prefs | 8 + .../org.eclipse.ltk.core.refactoring.prefs | 3 + .../.settings/org.eclipse.wst.common.component | 10 + .../org.eclipse.wst.common.project.facet.core.xml | 20 + .../org.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../org.eclipse.wst.ws.service.policy.prefs | 3 + .../WebContent/META-INF/MANIFEST.MF | 3 + .../WebContent/WEB-INF/lib/Jersey-LICENSE.txt | 135 + .../lib/Jersey-third-party-license-readme.txt | 188 + .../WebContent/WEB-INF/lib/antlr-2.7.6.jar | Bin 0 -> 443432 bytes .../WebContent/WEB-INF/lib/aopalliance-1.0.jar | Bin 0 -> 4467 bytes .../WebContent/WEB-INF/lib/asm-3.1.jar | Bin 0 -> 43033 bytes .../WEB-INF/lib/commons-collections-3.1.jar | Bin 0 -> 559366 bytes .../WEB-INF/lib/commons-logging-1.1.1.jar | Bin 0 -> 60841 bytes .../WebContent/WEB-INF/lib/derby.jar | Bin 0 -> 2512189 bytes .../WebContent/WEB-INF/lib/derbytools.jar | Bin 0 -> 165188 bytes .../WebContent/WEB-INF/lib/dom4j-1.6.1.jar | Bin 0 -> 313898 bytes .../WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt | 87 + .../WEB-INF/lib/ganymed-ssh2-build250.jar | Bin 0 -> 248915 bytes .../lib/hibernate-jpa-2.0-api-1.0.0.Final.jar | Bin 0 -> 100884 bytes .../WebContent/WEB-INF/lib/hibernate3.jar | Bin 0 -> 4133342 bytes .../WEB-INF/lib/jackson-core-asl-1.5.5.jar | Bin 0 -> 171958 bytes .../WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar | Bin 0 -> 17065 bytes .../WEB-INF/lib/jackson-mapper-asl-1.5.5.jar | Bin 0 -> 485699 bytes .../WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar | Bin 0 -> 24745 bytes .../WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar | Bin 0 -> 633312 bytes .../WebContent/WEB-INF/lib/jersey-client-1.5.jar | Bin 0 -> 128096 bytes .../WebContent/WEB-INF/lib/jersey-core-1.5.jar | Bin 0 -> 455665 bytes .../WebContent/WEB-INF/lib/jersey-json-1.5.jar | Bin 0 -> 144810 bytes .../WEB-INF/lib/jersey-multipart-1.5.jar | Bin 0 -> 49330 bytes .../WebContent/WEB-INF/lib/jersey-server-1.5.jar | Bin 0 -> 681117 bytes .../WebContent/WEB-INF/lib/jersey-spring-1.5.jar | Bin 0 -> 17079 bytes .../WebContent/WEB-INF/lib/jettison-1.1.jar | Bin 0 -> 67758 bytes .../WebContent/WEB-INF/lib/jnlp-servlet.jar | Bin 0 -> 61712 bytes .../WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar | Bin 0 -> 46367 bytes .../WebContent/WEB-INF/lib/jta-1.1.jar | Bin 0 -> 10899 bytes .../WebContent/WEB-INF/lib/log4j-1.2.16.jar | Bin 0 -> 481534 bytes .../WebContent/WEB-INF/lib/mimepull-1.3.jar | Bin 0 -> 38683 bytes .../org.eclipse.equinox.common_3.6.0.v20100503.jar | Bin 0 -> 101958 bytes .../lib/org.springframework.aop-3.0.5.RELEASE.jar | Bin 0 -> 321190 bytes .../lib/org.springframework.asm-3.0.5.RELEASE.jar | Bin 0 -> 53082 bytes .../org.springframework.aspects-3.0.5.RELEASE.jar | Bin 0 -> 35548 bytes .../org.springframework.beans-3.0.5.RELEASE.jar | Bin 0 -> 555410 bytes .../org.springframework.context-3.0.5.RELEASE.jar | Bin 0 -> 668861 bytes ...ringframework.context.support-3.0.5.RELEASE.jar | Bin 0 -> 100870 bytes .../lib/org.springframework.core-3.0.5.RELEASE.jar | Bin 0 -> 382442 bytes ...rg.springframework.expression-3.0.5.RELEASE.jar | Bin 0 -> 169752 bytes ...rg.springframework.instrument-3.0.5.RELEASE.jar | Bin 0 -> 1810 bytes ...ngframework.instrument.tomcat-3.0.5.RELEASE.jar | Bin 0 -> 5728 bytes .../lib/org.springframework.jdbc-3.0.5.RELEASE.jar | Bin 0 -> 385712 bytes .../lib/org.springframework.jms-3.0.5.RELEASE.jar | Bin 0 -> 185312 bytes .../lib/org.springframework.orm-3.0.5.RELEASE.jar | Bin 0 -> 334327 bytes .../lib/org.springframework.oxm-3.0.5.RELEASE.jar | Bin 0 -> 61379 bytes ...ringframework.spring-library-3.0.5.RELEASE.libd | 21 + .../lib/org.springframework.test-3.0.5.RELEASE.jar | Bin 0 -> 205278 bytes ...g.springframework.transaction-3.0.5.RELEASE.jar | Bin 0 -> 231922 bytes .../lib/org.springframework.web-3.0.5.RELEASE.jar | Bin 0 -> 395587 bytes ...g.springframework.web.portlet-3.0.5.RELEASE.jar | Bin 0 -> 175412 bytes ...g.springframework.web.servlet-3.0.5.RELEASE.jar | Bin 0 -> 418977 bytes ...rg.springframework.web.struts-3.0.5.RELEASE.jar | Bin 0 -> 31404 bytes .../WebContent/WEB-INF/lib/servlet-api.jar | Bin 0 -> 176386 bytes .../WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar | Bin 0 -> 25496 bytes .../lib/spring-framework-3.0.5.RELEASE-LICENSE.txt | 201 + .../lib/spring-security-3.0.5.RELEASE-LICENSE.txt | 201 + .../lib/spring-security-config-3.0.5.RELEASE.jar | Bin 0 -> 185716 bytes .../lib/spring-security-core-3.0.5.RELEASE.jar | Bin 0 -> 311038 bytes .../lib/spring-security-web-3.0.5.RELEASE.jar | Bin 0 -> 242833 bytes .../WebContent/WEB-INF/web.xml | 76 + .../WebContent/data/scripts/1.0.0/0-version.sql | 2 + .../data/scripts/1.0.0/1-security-schema.sql | 26 + .../scripts/1.0.0/2-users-authorities-groups.sql | 18 + .../data/scripts/1.0.0/3-cluster-servers.sql | 16 + .../WebContent/index.html | 158 + .../WebContent/scripts/Globals.py | 1 + .../WebContent/scripts/Protocol.py | 1 + .../WebContent/scripts/Utils.py | 1 + .../WebContent/scripts/XmlHandler.py | 1 + .../WebContent/scripts/add_user_cifs_all.py | 1 + .../WebContent/scripts/create_volume_cifs_all.py | 1 + .../WebContent/scripts/delete_user_cifs_all.py | 1 + .../WebContent/scripts/delete_volume_cifs_all.py | 1 + .../WebContent/scripts/get_volume_user_cifs.py | 1 + .../WebContent/scripts/gmg-reset-password.sh | 1 + .../WebContent/scripts/grun.py | 1 + .../scripts/multicast-discover-servers.py | 1 + .../scripts/remove_server_volume_cifs_config.py | 1 + .../WebContent/scripts/setup_cifs_config_all.py | 1 + .../WebContent/scripts/update_volume_cifs_all.py | 1 + .../WebContent/ssl/gmg-ssl.keystore | Bin 0 -> 1380 bytes .../buckminster.cspex | 37 + .../build/glusterserver.ant | 70 + .../src/META-INF/persistence.xml | 5 + .../src/log4j.properties | 20 + .../management/gateway/data/ClusterInfo.java | 79 + .../management/gateway/data/GlusterDataSource.java | 48 + .../management/gateway/data/PersistenceDao.java | 113 + .../management/gateway/data/ServerInfo.java | 72 + .../management/gateway/filters/AuditFilter.java | 48 + .../filters/AuthenticationFailureFilter.java | 105 + .../filters/GlusterResourceFilterFactory.java | 31 + .../gateway/listeners/ShutdownListener.java | 48 + .../gateway/resources/v1_0/AbstractResource.java | 177 + .../gateway/resources/v1_0/ClustersResource.java | 126 + .../resources/v1_0/DiscoveredServersResource.java | 101 + .../resources/v1_0/GenericExceptionMapper.java | 60 + .../resources/v1_0/GlusterServersResource.java | 343 ++ .../gateway/resources/v1_0/KeysResource.java | 155 + .../gateway/resources/v1_0/TasksResource.java | 226 + .../gateway/resources/v1_0/UsersResource.java | 124 + .../gateway/resources/v1_0/VolumesResource.java | 383 ++ .../security/GlusterUserDetailsService.java | 31 + .../management/gateway/security/UserAuthDao.java | 57 + .../gateway/services/AbstractGlusterInterface.java | 38 + .../gateway/services/ClusterService.java | 269 ++ .../gateway/services/DiscoveredServerService.java | 130 + .../services/Gluster323InterfaceService.java | 598 +++ .../gateway/services/GlusterInterface.java | 369 ++ .../gateway/services/GlusterInterfaceService.java | 256 ++ .../gateway/services/GlusterServerService.java | 530 +++ .../management/gateway/services/VolumeService.java | 984 +++++ .../management/gateway/tasks/InitServerTask.java | 161 + .../gateway/tasks/InitializeDiskTask.java | 198 + .../management/gateway/tasks/MigrateBrickTask.java | 220 + .../gateway/tasks/RebalanceVolumeTask.java | 141 + .../management/gateway/tasks/ServerSyncTask.java | 168 + .../storage/management/gateway/tasks/Task.java | 113 + .../gateway/utils/AbstractStatsFactory.java | 162 + .../management/gateway/utils/CpuStatsFactory.java | 36 + .../storage/management/gateway/utils/DBUtil.java | 84 + .../gateway/utils/MemoryStatsFactory.java | 68 + .../gateway/utils/NetworkStatsFactory.java | 173 + .../management/gateway/utils/PasswordManager.java | 83 + .../management/gateway/utils/ServerUtil.java | 370 ++ .../storage/management/gateway/utils/SshUtil.java | 463 ++ .../management/gateway/utils/StatsFactory.java | 32 + .../src/rebel.xml | 16 + .../src/spring/gluster-server-base.xml | 100 + .../src/spring/gluster-server-security.xml | 49 + 1672 files changed, 144350 insertions(+), 144292 deletions(-) delete mode 100644 src/com.gluster.storage.management.client/.classpath delete mode 100644 src/com.gluster.storage.management.client/.project delete mode 100644 src/com.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs delete mode 100644 src/com.gluster.storage.management.client/META-INF/MANIFEST.MF delete mode 100644 src/com.gluster.storage.management.client/build.properties delete mode 100644 src/com.gluster.storage.management.client/keystore/gmc-trusted.keystore delete mode 100644 src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar delete mode 100644 src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar delete mode 100644 src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/TasksClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java delete mode 100644 src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/utils/ClientUtil.java delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/.project delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/buckminster.cspex delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/build.properties delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/build/glustermc.ant delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/feature.xml delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp delete mode 100644 src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png delete mode 100644 src/com.gluster.storage.management.console.feature/.project delete mode 100644 src/com.gluster.storage.management.console.feature/build.properties delete mode 100644 src/com.gluster.storage.management.console.feature/feature.xml delete mode 100644 src/com.gluster.storage.management.console.help/.project delete mode 100644 src/com.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs delete mode 100644 src/com.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs delete mode 100644 src/com.gluster.storage.management.console.help/META-INF/MANIFEST.MF delete mode 100644 src/com.gluster.storage.management.console.help/build.properties delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/about_gmc.html delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/about_gmg.html delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/common_terms.html delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/gluster_fs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/maintopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/subtopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/concepts/subtopic2.html delete mode 100644 src/com.gluster.storage.management.console.help/html/css/Builder/style.css delete mode 100644 src/com.gluster.storage.management.console.help/html/css/builder-gluster/style.css delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/ subtopic3.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/access_gmc_jws.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/alerts.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/change_password.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/check_req_client.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/check_req_gmg.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/cifs_service.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/configure_cifs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/explore_gmc.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/gmc_install_overview.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/gmc_terminal_window.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/gmc_toolbar.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/gmg_install_overview.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/install_gmg.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/install_gmg_backend.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/maintopic (4).html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/maintopic - Copy (3).html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/maintopic - Copy (4).html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/maintopic - Copy.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/maintopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/manage_bricks.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/manage_cluster.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/manage_logs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/manage_servers.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/manage_volumes.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/monitor_resources.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/resetting_pwd.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/security_keys.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/setting_alerts_prefs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/setting_charts_prefs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/setting_gluster_prefs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/setting_preferences.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/setting_terminal_prefs.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/setting_the_gmc.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/subtopic (3) - Copy.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/subtopic (3).html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/subtopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/subtopic2 (2).html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/subtopic2 (3).html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/subtopic2.html delete mode 100644 src/com.gluster.storage.management.console.help/html/gettingstarted/tasks.html delete mode 100644 src/com.gluster.storage.management.console.help/html/help_home.html delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Delete-brick.png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC-Preferences-alerts .jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC-Preferences-charts.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC-Preferences-gluster .jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_02.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_03.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_04.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_05.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_06.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_07.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_09.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Add_Brick.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Add_Brick_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Add_Server_Confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Create_Vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Discovered_Server_Add.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Display_log_criteria.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Brick_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Bricks.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Bricks_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Server.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Server_1.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_Select_FS_Type.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_create_cluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_login.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_multiple_vols.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_multiple_vols_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_register_cluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_removeBrick_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_select_cluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_server_add_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_1.0_vol_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_10.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Add_Brick.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Add_Brick_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Add_Brick_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Add_Server_Manual.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Add_brick.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Add_brick_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Alerts.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Bricks_Tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Change_Password.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Change_Password_Confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Charts.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Clear_task_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Cluster_Summary.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Cluster_Summary_tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Cluster_Summary_tab_new.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Create_Cluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Create_Vol_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Create_Volume.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Create_Volume_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Delete_Vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_Confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_multiple.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_multiple_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Disk_tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Landing_Page.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Log_list.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Login_Change_Pwd.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Login_Window.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Migrate_Brick.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Migrate_Brick_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Preferences_alerts.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Preferences_charts.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Preferences_gluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Preferences_terminal.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Rebalance_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Refresh.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Register_Cluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Remove_Brick_Confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Remove_Brick_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Remove_Server_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Remove_server.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Remove_server_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Select_Cluster.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Select_Cluster_progess.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Server_Disk.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Server_Summ.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Server_Summary_tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Server_Tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Single_Vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Start_task_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Stop_Multiple_Vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Stop_Vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Stop_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Task_tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Terminal_window.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Toolbar.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Vol_List.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Vol_Options.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Vol_rebalance_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Volume_Options.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Volume_Summary.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Volume_Summary_tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Volume_logs.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Volume_properties.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_Volumes_tab.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_add_server_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_change_pwd.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_create_vol (2).jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_create_vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_download_log_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_landing_page.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_log_criteria.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_migrate_brick.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_migrate_brick_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_pause_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_pwd_change_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_rebalance_vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_remove_server_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_remove_volume_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_server_summary.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_setting_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_settings.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_start_vol_Multiple.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_start_vol_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_start_vol_success.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_stop_vol_Multiple.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_stop_vol_icon.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_terminal_Settings.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMC_terminal_toolbar.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GMG_Architecture.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GlusterFS_3.2_Architecture.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GlusterFS_3.2_Architecture.png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/GlusterMC_Architecture.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Migration.png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Preferences-alerts .png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Preferences-charts.png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Preferences-gluster .png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Running tasks & alerts.png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Stop_Vol.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Stop_Vol_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Stop_Vol_multiple.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/Stop_Vol_multiple_confirm.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/discovered_servers.png delete mode 100644 src/com.gluster.storage.management.console.help/html/images/java-web-start.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/java_web_start.jpg delete mode 100644 src/com.gluster.storage.management.console.help/html/images/login-dialog.png delete mode 100644 src/com.gluster.storage.management.console.help/html/reference/maintopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/reference/subtopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/reference/subtopic2.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/access_gmc_jws.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/add_brick.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/add_servers.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/configure_gmc.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/create_cluster.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/create_volume.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/delete_brick.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/delete_volume.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/deploy_gmc_dedicated_host.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/display_log.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/download_log.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/initialize_disk.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/logging.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/maintopic (3).html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/maintopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/migrate_brick.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/rebalance_vol.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/register_cluster.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/remove_brick.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/remove_server.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/select_cluster.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/start_vol.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/starting_gmc.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/stop_vol.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic2 (3).html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic2.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic3.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic4.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic5.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/subtopic6.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/tune_vol_opt.html delete mode 100644 src/com.gluster.storage.management.console.help/html/tasks/volumes.html delete mode 100644 src/com.gluster.storage.management.console.help/html/toc.html delete mode 100644 src/com.gluster.storage.management.console.help/plugin.xml delete mode 100644 src/com.gluster.storage.management.console.help/toc.xml delete mode 100644 src/com.gluster.storage.management.console.help/tocconcepts.xml delete mode 100644 src/com.gluster.storage.management.console.help/tocgettingstarted.xml delete mode 100644 src/com.gluster.storage.management.console.help/tocreference.xml delete mode 100644 src/com.gluster.storage.management.console.help/toctasks.xml delete mode 100644 src/com.gluster.storage.management.console/.classpath delete mode 100644 src/com.gluster.storage.management.console/.project delete mode 100644 src/com.gluster.storage.management.console/.settings/org.eclipse.jdt.core.prefs delete mode 100644 src/com.gluster.storage.management.console/META-INF/MANIFEST.MF delete mode 100644 src/com.gluster.storage.management.console/build.properties delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/arrow-down.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/arrow-up.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/bricks.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/close_task.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/cluster.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/disk-available.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/disk-error.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/disk-initialisation.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/disk-inuse.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/disk-uninitialized.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/disk.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/gluster_icon.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/help.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/logs.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/offline-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/online-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/pause.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/question.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/running-task.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/servers.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/settings.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/start.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/status-offline.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/status-online.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/stop.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/task-completed.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/task-error.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/utilities-terminal.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/view-refresh.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/volume-create.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/volume-options.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/16x16/volumes.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/disk-initialisation.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/high-memory-usage.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/low-diskspace.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/migrate-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/offline-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/offline-server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/offline-volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/server-warning.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/system-search.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/utilities-terminal.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/22x22/volume-rebalance.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/add-brick-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/add-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/add-server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/clear-task-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/clear-task.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/commit-task-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/commit-task.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/create-volume-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/create-volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/disk.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/download-log.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/help.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/log-rotate.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/logs.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/migrate-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/pause-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/pause.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/remove-brick-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/remove-brick.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/remove-server-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/remove-server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/remove-volume-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/remove-volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/reset-volume-option-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/reset-volume-option.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/servers.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/settings.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/start-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/start-volume-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/start-volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/start.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/stop-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/stop-volume-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/stop-volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/stop.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/utilities-terminal.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/view-refresh.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/volume-rebalance-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/volume-rebalance.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/32x32/volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/48x48/add-server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/48x48/create-volume.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/48x48/remove-brick-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/48x48/server.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/48x48/start-volume-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/48x48/stop-volume-disabled.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/8x8/offline.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/8x8/online.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/8x8/star.png delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/add_brick.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/add_volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/brick.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/bricks.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/cloud.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/create-volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk_available.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk_error.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/download_log.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/log.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/offline.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/offline_server.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/online.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/remove-server.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/running_task.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/start_volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_clear.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_commit.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_pause.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_paused.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_resume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_running.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_stop.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/volume.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/volume_option.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg delete mode 100644 src/com.gluster.storage.management.console/icons/tango/scalable/volumes.svg delete mode 100644 src/com.gluster.storage.management.console/images/gauge.png delete mode 100644 src/com.gluster.storage.management.console/images/gauge_small.png delete mode 100644 src/com.gluster.storage.management.console/images/gluster-about.png delete mode 100644 src/com.gluster.storage.management.console/images/login-screen-with-text.psd delete mode 100644 src/com.gluster.storage.management.console/images/login-screen.psd delete mode 100644 src/com.gluster.storage.management.console/images/splash-dialog.bmp delete mode 100644 src/com.gluster.storage.management.console/images/splash-screen.psd delete mode 100644 src/com.gluster.storage.management.console/plugin.properties delete mode 100644 src/com.gluster.storage.management.console/plugin.xml delete mode 100644 src/com.gluster.storage.management.console/preferences.ini delete mode 100644 src/com.gluster.storage.management.console/splash.bmp delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Activator.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/AlertsManager.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Application.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationActionBarAdvisor.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/BrickTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/DeviceTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/EntityGroupContentProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterServerTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ICommandIds.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IEntityListener.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Perspective.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerDiskTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TableLabelProviderAdapter.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TasksTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeLogTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsContentProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeTableLabelProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ActionConstants.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddBrickAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddServerAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ChangePasswordAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ClearTaskAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CommitTaskAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CreateVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/EditVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ImportSshKeysAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PauseTaskAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PreferencesAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RefreshDataAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveServerAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResumeTaskAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ServerAdditionAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopTaskAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/SupportAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TerminalAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TestPopupMenuAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickWizard.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/BricksSelectionPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ChangePasswordDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/GlusterSupportDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/LoginDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickWizard.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/SelectDisksDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ServerAdditionDialog.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/jobs/DataSyncJob.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/AlertsPreferencePage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/ChartsPreferencePage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/GlusterPreferencePage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceConstants.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceInitializer.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/GlusterToolbarManager.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/ToolbarManager.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartUtil.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartViewerComposite.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/EntityViewerFilter.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterChartPalette.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterLogger.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ImageUtil.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/TableViewerComparator.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/validators/StringRequiredValidator.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterAdapterFactory.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServerView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServersView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DisksView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerDisksView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerLogsView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersSummaryView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TasksView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ViewsManager.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeBricksView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeLogsView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeOptionsView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesSummaryView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesView.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/BricksPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DisksPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/GlusterServersPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerDisksPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerLogsPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServersPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/TasksPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeLogsPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeOptionsPage.java delete mode 100644 src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumesPage.java delete mode 100644 src/com.gluster.storage.management.console/src/test.xml delete mode 100644 src/com.gluster.storage.management.core/.classpath delete mode 100644 src/com.gluster.storage.management.core/.project delete mode 100644 src/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs delete mode 100644 src/com.gluster.storage.management.core/META-INF/MANIFEST.MF delete mode 100644 src/com.gluster.storage.management.core/build.properties delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/DateUtilTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/FileUtilTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/StringUtilTest.java delete mode 100644 src/com.gluster.storage.management.core/junit/core.junit.launch delete mode 100644 src/com.gluster.storage.management.core/junit/test/test.txt delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/ConnectionException.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterValidationException.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Brick.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/InitDiskStatusResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Partition.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeLogMessage.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/AbstractResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ClusterNameListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/LogMessageListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerNameListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/StringListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskIdResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskInfoListResponse.java delete mode 100755 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/JavaUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/LRUCache.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java delete mode 100644 src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java delete mode 100644 src/com.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch delete mode 100644 src/com.gluster.storage.management.gateway.scripts/.project delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/format_device.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/gluster-volume-settings.init.d delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py delete mode 100644 src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/grun.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py delete mode 100755 src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py delete mode 100644 src/com.gluster.storage.management.gateway/.classpath delete mode 100644 src/com.gluster.storage.management.gateway/.project delete mode 100644 src/com.gluster.storage.management.gateway/.settings/.jsdtscope delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/index.html delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/Globals.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/Protocol.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py delete mode 120000 src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py delete mode 100644 src/com.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore delete mode 100644 src/com.gluster.storage.management.gateway/buckminster.cspex delete mode 100644 src/com.gluster.storage.management.gateway/build/glusterserver.ant delete mode 100644 src/com.gluster.storage.management.gateway/src/META-INF/persistence.xml delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ClusterInfo.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/GlusterDataSource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/PersistenceDao.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ServerInfo.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuditFilter.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/TasksResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/UsersResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/GlusterUserDetailsService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/UserAuthDao.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/DiscoveredServerService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitServerTask.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/ServerSyncTask.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/Task.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/AbstractStatsFactory.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/CpuStatsFactory.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/MemoryStatsFactory.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java delete mode 100644 src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/StatsFactory.java delete mode 100644 src/com.gluster.storage.management.gateway/src/log4j.properties delete mode 100644 src/com.gluster.storage.management.gateway/src/rebel.xml delete mode 100644 src/com.gluster.storage.management.gateway/src/spring/gluster-server-base.xml delete mode 100644 src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml create mode 100644 src/org.gluster.storage.management.client/.classpath create mode 100644 src/org.gluster.storage.management.client/.project create mode 100644 src/org.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs create mode 100644 src/org.gluster.storage.management.client/META-INF/MANIFEST.MF create mode 100644 src/org.gluster.storage.management.client/build.properties create mode 100644 src/org.gluster.storage.management.client/keystore/gmc-trusted.keystore create mode 100644 src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar create mode 100644 src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar create mode 100644 src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/AbstractClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/ClustersClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/DiscoveredServersClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/GlusterServersClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/KeysClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/TasksClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/UsersClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/VolumesClient.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/constants/ClientConstants.java create mode 100644 src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/utils/ClientUtil.java create mode 100644 src/org.gluster.storage.management.console.feature.webstart/.project create mode 100644 src/org.gluster.storage.management.console.feature.webstart/buckminster.cspex create mode 100644 src/org.gluster.storage.management.console.feature.webstart/build.properties create mode 100644 src/org.gluster.storage.management.console.feature.webstart/build/glustermc.ant create mode 100644 src/org.gluster.storage.management.console.feature.webstart/feature.xml create mode 100644 src/org.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp create mode 100644 src/org.gluster.storage.management.console.feature.webstart/rootfiles/splash.png create mode 100644 src/org.gluster.storage.management.console.feature/.project create mode 100644 src/org.gluster.storage.management.console.feature/build.properties create mode 100644 src/org.gluster.storage.management.console.feature/feature.xml create mode 100644 src/org.gluster.storage.management.console.help/.project create mode 100644 src/org.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs create mode 100644 src/org.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs create mode 100644 src/org.gluster.storage.management.console.help/META-INF/MANIFEST.MF create mode 100644 src/org.gluster.storage.management.console.help/build.properties create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/about_gmc.html create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/about_gmg.html create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/common_terms.html create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/gluster_fs.html create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/maintopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/subtopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/concepts/subtopic2.html create mode 100644 src/org.gluster.storage.management.console.help/html/css/Builder/style.css create mode 100644 src/org.gluster.storage.management.console.help/html/css/builder-gluster/style.css create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/ subtopic3.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/access_gmc_jws.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/alerts.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/change_password.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/check_req_client.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/check_req_gmg.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/cifs_service.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/configure_cifs.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/explore_gmc.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/gmc_install_overview.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/gmc_terminal_window.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/gmc_toolbar.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/gmg_install_overview.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/install_gmg.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/install_gmg_backend.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/maintopic (4).html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/maintopic - Copy (3).html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/maintopic - Copy (4).html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/maintopic - Copy.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/maintopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/manage_bricks.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/manage_cluster.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/manage_logs.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/manage_servers.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/manage_volumes.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/monitor_resources.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/resetting_pwd.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/security_keys.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/setting_alerts_prefs.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/setting_charts_prefs.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/setting_gluster_prefs.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/setting_preferences.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/setting_terminal_prefs.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/setting_the_gmc.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/subtopic (3) - Copy.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/subtopic (3).html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/subtopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/subtopic2 (2).html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/subtopic2 (3).html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/subtopic2.html create mode 100644 src/org.gluster.storage.management.console.help/html/gettingstarted/tasks.html create mode 100644 src/org.gluster.storage.management.console.help/html/help_home.html create mode 100644 src/org.gluster.storage.management.console.help/html/images/Delete-brick.png create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC-Preferences-alerts .jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC-Preferences-charts.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC-Preferences-gluster .jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_02.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_03.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_04.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_05.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_06.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_07.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_09.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Add_Brick.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Add_Brick_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Add_Server_Confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Create_Vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Discovered_Server_Add.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Display_log_criteria.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Brick_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Bricks.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Bricks_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Server.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Remove_Server_1.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_Select_FS_Type.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_create_cluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_login.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_multiple_vols.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_multiple_vols_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_register_cluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_removeBrick_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_select_cluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_server_add_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_1.0_vol_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_10.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Add_Brick.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Add_Brick_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Add_Brick_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Add_Server_Manual.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Add_brick.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Add_brick_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Alerts.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Bricks_Tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Change_Password.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Change_Password_Confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Charts.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Clear_task_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Cluster_Summary.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Cluster_Summary_tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Cluster_Summary_tab_new.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Create_Cluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Create_Vol_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Create_Volume.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Create_Volume_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Delete_Vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_Confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_multiple.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_multiple_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Delete_Vol_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Disk_tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Landing_Page.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Log_list.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Login_Change_Pwd.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Login_Window.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Migrate_Brick.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Migrate_Brick_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Preferences_alerts.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Preferences_charts.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Preferences_gluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Preferences_terminal.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Rebalance_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Refresh.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Register_Cluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Remove_Brick_Confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Remove_Brick_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Remove_Server_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Remove_server.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Remove_server_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Select_Cluster.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Select_Cluster_progess.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Server_Disk.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Server_Summ.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Server_Summary_tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Server_Tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Single_Vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Start_task_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Stop_Multiple_Vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Stop_Vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Stop_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Task_tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Terminal_window.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Toolbar.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Vol_List.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Vol_Options.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Vol_rebalance_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Volume_Options.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Volume_Summary.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Volume_Summary_tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Volume_logs.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Volume_properties.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_Volumes_tab.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_add_server_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_change_pwd.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_create_vol (2).jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_create_vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_download_log_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_landing_page.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_log_criteria.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_migrate_brick.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_migrate_brick_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_pause_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_pwd_change_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_rebalance_vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_remove_server_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_remove_volume_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_server_summary.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_setting_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_settings.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_start_vol_Multiple.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_start_vol_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_start_vol_success.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_stop_vol_Multiple.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_stop_vol_icon.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_terminal_Settings.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMC_terminal_toolbar.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GMG_Architecture.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GlusterFS_3.2_Architecture.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/GlusterFS_3.2_Architecture.png create mode 100644 src/org.gluster.storage.management.console.help/html/images/GlusterMC_Architecture.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/Migration.png create mode 100644 src/org.gluster.storage.management.console.help/html/images/Preferences-alerts .png create mode 100644 src/org.gluster.storage.management.console.help/html/images/Preferences-charts.png create mode 100644 src/org.gluster.storage.management.console.help/html/images/Preferences-gluster .png create mode 100644 src/org.gluster.storage.management.console.help/html/images/Running tasks & alerts.png create mode 100644 src/org.gluster.storage.management.console.help/html/images/Stop_Vol.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/Stop_Vol_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/Stop_Vol_multiple.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/Stop_Vol_multiple_confirm.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/discovered_servers.png create mode 100644 src/org.gluster.storage.management.console.help/html/images/java-web-start.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/java_web_start.jpg create mode 100644 src/org.gluster.storage.management.console.help/html/images/login-dialog.png create mode 100644 src/org.gluster.storage.management.console.help/html/reference/maintopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/reference/subtopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/reference/subtopic2.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/access_gmc_jws.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/add_brick.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/add_servers.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/configure_gmc.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/create_cluster.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/create_volume.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/delete_brick.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/delete_volume.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/deploy_gmc_dedicated_host.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/display_log.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/download_log.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/initialize_disk.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/logging.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/maintopic (3).html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/maintopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/migrate_brick.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/rebalance_vol.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/register_cluster.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/remove_brick.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/remove_server.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/select_cluster.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/start_vol.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/starting_gmc.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/stop_vol.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic2 (3).html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic2.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic3.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic4.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic5.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/subtopic6.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/tune_vol_opt.html create mode 100644 src/org.gluster.storage.management.console.help/html/tasks/volumes.html create mode 100644 src/org.gluster.storage.management.console.help/html/toc.html create mode 100644 src/org.gluster.storage.management.console.help/plugin.xml create mode 100644 src/org.gluster.storage.management.console.help/toc.xml create mode 100644 src/org.gluster.storage.management.console.help/tocconcepts.xml create mode 100644 src/org.gluster.storage.management.console.help/tocgettingstarted.xml create mode 100644 src/org.gluster.storage.management.console.help/tocreference.xml create mode 100644 src/org.gluster.storage.management.console.help/toctasks.xml create mode 100644 src/org.gluster.storage.management.console/.classpath create mode 100644 src/org.gluster.storage.management.console/.project create mode 100644 src/org.gluster.storage.management.console/.settings/org.eclipse.jdt.core.prefs create mode 100644 src/org.gluster.storage.management.console/META-INF/MANIFEST.MF create mode 100644 src/org.gluster.storage.management.console/build.properties create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/arrow-down.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/arrow-up.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/bricks.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/close_task.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/cluster.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/disk-available.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/disk-error.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/disk-initialisation.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/disk-inuse.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/disk-uninitialized.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/disk.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/gluster_icon.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/help.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/logs.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/offline-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/online-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/pause.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/question.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/running-task.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/servers.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/settings.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/start.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/status-offline.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/status-online.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/stop.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/task-completed.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/task-error.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/utilities-terminal.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/view-refresh.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/volume-create.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/volume-options.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/16x16/volumes.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/disk-initialisation.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/high-memory-usage.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/low-diskspace.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/migrate-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/offline-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/offline-server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/offline-volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/server-warning.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/system-search.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/utilities-terminal.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/22x22/volume-rebalance.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/add-brick-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/add-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/add-server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/clear-task-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/clear-task.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/commit-task-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/commit-task.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/create-volume-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/create-volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/disk.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/download-log.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/help.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/log-rotate.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/logs.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/migrate-brick-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/migrate-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/pause-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/pause.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/remove-brick-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/remove-brick.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/remove-server-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/remove-server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/remove-volume-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/remove-volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/reset-volume-option-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/reset-volume-option.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/servers.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/settings.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/start-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/start-volume-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/start-volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/start.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/stop-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/stop-volume-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/stop-volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/stop.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/utilities-terminal.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/view-refresh.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/volume-rebalance-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/volume-rebalance.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/32x32/volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/48x48/add-server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/48x48/create-volume.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/48x48/remove-brick-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/48x48/server.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/48x48/start-volume-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/48x48/stop-volume-disabled.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/8x8/offline.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/8x8/online.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/8x8/star.png create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/add_brick.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/add_volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/brick.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/bricks.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/cloud.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/create-volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk_available.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk_error.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/download_log.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/log.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/offline.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/offline_server.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/online.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/remove-server.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/running_task.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/start_volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_clear.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_commit.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_pause.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_paused.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_resume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_running.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_stop.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/volume.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/volume_option.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg create mode 100644 src/org.gluster.storage.management.console/icons/tango/scalable/volumes.svg create mode 100644 src/org.gluster.storage.management.console/images/gauge.png create mode 100644 src/org.gluster.storage.management.console/images/gauge_small.png create mode 100644 src/org.gluster.storage.management.console/images/gluster-about.png create mode 100644 src/org.gluster.storage.management.console/images/login-screen-with-text.psd create mode 100644 src/org.gluster.storage.management.console/images/login-screen.psd create mode 100644 src/org.gluster.storage.management.console/images/splash-dialog.bmp create mode 100644 src/org.gluster.storage.management.console/images/splash-screen.psd create mode 100644 src/org.gluster.storage.management.console/plugin.properties create mode 100644 src/org.gluster.storage.management.console/plugin.xml create mode 100644 src/org.gluster.storage.management.console/preferences.ini create mode 100644 src/org.gluster.storage.management.console/splash.bmp create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Activator.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/AlertsManager.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Application.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationActionBarAdvisor.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/BrickTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ConsoleConstants.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/DeviceTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/EntityGroupContentProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterDataModelManager.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterServerTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ICommandIds.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IEntityListener.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IImageKeys.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Perspective.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerDiskTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TableLabelProviderAdapter.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TasksTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeLogTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsContentProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeTableLabelProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractActionDelegate.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ActionConstants.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddBrickAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddServerAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ChangePasswordAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ClearTaskAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CommitTaskAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CreateVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DeleteVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/EditVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ExportSshKeysAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ForceStartVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ImportSshKeysAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateBrickAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PauseTaskAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PreferencesAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RebalanceVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RefreshDataAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveBrickAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveServerAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResumeTaskAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ServerAdditionAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StartVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopTaskAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopVolumeAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/SupportAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TerminalAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TestPopupMenuAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/VolumeLogRotateAction.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/BricksSelectionPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ChangePasswordDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumePage1.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumeWizard.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/GlusterSupportDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/InitDiskDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/LoginDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickPage1.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickWizard.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/SelectDisksDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ServerAdditionDialog.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/jobs/DataSyncJob.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/AlertsPreferencePage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/ChartsPreferencePage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/GlusterPreferencePage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceConstants.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceInitializer.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/GlusterToolbarManager.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/ToolbarManager.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartUtil.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartViewerComposite.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/EntityViewerFilter.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GUIHelper.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterChartPalette.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterLogger.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ImageUtil.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/TableViewerComparator.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/validators/StringRequiredValidator.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterAdapterFactory.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterSummaryView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServerView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServersView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DisksView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerDisksView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerLogsView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerSummaryView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersSummaryView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterViewsManager.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/TasksView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ViewsManager.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeBricksView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeLogsView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeOptionsView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeSummaryView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesSummaryView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesView.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractDisksPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/BricksPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DisksPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/GlusterServersPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerDisksPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerLogsPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServersPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/TasksPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeLogsPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeOptionsPage.java create mode 100644 src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumesPage.java create mode 100644 src/org.gluster.storage.management.console/src/test.xml create mode 100644 src/org.gluster.storage.management.core/.classpath create mode 100644 src/org.gluster.storage.management.core/.project create mode 100644 src/org.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs create mode 100644 src/org.gluster.storage.management.core/META-INF/MANIFEST.MF create mode 100644 src/org.gluster.storage.management.core/build.properties create mode 100644 src/org.gluster.storage.management.core/junit/core.junit.launch create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/AlertTest.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/BrickTest.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/ClusterTest.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/DiskTest.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/TestAll.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/DateUtilTest.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/FileUtilTest.java create mode 100644 src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/StringUtilTest.java create mode 100644 src/org.gluster.storage.management.core/junit/test/test.txt create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/CoreConstants.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/GlusterConstants.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/RESTConstants.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/ConnectionException.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterRuntimeException.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterValidationException.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Alert.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Brick.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Cluster.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ClusterListener.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ConnectionDetails.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/DefaultClusterListener.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Device.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Disk.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Entity.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/EntityGroup.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Event.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Filterable.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDataModel.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDummyModel.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterServer.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/InitDiskStatusResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/NetworkInterface.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Partition.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Response.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Server.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStats.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStatsRow.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/StatsMetadata.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Status.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskInfo.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskStatus.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/User.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Version.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Volume.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeLogMessage.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOption.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptionInfo.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptions.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/AbstractResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ClusterNameListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/FsTypeListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/LogMessageListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerNameListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/StringListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskIdResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskInfoListResponse.java create mode 100755 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/DateUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/FileUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/GlusterCoreUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/JavaUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/LRUCache.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5Crypt.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/NumberUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessResult.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/StringUtil.java create mode 100644 src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ValidationUtil.java create mode 100644 src/org.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch create mode 100644 src/org.gluster.storage.management.gateway.scripts/.project create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/format_device.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/gluster-volume-settings.init.d create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/common/Globals.py create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/common/Utils.py create mode 100644 src/org.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/grun.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py create mode 100755 src/org.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py create mode 100644 src/org.gluster.storage.management.gateway/.classpath create mode 100644 src/org.gluster.storage.management.gateway/.project create mode 100644 src/org.gluster.storage.management.gateway/.settings/.jsdtscope create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs create mode 100644 src/org.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar create mode 100644 src/org.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml create mode 100644 src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql create mode 100644 src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql create mode 100644 src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql create mode 100644 src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql create mode 100644 src/org.gluster.storage.management.gateway/WebContent/index.html create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/Globals.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/Protocol.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/Utils.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/grun.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py create mode 120000 src/org.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py create mode 100644 src/org.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore create mode 100644 src/org.gluster.storage.management.gateway/buckminster.cspex create mode 100644 src/org.gluster.storage.management.gateway/build/glusterserver.ant create mode 100644 src/org.gluster.storage.management.gateway/src/META-INF/persistence.xml create mode 100644 src/org.gluster.storage.management.gateway/src/log4j.properties create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ClusterInfo.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/GlusterDataSource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/PersistenceDao.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ServerInfo.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuditFilter.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/listeners/ShutdownListener.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/KeysResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/TasksResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/UsersResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/GlusterUserDetailsService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/UserAuthDao.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/AbstractGlusterInterface.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/ClusterService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/DiscoveredServerService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/Gluster323InterfaceService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterface.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterfaceService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterServerService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/VolumeService.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitServerTask.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitializeDiskTask.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/MigrateBrickTask.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/ServerSyncTask.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/Task.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/AbstractStatsFactory.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/CpuStatsFactory.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/DBUtil.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/MemoryStatsFactory.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/NetworkStatsFactory.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/PasswordManager.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/ServerUtil.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/SshUtil.java create mode 100644 src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/StatsFactory.java create mode 100644 src/org.gluster.storage.management.gateway/src/rebel.xml create mode 100644 src/org.gluster.storage.management.gateway/src/spring/gluster-server-base.xml create mode 100644 src/org.gluster.storage.management.gateway/src/spring/gluster-server-security.xml (limited to 'src') diff --git a/src/com.gluster.storage.management.client/.classpath b/src/com.gluster.storage.management.client/.classpath deleted file mode 100644 index d81daeeb..00000000 --- a/src/com.gluster.storage.management.client/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.client/.project b/src/com.gluster.storage.management.client/.project deleted file mode 100644 index 61a0ec41..00000000 --- a/src/com.gluster.storage.management.client/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - com.gluster.storage.management.client - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - com.instantiations.assist.eclipse.coverage.instrumentationBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - com.instantiations.assist.eclipse.coverage.codeCoverageNature - - diff --git a/src/com.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs b/src/com.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f8b5cc38..00000000 --- a/src/com.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Dec 29 15:47:13 IST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/com.gluster.storage.management.client/META-INF/MANIFEST.MF b/src/com.gluster.storage.management.client/META-INF/MANIFEST.MF deleted file mode 100644 index 7958d8cd..00000000 --- a/src/com.gluster.storage.management.client/META-INF/MANIFEST.MF +++ /dev/null @@ -1,17 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Gluster Storage Platform Client -Bundle-SymbolicName: com.gluster.storage.management.client -Bundle-Version: 1.0.0 -Bundle-Vendor: GLUSTER -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: com.gluster.storage.management.core;bundle-version="1.0.0", - org.eclipse.equinox.common;bundle-version="3.6.0" -Export-Package: com.gluster.storage.management.client, - com.gluster.storage.management.client.constants -Bundle-ClassPath: ., - lib/jersey-1.5/jersey-client-1.5.jar, - lib/jersey-1.5/jersey-core-1.5.jar, - lib/jersey-1.5/jersey-multipart-1.5.jar, - keystore/ -Import-Package: org.eclipse.jface.preference diff --git a/src/com.gluster.storage.management.client/build.properties b/src/com.gluster.storage.management.client/build.properties deleted file mode 100644 index b9d04dbf..00000000 --- a/src/com.gluster.storage.management.client/build.properties +++ /dev/null @@ -1,14 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = .,\ - META-INF/,\ - lib/,\ - keystore/,\ - lib/jersey-1.5/jersey-multipart-1.5.jar -src.includes = lib/,\ - keystore/,\ - build.properties,\ - .project,\ - .classpath,\ - .settings/,\ - META-INF/ diff --git a/src/com.gluster.storage.management.client/keystore/gmc-trusted.keystore b/src/com.gluster.storage.management.client/keystore/gmc-trusted.keystore deleted file mode 100644 index 5517b6e5..00000000 Binary files a/src/com.gluster.storage.management.client/keystore/gmc-trusted.keystore and /dev/null differ diff --git a/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar b/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar deleted file mode 100644 index 62f790fa..00000000 Binary files a/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar b/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar deleted file mode 100644 index 92b38466..00000000 Binary files a/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar b/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar deleted file mode 100644 index 1c134f05..00000000 Binary files a/src/com.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java deleted file mode 100644 index a77e2a31..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/AbstractClient.java +++ /dev/null @@ -1,428 +0,0 @@ -package com.gluster.storage.management.client; - -import static com.gluster.storage.management.client.constants.ClientConstants.ALGORITHM_SUNX509; -import static com.gluster.storage.management.client.constants.ClientConstants.KEYSTORE_TYPE_JKS; -import static com.gluster.storage.management.client.constants.ClientConstants.PROTOCOL_TLS; -import static com.gluster.storage.management.client.constants.ClientConstants.TRUSTED_KEYSTORE; -import static com.gluster.storage.management.client.constants.ClientConstants.TRUSTED_KEYSTORE_ACCESS; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.ConnectException; -import java.net.URI; -import java.security.KeyStore; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManagerFactory; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; - -import com.gluster.storage.management.client.utils.ClientUtil; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.WebResource.Builder; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.representation.Form; -import com.sun.jersey.client.urlconnection.HTTPSProperties; -import com.sun.jersey.core.util.MultivaluedMapImpl; -import com.sun.jersey.multipart.FormDataMultiPart; - -public abstract class AbstractClient { - private static final String HTTP_HEADER_AUTH = "Authorization"; - protected static final MultivaluedMap NO_PARAMS = new MultivaluedMapImpl(); - protected static String clusterName; - protected static String securityToken; - protected WebResource resource; - private String authHeader; - private Client client; - - /** - * This constructor will work only after the data model manager has been initialized. - */ - public AbstractClient() { - this(securityToken, clusterName); - } - - /** - * This constructor will work only after the data model manager has been initialized. - */ - public AbstractClient(String clusterName) { - this(securityToken, clusterName); - } - - public AbstractClient(String securityToken, String clusterName) { - AbstractClient.clusterName = clusterName; - setSecurityToken(securityToken); - - createClient(); - - // this must be after setting clusterName as sub-classes may refer to cluster name in the getResourcePath method - resource = client.resource(ClientUtil.getServerBaseURI()).path(getResourcePath()); - } - - private void createClient() { - SSLContext context = initializeSSLContext(); - DefaultClientConfig config = createClientConfig(context); - client = Client.create(config); - } - - private DefaultClientConfig createClientConfig(SSLContext context) { - DefaultClientConfig config = new DefaultClientConfig(); - config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(createHostnameVerifier(), context)); - return config; - } - - private HostnameVerifier createHostnameVerifier() { - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String arg0, SSLSession arg1) { - return true; - } - }; - return hostnameVerifier; - } - - private SSLContext initializeSSLContext() { - SSLContext context = null; - try { - context = SSLContext.getInstance(PROTOCOL_TLS); - - KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE_JKS); - keyStore.load(loadResource(TRUSTED_KEYSTORE), TRUSTED_KEYSTORE_ACCESS.toCharArray()); - - KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(ALGORITHM_SUNX509); - keyManagerFactory.init(keyStore, TRUSTED_KEYSTORE_ACCESS.toCharArray()); - - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(ALGORITHM_SUNX509); - trustManagerFactory.init(keyStore); - - context.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); - } catch (Exception e) { - throw new GlusterRuntimeException( - "Couldn't initialize SSL Context with Gluster Management Gateway! Error: " + e, e); - } - return context; - } - - private InputStream loadResource(String resourcePath) { - return this.getClass().getClassLoader().getResourceAsStream(resourcePath); - } - - /** - * Fetches the given resource by dispatching a GET request - * - * @param res - * Resource to be fetched - * @param queryParams - * Query parameters to be sent for the GET request - * @param responseClass - * Expected class of the response - * @return Object of responseClass received as a result of the GET request - */ - private T fetchResource(WebResource res, MultivaluedMap queryParams, Class responseClass) { - try { - return res.queryParams(queryParams).header(HTTP_HEADER_AUTH, authHeader).accept(MediaType.APPLICATION_XML) - .get(responseClass); - } catch (Exception e1) { - throw createGlusterException(e1); - } - } - - private GlusterRuntimeException createGlusterException(Exception e) { - if (e instanceof GlusterRuntimeException) { - return (GlusterRuntimeException) e; - } - - if (e instanceof UniformInterfaceException) { - UniformInterfaceException uie = (UniformInterfaceException) e; - if ((uie.getResponse().getStatus() == Response.Status.UNAUTHORIZED.getStatusCode())) { - // authentication failed. clear security token. - setSecurityToken(null); - return new GlusterRuntimeException("Invalid credentials!"); - } else { - return new GlusterRuntimeException("[" + uie.getResponse().getStatus() + "][" - + uie.getResponse().getEntity(String.class) + "]"); - } - } else { - Throwable cause = e.getCause(); - if (cause != null && cause instanceof ConnectException) { - return new GlusterRuntimeException("Couldn't connect to Gluster Management Gateway!"); - } - - return new GlusterRuntimeException("Exception in REST communication! [" + e.getMessage() + "]", e); - } - } - - protected void downloadResource(WebResource res, String filePath) { - ClientResponse response = null; - try { - response = res.header(HTTP_HEADER_AUTH, authHeader).accept(MediaType.APPLICATION_OCTET_STREAM) - .get(ClientResponse.class); - checkResponseStatus(response); - } catch (Exception e1) { - throw createGlusterException(e1); - } - - try { - if (!response.hasEntity()) { - throw new GlusterRuntimeException("No entity in response!"); - } - - InputStream inputStream = response.getEntityInputStream(); - FileOutputStream outputStream = new FileOutputStream(filePath); - - int c; - while ((c = inputStream.read()) != -1) { - outputStream.write(c); - } - inputStream.close(); - outputStream.close(); - } catch (IOException e) { - throw new GlusterRuntimeException("Error while downloading resource [" + res.getURI().getPath() + "]", e); - } - } - - public void uploadResource(WebResource res, FormDataMultiPart form) { - try { - res.header(HTTP_HEADER_AUTH, authHeader).type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, form); - } catch (Exception e) { - throw createGlusterException(e); - } - } - - /** - * Fetches the default resource (the one returned by {@link AbstractClient#getResourcePath()}) by dispatching a GET - * request on the resource - * - * @param queryParams - * Query parameters to be sent for the GET request - * @param responseClass - * Expected class of the response - * @return Object of responseClass received as a result of the GET request - */ - protected T fetchResource(MultivaluedMap queryParams, Class responseClass) { - return fetchResource(resource, queryParams, responseClass); - } - - /** - * Fetches the default resource (the one returned by {@link AbstractClient#getResourcePath()}) by dispatching a GET - * request on the resource - * - * @param responseClass - * Expected class of the response - * @return Object of responseClass received as a result of the GET request - */ - protected T fetchResource(Class responseClass) { - return fetchResource(resource, NO_PARAMS, responseClass); - } - - /** - * Fetches the resource whose name is arrived at by appending the "subResourceName" parameter to the default - * resource (the one returned by {@link AbstractClient#getResourcePath()}) - * - * @param subResourceName - * Name of the sub-resource - * @param responseClass - * Expected class of the response - * @return Object of responseClass received as a result of the GET request on the sub-resource - */ - protected T fetchSubResource(String subResourceName, Class responseClass) { - return fetchResource(resource.path(subResourceName), NO_PARAMS, responseClass); - } - - protected void downloadSubResource(String subResourceName, String filePath) { - downloadResource(resource.path(subResourceName), filePath); - } - - /** - * Fetches the resource whose name is arrived at by appending the "subResourceName" parameter to the default - * resource (the one returned by {@link AbstractClient#getResourcePath()}) - * - * @param subResourceName - * Name of the sub-resource - * @param queryParams - * Query parameters to be sent for the GET request - * @param responseClass - * Expected class of the response - * @return Object of responseClass received as a result of the GET request on the sub-resource - */ - protected T fetchSubResource(String subResourceName, MultivaluedMap queryParams, - Class responseClass) { - return fetchResource(resource.path(subResourceName), queryParams, responseClass); - } - - private ClientResponse postRequest(WebResource resource, Form form) { - try { - ClientResponse response = prepareFormRequestBuilder(resource).post(ClientResponse.class, form); - checkResponseStatus(response); - return response; - } catch (UniformInterfaceException e) { - throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); - } - } - - /** - * Submits given object to the resource and returns the object received as response - * - * @param responseClass - * Class of the object expected as response - * @param requestObject - * the Object to be submitted - * @return Object of given class received as response - */ - protected T postObject(Class responseClass, Object requestObject) { - return resource.type(MediaType.APPLICATION_XML).header(HTTP_HEADER_AUTH, authHeader) - .accept(MediaType.APPLICATION_XML).post(responseClass, requestObject); - } - - /** - * Submits given Form using POST method to the resource and returns the object received as response - * - * @param form - * Form to be submitted - */ - protected URI postRequest(Form form) { - return postRequest(resource, form).getLocation(); - } - - /** - * Submits given Form using POST method to the given sub-resource and returns the object received as response - * - * @param subResourceName - * Name of the sub-resource to which the request is to be posted - * @param form - * Form to be submitted - */ - protected void postRequest(String subResourceName, Form form) { - postRequest(resource.path(subResourceName), form); - } - - private ClientResponse putRequest(WebResource resource, Form form) { - try { - ClientResponse response = prepareFormRequestBuilder(resource).put(ClientResponse.class, form); - checkResponseStatus(response); - return response; - } catch (Exception e) { - throw createGlusterException(e); - } - } - - private void checkResponseStatus(ClientResponse response) { - if ((response.getStatus() == Response.Status.UNAUTHORIZED.getStatusCode())) { - // authentication failed. clear security token. - setSecurityToken(null); - throw new GlusterRuntimeException("Invalid credentials!"); - } - if (response.getStatus() >= 300) { - throw new GlusterRuntimeException(response.getEntity(String.class)); - } - } - - public Builder prepareFormRequestBuilder(WebResource resource) { - return resource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).header(HTTP_HEADER_AUTH, authHeader) - .accept(MediaType.APPLICATION_XML); - } - - /** - * Submits given Form using PUT method to the given sub-resource and returns the object received as response - * - * @param subResourceName - * Name of the sub-resource to which the request is to be posted - * @param form - * Form to be submitted - */ - protected void putRequest(String subResourceName, Form form) { - putRequest(resource.path(subResourceName), form); - } - - protected URI putRequestURI(String subResourceName, Form form) { - ClientResponse response = putRequest(resource.path(subResourceName), form); - return response.getLocation(); - } - - /** - * Submits given Form using PUT method to the given sub-resource and returns the object received as response - * - * @param form - * Form to be submitted - */ - protected void putRequest(Form form) { - putRequest(resource, form); - } - - /** - * Submits given Form using PUT method to the given sub-resource and returns the object received as response - * - * @param subResourceName - * Name of the sub-resource to which the request is to be posted - */ - protected void putRequest(String subResourceName) { - try { - prepareFormRequestBuilder(resource.path(subResourceName)).put(); - } catch (UniformInterfaceException e) { - throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); - } - } - - private void deleteResource(WebResource resource, MultivaluedMap queryParams) { - try { - resource.queryParams(queryParams).header(HTTP_HEADER_AUTH, authHeader).delete(); - } catch (UniformInterfaceException e) { - throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); - } - } - - protected void deleteResource(MultivaluedMap queryParams) { - deleteResource(resource, queryParams); - } - - protected void deleteSubResource(String subResourceName, MultivaluedMap queryParams) { - deleteResource(resource.path(subResourceName), queryParams); - } - - protected void deleteSubResource(String subResourceName) { - try { - resource.path(subResourceName).header(HTTP_HEADER_AUTH, authHeader).delete(); - } catch (UniformInterfaceException e) { - throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); - } - } - - public abstract String getResourcePath(); - - /** - * @return the securityToken - */ - protected String getSecurityToken() { - return securityToken; - } - - /** - * @param securityToken - * the securityToken to set - */ - protected void setSecurityToken(String securityToken) { - AbstractClient.securityToken = securityToken; - authHeader = "Basic " + securityToken; - } - - /** - * @param uri - * The URI to be fetched using GET API - * @param responseClass - * Expected type of response object - * @return Object of the given class - */ - protected T fetchResource(URI uri, Class responseClass) { - return fetchResource(client.resource(uri), NO_PARAMS, responseClass); - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java deleted file mode 100644 index d6bf962a..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/ClustersClient.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.client; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CLUSTER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; - -import java.util.List; - -import com.gluster.storage.management.core.response.ClusterNameListResponse; -import com.sun.jersey.api.representation.Form; - -/** - * - */ -public class ClustersClient extends AbstractClient { - public ClustersClient() { - super(); - } - - public ClustersClient(String securityToken) { - super(); - setSecurityToken(securityToken); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.client.AbstractClient#getResourcePath() - */ - @Override - public String getResourcePath() { - return RESOURCE_PATH_CLUSTERS; - } - - public List getClusterNames() { - return ((ClusterNameListResponse)fetchResource(ClusterNameListResponse.class)).getClusterNames(); - } - - public void createCluster(String clusterName) { - Form form = new Form(); - form.add(FORM_PARAM_CLUSTER_NAME, clusterName); - - postRequest(form); - } - - public void registerCluster(String clusterName, String knownServer) { - Form form = new Form(); - form.add(FORM_PARAM_CLUSTER_NAME, clusterName); - form.add(FORM_PARAM_SERVER_NAME, knownServer); - putRequest(form); - } - - public void deleteCluster(String clusterName) { - deleteSubResource(clusterName); - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java deleted file mode 100644 index 6b7af5b0..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/DiscoveredServersClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.client; - -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_DISCOVERED_SERVERS; - -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.response.ServerListResponse; -import com.gluster.storage.management.core.response.ServerNameListResponse; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class DiscoveredServersClient extends AbstractClient { - - public DiscoveredServersClient(String clusterName) { - super(clusterName); - } - - public DiscoveredServersClient(String securityToken, String clusterName) { - super(securityToken, clusterName); - } - - @Override - public String getResourcePath() { - return RESOURCE_PATH_DISCOVERED_SERVERS; - } - - private T getDiscoveredServers(Boolean details, Class responseClass) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.putSingle(QUERY_PARAM_DETAILS, details.toString()); - return fetchResource(queryParams, responseClass); - } - - public List getDiscoveredServerNames() { - return ((ServerNameListResponse) getDiscoveredServers(Boolean.FALSE, ServerNameListResponse.class)) - .getServerNames(); - } - - public List getDiscoveredServerDetails() { - List servers = ((ServerListResponse) getDiscoveredServers(Boolean.TRUE, ServerListResponse.class)) - .getServers(); - - for (Server server : servers) { - GlusterCoreUtil.updateServerNameOnDevices(server); - } - return servers; - } - - public Server getServer(String serverName) { - return (Server) fetchSubResource(serverName, Server.class); - } - - public static void main(String[] args) { - UsersClient usersClient = new UsersClient(); - try { - usersClient.authenticate("gluster", "gluster"); - DiscoveredServersClient serverResource = new DiscoveredServersClient(usersClient.getSecurityToken(), "new"); - List discoveredServerNames = serverResource.getDiscoveredServerNames(); - System.out.println(discoveredServerNames); - List discoveredServers = serverResource.getDiscoveredServerDetails(); - System.out.println(discoveredServers); - } catch(Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java deleted file mode 100644 index 5fefedc0..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterServersClient.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.client; - -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_SERVERS; - -import java.net.URI; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.response.FsTypeListResponse; -import com.gluster.storage.management.core.response.GlusterServerListResponse; -import com.gluster.storage.management.core.response.StringListResponse; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.sun.jersey.api.representation.Form; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class GlusterServersClient extends AbstractClient { - - public GlusterServersClient() { - super(); - } - - public GlusterServersClient(String clusterName) { - super(clusterName); - } - - public GlusterServersClient(String securityToken, String clusterName) { - super(securityToken, clusterName); - } - - @Override - public String getResourcePath() { - return RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_SERVERS; - } - - public List getServers() { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.putSingle(QUERY_PARAM_DETAILS, "true"); - List servers = ((GlusterServerListResponse) fetchResource(queryParams, GlusterServerListResponse.class)).getServers(); - for(GlusterServer server : servers) { - GlusterCoreUtil.updateServerNameOnDevices(server); - } - return servers; - } - - public GlusterServer getGlusterServer(String serverName) { - GlusterServer server = (GlusterServer) fetchSubResource(serverName, GlusterServer.class); - GlusterCoreUtil.updateServerNameOnDevices(server); - return server; - } - - public URI addServer(String serverName) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_SERVER_NAME, serverName); - return postRequest(form); - } - - public List getFSTypes(String serverName) { - FsTypeListResponse fsTypeListResponse = ((FsTypeListResponse) fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_FSTYPES, - FsTypeListResponse.class)); - return fsTypeListResponse.getFsTypes(); - } - - public URI initializeDisk(String serverName, String diskName, String fsType, String mountPoint) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_FSTYPE, fsType); - form.add(RESTConstants.FORM_PARAM_MOUNTPOINT, fsType); - return putRequestURI(serverName + "/" + RESTConstants.RESOURCE_DISKS + "/" + diskName, form); - } - - public void removeServer(String serverName) { - deleteSubResource(serverName); - } - - public ServerStats getCpuStats(String serverName, String period) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_CPU); - queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); - return fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); - } - - public ServerStats getMemoryStats(String serverName, String period) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_MEMORY); - queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); - return fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); - } - - public ServerStats getNetworkStats(String serverName, String networkInterface, String period) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_NETWORK); - queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); - queryParams.add(RESTConstants.QUERY_PARAM_INTERFACE, networkInterface); - return fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); - } - - public ServerStats getAggregatedCpuStats(String period) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_CPU); - queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); - return fetchSubResource(RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); - } - - public ServerStats getAggregatedNetworkStats(String period) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_NETWORK); - queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); - return fetchSubResource(RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); - } - - public GlusterServer getGlusterServer(URI uri) { - GlusterServer server = fetchResource(uri, GlusterServer.class); - GlusterCoreUtil.updateServerNameOnDevices(server); - return server; - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java deleted file mode 100644 index 51fda466..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/KeysClient.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * KeysClient.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.client; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import javax.ws.rs.core.MediaType; - -import com.gluster.storage.management.core.constants.RESTConstants; -import com.sun.jersey.multipart.FormDataMultiPart; - -public class KeysClient extends AbstractClient { - - public KeysClient() { - super(); - } - - @Override - public String getResourcePath() { - return RESTConstants.RESOURCE_KEYS; - } - - public void exportSshKeys(String filePath) { - downloadResource(resource, filePath); - } - - public void importSshKeys(String keysFile) { - FormDataMultiPart form = new FormDataMultiPart(); - try { - form.field("file", new FileInputStream(keysFile), MediaType.TEXT_PLAIN_TYPE); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - uploadResource(resource, form); - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/TasksClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/TasksClient.java deleted file mode 100644 index 46077371..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/TasksClient.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * tasksClient.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.client; - -import java.net.URI; -import java.util.List; - -import javax.ws.rs.core.MultivaluedMap; - -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.response.TaskInfoListResponse; -import com.sun.jersey.api.representation.Form; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class TasksClient extends AbstractClient { - - public TasksClient() { - super(); - } - - public TasksClient(String clusterName) { - super(clusterName); - } - - public TasksClient(String securityToken,String clusterName) { - super(securityToken, clusterName); - } - - @Override - public String getResourcePath() { - return RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESTConstants.RESOURCE_TASKS + "/"; - } - - public List getAllTasks() { // TaskListResponse get only the list of taskInfo not list of Tasks - return ((TaskInfoListResponse) fetchResource(TaskInfoListResponse.class)).getTaskList(); - } - - // see startMigration @ VolumesClient, etc - public void pauseTask(String taskId) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_PAUSE); - - putRequest( taskId, form); - } - - public void resumeTask(String taskId) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_RESUME); - - putRequest(taskId, form); - } - - public void stopTask(String taskId) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_STOP); - - putRequest(taskId, form); - } - - public void commitTask(String taskId) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_COMMIT); - - putRequest(taskId, form); - } - - public void getTaskStatus(String taskId) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_STATUS); - - putRequest(taskId, form); - } - - public void deleteTask(String taskId) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_DELETE); - - deleteSubResource(taskId, queryParams); - } - - public TaskInfo getTaskInfo(URI uri) { - return ((TaskInfo) fetchResource(uri, TaskInfo.class)); - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java deleted file mode 100644 index 4e89e994..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/UsersClient.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.client; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_NEW_PASSWORD; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OLD_PASSWORD; - -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Status; -import com.sun.jersey.api.representation.Form; -import com.sun.jersey.core.util.Base64; - - -public class UsersClient extends AbstractClient { - private String generateSecurityToken(String user, String password) { - return new String(Base64.encode(user + ":" + password)); - } - - public UsersClient() { - super(); - } - - public void authenticate(String user, String password) { - setSecurityToken(generateSecurityToken(user, password)); - fetchSubResource(user, Status.class); - } - - public void changePassword(String user, String oldPassword, String newPassword) { - String oldSecurityToken = getSecurityToken(); - String newSecurityToken = generateSecurityToken(user, oldPassword); - if(!oldSecurityToken.equals(newSecurityToken)) { - throw new GlusterRuntimeException("Invalid old password!"); - } - - Form form = new Form(); - form.add(FORM_PARAM_OLD_PASSWORD, oldPassword); - form.add(FORM_PARAM_NEW_PASSWORD, newPassword); - putRequest(user, form); - - // password changed. set the new security token - setSecurityToken(generateSecurityToken(user, newPassword)); - //authenticate(user, newPassword); - } - - public static void main(String[] args) { - UsersClient authClient = new UsersClient(); - - // authenticate user - authClient.authenticate("gluster", "gluster"); - - // change password to gluster1 - authClient.changePassword("gluster", "gluster", "gluster1"); - - // change it back to gluster - authClient.changePassword("gluster", "gluster1", "gluster"); - - System.out.println("success"); - } - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.client.AbstractClient#getResourceName() - */ - @Override - public String getResourcePath() { - return RESTConstants.RESOURCE_USERS; - } - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.client.AbstractClient#getSecurityToken() - */ - @Override - public String getSecurityToken() { - return super.getSecurityToken(); - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java deleted file mode 100644 index ec8d0212..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java +++ /dev/null @@ -1,281 +0,0 @@ -/** - * VolumesClient.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.client; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_ACCESS_PROTOCOLS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_USERS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_REPLICA_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_STRIPE_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TRANSPORT_TYPE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_OPTIONS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_TYPE; - -import java.net.URI; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import javax.ws.rs.core.MultivaluedMap; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeLogMessage; -import com.gluster.storage.management.core.model.VolumeOptionInfo; -import com.gluster.storage.management.core.response.LogMessageListResponse; -import com.gluster.storage.management.core.response.VolumeListResponse; -import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; -import com.gluster.storage.management.core.utils.DateUtil; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.StringUtil; -import com.sun.jersey.api.representation.Form; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -public class VolumesClient extends AbstractClient { - public VolumesClient() { - super(); - } - - public VolumesClient(String clusterName) { - super(clusterName); - } - - public VolumesClient(String securityToken, String clusterName) { - super(securityToken, clusterName); - } - - @Override - public String getResourcePath() { - return RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESTConstants.RESOURCE_VOLUMES; - } - - public void createVolume(Volume volume) { - Form form = new Form(); - form.add(FORM_PARAM_VOLUME_NAME, volume.getName()); - form.add(FORM_PARAM_VOLUME_TYPE, volume.getVolumeType().toString()); - form.add(FORM_PARAM_TRANSPORT_TYPE, volume.getTransportType().toString()); - form.add(FORM_PARAM_REPLICA_COUNT, volume.getReplicaCount()); - form.add(FORM_PARAM_STRIPE_COUNT, volume.getStripeCount()); - form.add(FORM_PARAM_BRICKS, StringUtil.collectionToString(volume.getBricks(), ",")); - form.add(FORM_PARAM_ACCESS_PROTOCOLS, StringUtil.collectionToString(volume.getNASProtocols(), ",")); - form.add(FORM_PARAM_VOLUME_OPTIONS, StringUtil.collectionToString(volume.getOptions().getOptions(), ",")); - if (volume.isCifsEnable()) { - form.add(FORM_PARAM_CIFS_USERS, StringUtil.collectionToString(volume.getCifsUsers(), ",")); - } - postRequest(form); - } - - private void performOperation(String volumeName, String operation, Boolean force) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, operation); - form.add(RESTConstants.FORM_PARAM_FORCE, force); - - putRequest(volumeName, form); - } - - public void startVolume(String volumeName, Boolean forceStart) { - performOperation(volumeName, RESTConstants.TASK_START, forceStart); - } - - public void stopVolume(String volumeName, Boolean forceStop) { - performOperation(volumeName, RESTConstants.TASK_STOP, forceStop); - } - - public void setCifsConfig(String volumeName, Boolean isCifsEnabled, String cifsUsers) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.FORM_PARAM_CIFS_CONFIG); - form.add(RESTConstants.FORM_PARAM_CIFS_ENABLE, isCifsEnabled); - form.add(RESTConstants.FORM_PARAM_CIFS_USERS, cifsUsers); - putRequest(volumeName, form); - } - - public boolean volumeExists(String volumeName) { - try { - // TODO: instead of fetching full volume name, fetch list of volumes and check if - // it contains our volume name - getVolume(volumeName); - return true; - } catch(Exception e) { - return false; - } - } - - public void setVolumeOption(String volume, String key, String value) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPTION_KEY, key); - form.add(RESTConstants.FORM_PARAM_OPTION_VALUE, value); - postRequest(volume + "/" + RESTConstants.RESOURCE_OPTIONS, form); - } - - public void resetVolumeOptions(String volume) { - putRequest(volume + "/" + RESTConstants.RESOURCE_OPTIONS); - } - - public List getAllVolumes() { - return ((VolumeListResponse) fetchResource(VolumeListResponse.class)).getVolumes(); - } - - public Volume getVolume(String volumeName) { - return (Volume)fetchSubResource(volumeName, Volume.class); - } - - public void deleteVolume(String volumeName, boolean deleteOption) { - MultivaluedMap queryParams = prepareDeleteVolumeQueryParams(deleteOption); - deleteSubResource(volumeName, queryParams); - } - - public List getVolumeOptionsInfo() { - return ((VolumeOptionInfoListResponse) fetchSubResource(RESTConstants.RESOURCE_DEFAULT_OPTIONS, - VolumeOptionInfoListResponse.class)).getOptions(); - } - - public void addBricks(String volumeName, Set brickList) { - String bricks = StringUtil.collectionToString(brickList, ","); - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_BRICKS, bricks); - postRequest(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, form); - } - - /** - * Fetches volume logs for the given volume based on given filter criteria - * - * @param volumeName - * Name of volume whose logs are to be fetched - * @param brickName - * Name of the brick whose logs are to be fetched. Pass ALL to fetch log messages from all bricks of the - * volume. - * @param severity - * Log severity {@link GlusterConstants#VOLUME_LOG_LEVELS_ARR}. Pass ALL to fetch log messages of all - * severity levels. - * @param fromTimestamp - * From timestamp. Pass null if this filter is not required. - * @param toTimestamp - * To timestamp. Pass null if this filter is not required. - * @param messageCount - * Number of most recent log messages to be fetched (from each disk) - * @return Log Message List response received from the Gluster Management Server. - */ - public List getLogs(String volumeName, String brickName, String severity, Date fromTimestamp, - Date toTimestamp, int messageCount) { - MultivaluedMap queryParams = prepareGetLogQueryParams(brickName, severity, fromTimestamp, - toTimestamp, messageCount); - - return ((LogMessageListResponse) fetchSubResource(volumeName + "/" + RESTConstants.RESOURCE_LOGS, - queryParams, LogMessageListResponse.class)).getLogMessages(); - } - - public void downloadLogs(String volumeName, String filePath) { - downloadSubResource(volumeName + "/" + RESTConstants.RESOURCE_LOGS + "/" + RESTConstants.RESOURCE_DOWNLOAD, filePath); - } - - public void removeBricks(String volumeName, Set BrickList, boolean deleteOption) { - String bricks = StringUtil.collectionToString(GlusterCoreUtil.getQualifiedBrickList(BrickList), ","); - MultivaluedMap queryParams = prepareRemoveBrickQueryParams(volumeName, bricks, deleteOption); - deleteSubResource(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, queryParams); - } - - private MultivaluedMap prepareRemoveBrickQueryParams(String volumeName, String bricks, - boolean deleteOption) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_VOLUME_NAME, volumeName); - queryParams.add(RESTConstants.QUERY_PARAM_BRICKS, bricks); - queryParams.add(RESTConstants.QUERY_PARAM_DELETE_OPTION, "" + deleteOption); - return queryParams; - } - - private MultivaluedMap prepareDeleteVolumeQueryParams(boolean deleteOption) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_DELETE_OPTION, "" + deleteOption); - return queryParams; - } - - private MultivaluedMap prepareGetLogQueryParams(String brickName, String severity, - Date fromTimestamp, Date toTimestamp, int messageCount) { - MultivaluedMap queryParams = new MultivaluedMapImpl(); - queryParams.add(RESTConstants.QUERY_PARAM_LINE_COUNT, "" + messageCount); - if (!brickName.equals(CoreConstants.ALL)) { - queryParams.add(RESTConstants.QUERY_PARAM_BRICK_NAME, brickName); - } - - if (!severity.equals(CoreConstants.ALL)) { - queryParams.add(RESTConstants.QUERY_PARAM_LOG_SEVERITY, severity); - } - - if (fromTimestamp != null) { - queryParams.add(RESTConstants.QUERY_PARAM_FROM_TIMESTAMP, - DateUtil.dateToString(fromTimestamp, CoreConstants.DATE_WITH_TIME_FORMAT)); - } - - if (toTimestamp != null) { - queryParams.add(RESTConstants.QUERY_PARAM_TO_TIMESTAMP, - DateUtil.dateToString(toTimestamp, CoreConstants.DATE_WITH_TIME_FORMAT)); - } - return queryParams; - } - - public URI startMigration(String volumeName, String brickFrom, String brickTo, Boolean autoCommit) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_SOURCE, brickFrom); - form.add(RESTConstants.FORM_PARAM_TARGET, brickTo); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_START); - form.add(RESTConstants.FORM_PARAM_AUTO_COMMIT, autoCommit); - return putRequestURI(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, form); - } - - public URI rebalanceStart(String volumeName, Boolean fixLayout, Boolean migrateData, Boolean forcedDataMigrate) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_REBALANCE_START); - form.add(RESTConstants.FORM_PARAM_FIX_LAYOUT, fixLayout); - form.add(RESTConstants.FORM_PARAM_MIGRATE_DATA, migrateData); - form.add(RESTConstants.FORM_PARAM_FORCED_DATA_MIGRATE, forcedDataMigrate); - return putRequestURI(volumeName, form); - } - - public void rebalanceStop(String volumeName) { - Form form = new Form(); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_REBALANCE_STOP); - putRequest(volumeName, form); - } - - public void volumeLogRotate(String volumeName, List brickList) { - Form form = new Form(); - String bricks = StringUtil.collectionToString(brickList, ","); - form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_LOG_ROTATE); - form.add(FORM_PARAM_BRICKS, bricks); - putRequest(volumeName, form); - } - - public static void main(String[] args) { - UsersClient usersClient = new UsersClient(); - try { - usersClient.authenticate("gluster", "gluster"); - VolumesClient client = new VolumesClient(usersClient.getSecurityToken()); - System.out.println(client.getAllVolumes()); -// client.downloadLogs("vol1", "/tmp/temp1.tar.gz"); - } catch(Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java deleted file mode 100644 index e253dfa5..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/constants/ClientConstants.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * ClientConstants.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.client.constants; - -/** - * - */ -public class ClientConstants { - public static final String SYS_PROP_SERVER_URL = "gluster.server.url"; - public static final String DEFAULT_SERVER_URL = "https://localhost:8443/glustermg/linux.gtk.x86_64"; - public static final String CONTEXT_ROOT = "glustermg"; - public static final String REST_API_VERSION = "1.0.0"; - - // SSL related - public static final String TRUSTED_KEYSTORE = "gmc-trusted.keystore"; - public static final String TRUSTED_KEYSTORE_ACCESS = "gluster"; - public static final String PROTOCOL_TLS = "TLS"; - public static final String ALGORITHM_SUNX509 = "SunX509"; - public static final String KEYSTORE_TYPE_JKS = "JKS"; -} - diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/utils/ClientUtil.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/utils/ClientUtil.java deleted file mode 100644 index 3f87fd27..00000000 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/utils/ClientUtil.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gluster.storage.management.client.utils; - -import java.net.URI; - -import javax.ws.rs.core.UriBuilder; - -import com.gluster.storage.management.client.constants.ClientConstants; - -public class ClientUtil { - - public static URI getServerBaseURI() { - return UriBuilder.fromUri(getBaseURL()).path(ClientConstants.REST_API_VERSION).build(); - } - - private static String getBaseURL() { - // remove the platform path (e.g. /linux.gtk.x86_64) from the URL - return System.getProperty(ClientConstants.SYS_PROP_SERVER_URL, ClientConstants.DEFAULT_SERVER_URL) - .replaceAll(ClientConstants.CONTEXT_ROOT + "\\/.*", ClientConstants.CONTEXT_ROOT + "\\/"); - } -} diff --git a/src/com.gluster.storage.management.console.feature.webstart/.project b/src/com.gluster.storage.management.console.feature.webstart/.project deleted file mode 100644 index ebf9c846..00000000 --- a/src/com.gluster.storage.management.console.feature.webstart/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - com.gluster.storage.management.console.feature.webstart - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/src/com.gluster.storage.management.console.feature.webstart/buckminster.cspex b/src/com.gluster.storage.management.console.feature.webstart/buckminster.cspex deleted file mode 100644 index 252a5e15..00000000 --- a/src/com.gluster.storage.management.console.feature.webstart/buckminster.cspex +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console.feature.webstart/build.properties b/src/com.gluster.storage.management.console.feature.webstart/build.properties deleted file mode 100644 index 322a3114..00000000 --- a/src/com.gluster.storage.management.console.feature.webstart/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -#bin.includes = feature.xml -root=rootfiles diff --git a/src/com.gluster.storage.management.console.feature.webstart/build/glustermc.ant b/src/com.gluster.storage.management.console.feature.webstart/build/glustermc.ant deleted file mode 100644 index 93bf3ccb..00000000 --- a/src/com.gluster.storage.management.console.feature.webstart/build/glustermc.ant +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console.feature.webstart/feature.xml b/src/com.gluster.storage.management.console.feature.webstart/feature.xml deleted file mode 100644 index 24a76dc9..00000000 --- a/src/com.gluster.storage.management.console.feature.webstart/feature.xml +++ /dev/null @@ -1,229 +0,0 @@ - - - - - [Enter Feature Description here.] - - - - [Enter Copyright Description here.] - - - - [Enter License Description here.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp deleted file mode 100644 index 3ac01605..00000000 --- a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp +++ /dev/null @@ -1,44 +0,0 @@ - - - - Gluster Management Console - Gluster Inc. - - Gluster Management Console - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png b/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png deleted file mode 100644 index 74983f8a..00000000 Binary files a/src/com.gluster.storage.management.console.feature.webstart/rootfiles/splash.png and /dev/null differ diff --git a/src/com.gluster.storage.management.console.feature/.project b/src/com.gluster.storage.management.console.feature/.project deleted file mode 100644 index a736d116..00000000 --- a/src/com.gluster.storage.management.console.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - com.gluster.storage.management.console.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/src/com.gluster.storage.management.console.feature/build.properties b/src/com.gluster.storage.management.console.feature/build.properties deleted file mode 100644 index 64f93a9f..00000000 --- a/src/com.gluster.storage.management.console.feature/build.properties +++ /dev/null @@ -1 +0,0 @@ -bin.includes = feature.xml diff --git a/src/com.gluster.storage.management.console.feature/feature.xml b/src/com.gluster.storage.management.console.feature/feature.xml deleted file mode 100644 index aaf4a08c..00000000 --- a/src/com.gluster.storage.management.console.feature/feature.xml +++ /dev/null @@ -1,942 +0,0 @@ - - - - - [Enter Feature Description here.] - - - - [Enter Copyright Description here.] - - - - [Enter License Description here.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console.help/.project b/src/com.gluster.storage.management.console.help/.project deleted file mode 100644 index ba39c551..00000000 --- a/src/com.gluster.storage.management.console.help/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - com.gluster.storage.management.console.help - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - - diff --git a/src/com.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs b/src/com.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 970d49e2..00000000 --- a/src/com.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Tue Aug 23 12:38:58 IST 2011 -eclipse.preferences.version=1 -encoding//html/concepts/about_gmc.html=UTF-8 -encoding//html/concepts/common_terms.html=UTF-8 -encoding//html/concepts/gluster_fs.html=UTF-8 -encoding//html/gettingstarted/check_req_client.html=UTF-8 -encoding//html/gettingstarted/cifs_service.html=UTF-8 -encoding/build.properties=UTF-8 diff --git a/src/com.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs b/src/com.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs deleted file mode 100644 index d7503970..00000000 --- a/src/com.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Tue Aug 09 14:50:25 IST 2011 -css-profile//html/concepts/about_gmc.html=org.eclipse.wst.css.core.cssprofile.css1 -css-profile//html/concepts/common_terms.html=org.eclipse.wst.css.core.cssprofile.css1 -eclipse.preferences.version=1 diff --git a/src/com.gluster.storage.management.console.help/META-INF/MANIFEST.MF b/src/com.gluster.storage.management.console.help/META-INF/MANIFEST.MF deleted file mode 100644 index 7795e50d..00000000 --- a/src/com.gluster.storage.management.console.help/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Gluster Management Console - Help -Bundle-SymbolicName: com.gluster.storage.management.console.help; singleton:=true -Bundle-Version: 1.0.0 -Bundle-Vendor: GLUSTER -Require-Bundle: org.eclipse.help.ui;bundle-version="3.5.2", - org.eclipse.help.webapp;bundle-version="3.5.2", - org.eclipse.help diff --git a/src/com.gluster.storage.management.console.help/build.properties b/src/com.gluster.storage.management.console.help/build.properties deleted file mode 100644 index 9fb97e12..00000000 --- a/src/com.gluster.storage.management.console.help/build.properties +++ /dev/null @@ -1,8 +0,0 @@ -bin.includes = plugin.xml,\ - META-INF/,\ - html/,\ - toc.xml,\ - tocconcepts.xml,\ - tocgettingstarted.xml,\ - toctasks.xml,\ - tocreference.xml diff --git a/src/com.gluster.storage.management.console.help/html/concepts/about_gmc.html b/src/com.gluster.storage.management.console.help/html/concepts/about_gmc.html deleted file mode 100644 index ef79927b..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/about_gmc.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -Main Topic - - - -

About Gluster Management Console

-Gluster Management Console is a Java application that provides a single interface to perform the administrative tasks such as create, manage, and maintain your storage cluster.

You can use the Gluster Management Console to:

-
    -
  • Create a Gluster Storage Cluster -
  • Expand your cluster -
  • Monitor systems in your cluster -
  • Manage logs -
- - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/concepts/about_gmg.html b/src/com.gluster.storage.management.console.help/html/concepts/about_gmg.html deleted file mode 100644 index 34f9c860..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/about_gmg.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Main Topic - - - -

Gluster Management Gateway

-Gluster Management Gateway provides simple and powerful ReST APIs for managing your Gluster Storage Cluster. It also hosts the Gluster Management Console binaries, which can be launched from a browser using the Java Webstart. Gluster Management Console uses the ReST APIs for performing the administrative tasks on the Gluster Storage Cluster -

Gluster Management Gateway Architecture - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/concepts/common_terms.html b/src/com.gluster.storage.management.console.help/html/concepts/common_terms.html deleted file mode 100644 index ccf6d218..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/common_terms.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - -Sub Topic 2 - - - -

Common Cluster Terminologies

-

Cluster

-

A cluster is a group of linked computers, working together closely thus in many respects forming a single computer.

-

Brick -

Brick is the basic unit of storage, represented by an export directory on a server in the trusted storage pool.

-

Network

-

A network is a collection of interconnected computers able to -communicate with each other and transfer information back and forth.

-

Distributed File Systems

-

A file system is a collection of files and the facilities -(programs and commands) that enable users to access the information in -the files. All computing environments have file systems. A distributed -file system takes advantage of the interconnected nature of the network -by storing files on more than one computer in the network and making -them accessible to all of them. In other words, the responsibility for -file storage and delivery is "distributed" among multiple machines -instead of relying on only one.

-

File Server Machines

-

File server machines store the files in the distributed file -system, and a server process running on the file server machine delivers -and receives files.

-

Volumes

-

A volume is a conceptual container for a set of related files -that keeps them all together on one file server machine partition. -Volumes can vary in size, but are (by definition) smaller than a -partition. You can maintain maximum system efficiency by moving volumes -to keep the load balanced evenly among the different machines. If a -partition becomes full, the small size of individual volumes makes it -easy to find enough room on other machines for them. Each volume -corresponds logically to a directory in the file tree and keeps -together, on a single partition, all the data that makes up the files in -the directory (including possible subdirectories). By maintaining (for -example) a separate volume for each user's home directory, you keep all -of the user's files together, but separate from those of other users. -This is an administrative convenience that is impossible if the -partition is the smallest unit of storage.

- - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/concepts/gluster_fs.html b/src/com.gluster.storage.management.console.help/html/concepts/gluster_fs.html deleted file mode 100644 index 4efe5f36..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/gluster_fs.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -Sub Topic - - - -

Introducing Gluster Filesystem (GlusterFS)

-GlusterFS is an open source, scale-out file system capable of scaling to several petabytes and handling thousands of clients. GlusterFS assembles storage building blocks, aggregating disk and memory resources and managing data in a single global namespace. GlusterFS is based on a stackable user space design and can deliver exceptional performance for diverse workloads

The GlusterFS modular architecture allows administrators to stack modules to match user requirements, as needed. For example, administrators can use GlusterFS to quickly configure a standalone server system and later expand the system as their business needs grow.

-

Virtualized Cloud Environments

-

GlusterFS is designed for today's high-performance, virtualized cloud environments. Unlike traditional data centers, cloud environments require multi-tenancy along with the ability to grow or shrink resources on demand. GlusterFS incorporates cloud capabilities into the core architecture. -

Every module in GlusterFS is treated as a volume. GlusterFS further adds an elastic volume manager (the glusterd daemon) and a console manager (the gluster command line interface). Using the console manager, administrators can dynamically expand, shrink, rebalance, and migrate volumes, among other operations. The command line interface additionally provides an interactive shell (with auto-completion) along with scripting capabilities suitable for automation.

-

GlusterFS Architecture - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/concepts/maintopic.html b/src/com.gluster.storage.management.console.help/html/concepts/maintopic.html deleted file mode 100644 index a476078a..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/maintopic.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Main Topic - - - -

Main Topic

-Please enter your text here. - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/concepts/subtopic.html b/src/com.gluster.storage.management.console.help/html/concepts/subtopic.html deleted file mode 100644 index 8a61c501..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/subtopic.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Sub Topic - - - -

Sub Topic

-Please enter your text here. - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/concepts/subtopic2.html b/src/com.gluster.storage.management.console.help/html/concepts/subtopic2.html deleted file mode 100644 index 86bcbf9c..00000000 --- a/src/com.gluster.storage.management.console.help/html/concepts/subtopic2.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Sub Topic 2 - - - -

Sub Topic 2

-Please enter your text here. - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console.help/html/css/Builder/style.css b/src/com.gluster.storage.management.console.help/html/css/Builder/style.css deleted file mode 100644 index 39efe946..00000000 --- a/src/com.gluster.storage.management.console.help/html/css/Builder/style.css +++ /dev/null @@ -1,939 +0,0 @@ -/* -Theme Name: Builder -Theme URI: http://ithemes.com/ -Description: Builder lets you create custom layouts quickly and easily. -Author: iThemes -Author URI: http://ithemes.com/ -Version: 2.8.0 -Tags: blog, theme options, multiple layouts, multiple color schemes - -Version History - See history.txt -*/ - -/********************************************* - Default font settings and typography. - The font-size percentage is of 16px. (0.75 * 16px = 12px) -*********************************************/ -html { - font-size: 100.01%; -} -body { - font-size: 75%; - line-height: 1.5; - color: #222222; - font-family: Arial, Helvetica, sans-serif; -} -input, select, textarea { - font-family: Arial, Helvetica, sans-serif; -} -pre, code, tt, kbd { - font-family: 'andale mono', 'lucida console', monospace; - font-size: 1em; - line-height: 1.5; -} -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -address, dfn, img, samp, ul, ol, dl { - margin-top: 1.5em; - margin-bottom: 1.5em; -} -a img { - margin: 0; -} - -/********************************************* - Constrain table, image, and input widths -*********************************************/ -table, img, input, textarea, select { - max-width: 100%; - height: auto; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; -} - -/********************************************* - Main Background -*********************************************/ -body { - background: #F7F7F7; -} - -/********************************************* - Universal Link Styles -*********************************************/ -a { - color: #000000; - text-decoration: underline; -} -a:hover { - color: #000000; - text-decoration: underline; -} -a:focus { - color: #000000; -} - -/********************************************* - Headings -*********************************************/ -h1, h2, h3, h4, h5, h6 { - font-weight: bold; - color: #111111; -} -h1 { - font-family: "Arial Black", Arial, Helvetica, Sans-Serif; - font-size: 2em; - line-height: 1.5; - margin-top: 0.75em; - margin-bottom: 0.75em; - letter-spacing: -1px; -} -h2 { - font-size: 1.7em; - line-height: 1.75em; - margin-top: 0.9em; - margin-bottom: 0.9em; -} -h3 { - font-size: 1.5em; - line-height: 1; - margin-top: 1em; - margin-bottom: 1em; -} -h4 { - font-size: 1.2em; - line-height: 1.25em; - margin-top: 1.25em; - margin-bottom: 1.25em; -} -h5, h6 { - font-size: 1em; -} -h6 { - font-style: italic; -} -h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { - margin: 0; -} - -/********************************************* - Container Div -*********************************************/ -.builder-container-outer-wrapper { - background: transparent; - margin: 1.5em auto; - border: none; - display: block; -} - -/********************************************* - Default Module Styling -*********************************************/ -.builder-module { - background: #FFFFFF; - margin-bottom: 1.5em; - border-top: .1em solid #777777; - border-bottom: .1em solid #777777; -} -.builder-module-last { - margin-bottom: 0; -} - -/* Failed attempt #5 at producing full-height sidebars - - This does not work due to a Firefox glitch that causes wide content to - override the width of blocks. - - These rules should be looked at again later in case Firefox fixes this issue. -*/ -/* -.builder-module { - display: table; - table-layout: fixed; -} -.builder-module-block-outer-wrapper { - display: table-cell !important; - float: none !important; - vertical-align: top; -} -*/ - -/********************************************* - All Sidebars -*********************************************/ -.builder-module-sidebar { - background: #DDDDDD; - display: block; - width: 100%; - text-align: left; - margin: 0; - padding: .75em 0; -} -.builder-module-sidebar.right { - margin-right: 0; -} -.builder-module-sidebar.left { - margin-left: 0; -} -.builder-module-sidebar .widget-wrapper { - width: 100%; -} -.builder-module-sidebar .widget { - margin: 0; - padding: .75em 1.5em; - color: #333333; -} -.builder-module-block-outer-wrapper { - overflow: visible !important; -} -.builder-module-block-outer-wrapper .widget-wrapper-left .widget, -.builder-module-block-outer-wrapper .widget-wrapper-middle .widget { - padding-right: .75em; -} -.builder-module-block-outer-wrapper .widget-wrapper-middle .widget, -.builder-module-block-outer-wrapper .widget-wrapper-right .widget { - padding-left: .75em; -} -.builder-module-sidebar h4.widget-title { - color: #333333; - background: none; - font-size: 1.2em; - line-height: 1.25; - padding: 0; - margin: 0 0 1.25em 0; -} -.builder-module-sidebar h4.widget-title a { - color: #333333; -} -.builder-module-sidebar h4.widget-title + * { - margin-top: 0; -} -.builder-module-sidebar .widget *:first-child { - margin-top: 0; -} -.builder-module-sidebar .widget *:last-child { - margin-bottom: 0; -} -.builder-module-sidebar .widget a.rsswidget img { - display: none; -} - -/********************************************* - Navigation Module -*********************************************/ -.builder-module-navigation { - font-size: 1em; - line-height: 2em; - background: #FFFFFF url('images/nav_bg.png') repeat top left; - display: block; - width: 100%; -} -.builder-module-navigation .builder-module-element { - margin: 0 .5em; -} -.builder-module-navigation ul { - float: left; - display: block; - margin: 0; - padding: 0; -} -.builder-module-navigation ul * { - margin: 0; -} -.builder-module-navigation li { - padding: 0; -} -.builder-module-navigation li a, -.builder-module-navigation li.current_page_item li a, -.builder-module-navigation li.current-cat li a { - font-size: 1em; - padding: .4em .6em; - color: #333333; - font-weight: bold; - text-decoration: none; - background: #FFFFFF url('images/nav_bg.png') repeat-x top left; -} -.builder-module-navigation li a:hover { - background: #333333 url('images/nav_bg_hover.jpg') repeat-x top left; - color: #FFFFFF; -} -.builder-module-navigation li.current_page_item a, -.builder-module-navigation li.current-cat a { -} -/* second level stuff */ -.builder-module-navigation li ul { - width: 14em; - border: .1em solid #777777; - border-bottom: 0; -} -.builder-module-navigation li li { - border-bottom: .1em solid #777777; - width: 14em; -} -.builder-module-navigation li li a { - float: none; -} -.builder-module-navigation li li a:hover, -.builder-module-navigation li li a.sfhover { -} -.builder-module-navigation li ul ul { - margin: -2.9em 0 0 14em; -} - -/********************************************* - Widget Bar Module -*********************************************/ -.builder-module-widget-bar { - background: #DDDDDD; -} - -/********************************************* - Footer Module -*********************************************/ -.builder-module-footer { - background: transparent; - border: none; -} -.builder-module-footer .builder-module-element { - text-align: left; - color: #333333; - margin: 0 1.5em; -} -.builder-module-footer .builder-module-element .alignright { - text-align: right; -} -.builder-module-footer .builder-module-element a { - color: #333333; - text-decoration: none; -} -.builder-module-footer .builder-module-element a:hover { - text-decoration: underline; -} - -/********************************************* - Image Module -*********************************************/ -.builder-module-image .builder-module-element { - font-size: 0; -} -.builder-module-image .builder-module-element img { - margin: 0; -} - -/********************************************* - HTML Module -*********************************************/ - -/********************************************* - Content Module -*********************************************/ -.builder-module-content .builder-module-element { - margin: 1.5em; - display: block; - text-align: left; - overflow: hidden; -} -.builder-module-content .post { - margin-bottom: 1.5em; -} - -.post-title, .post-title * { - margin: 0; - padding: 0; -} -.post .thumbnail-wrap { - display: none; -} -.post .date { - /*display: none;*/ - float: left; -} - -.post-title h1, -.post-title h2, -.post-title h3 { - font-family: "Arial Black",Arial,Helvetica,Sans-Serif; - clear: both; - color: #262626; - font-size: 1.9em; - line-height: 1em; - letter-spacing: -1px; - font-weight: bold; - text-transform: uppercase; - margin-bottom: .56em; -} -.post-title a { - text-decoration: none; - color: #262626; - font-size: 1em; -} - -.post .post-meta { - display: block; - /*clear: both;*/ -} -.post .post-meta a { - text-decoration: none; - font-style: italic; -} -.post .post-meta a:hover { - text-decoration: underline; -} -.post .meta-bottom { - display: block; -} -.post .meta-bottom img { - max-width: none; -} - -.post .entry-attachment .attachment { - text-align: center; -} - -.post .edit-entry-link { - margin: 0 0 1.5em 0; - clear: both; -} - -.post-content { - margin-top: 1.5em; - clear: both; -} -.page-title { - font-size: 1.75em; - line-height: 1.7em; - margin-top: 0; - margin-bottom: .875em; -} - -/********************************************* - Style images and galleries - .hentry is used instead of .page or .post - as it applies to all content types -*********************************************/ -.hentry .gallery a, -.hentry .gallery dt, -.hentry .gallery img { - margin: 0; - font-size: 0; - line-height: 0; -} -.hentry .gallery-item { - display: inline-block; - margin: 0 1.5em 1.5em 0; - padding: 5px; - vertical-align: top; - text-align: left; - width: 150px; - border: 1px solid #CFCFCF; - background: #F3F3F3; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} -.hentry .gallery-item img { - border: 0; - margin: 0; - padding: 0; -} -.hentry .gallery-caption { - margin: 0; - padding: 10px 5px 5px 5px; - line-height: 1; -} -.hentry .gallery + * { - margin-top: 0; -} - -.hentry img { - border: 1px solid #CFCFCF; - background: #F3F3F3; - padding: 5px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} -.hentry .alignright { - margin: 0 0 1.5em 1.5em; -} -.hentry .alignleft { - margin: 0 1.5em 1.5em 0; -} -.hentry .aligncenter { - margin: 0 auto 1.5em auto; -} - -.hentry .wp-caption { - border: 1px solid #CFCFCF; - background: #F3F3F3; - padding: 5px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} -.hentry .wp-caption img { - border: none; - background: transparent; - padding: 0; -} - -.hentry .wp-caption-text { - text-align: left; - margin: 0; - padding: 10px 5px 5px 5px; - line-height: 1; -} - - -/********************************************* - Post Meta Styles, if needed -*********************************************/ -.meta-top { - clear: both; /* we need this so floats in the post are cleared */ -} - -.meta-bottom { - clear: both; /* we need this so floats in the post are cleared */ - border-top: .1em solid #D7D7D7; - padding-top: 1.4em; - margin-bottom: 3em; -} -.meta-bottom .alignright { - margin-bottom: 1.5em; -} -.meta-bottom .categories, -.meta-bottom .tags { - background: url( 'images/folder.png' ) 0 0 no-repeat; - padding: 0 0 0 1.5em; -} -.meta-bottom .comments { - background: url( 'images/comments.png' ) 0 2px no-repeat; - padding: 0 0 0 1.5em; -} - -.EXIF table { - margin: 1.5em auto; -} -.photometa h4 { - text-align: center; - margin: 0; - padding: 0; -} -.photometa ul { - list-style-type: none; -} - -/********************************************* - Previous/Next Page Navigation -*********************************************/ -.paging { - clear: both; /* To clear any floats */ - margin: 0; - padding: 0; -} - -/********************************************* - Comment Styles -*********************************************/ -#comments { - margin: 3em 0 1.5em 0; - padding: 0; -} -#comments ol.commentlist { - margin: 1.5em 0; - padding: 0; - background: transparent; -} -#comments ul.children { - margin: 0 1.5em; -} -#comments .vcard { - line-height: 1; - margin-bottom: .5em; -} -#comments .vcard .avatar { - display: block; - float: left; - margin: 0 .75em 0 0; -} -#comments .comment-meta { - margin-bottom: 1.5em; -} -#comments li { - clear: both; - list-style-type: none; - margin: 1.5em 0; - border: 1px solid #999999; - overflow: hidden; -} -#comments li .comment-body { - margin: 1.5em; -} -#comments blockquote { - margin: 1.5em; -} - -#respond { - margin-top: 3em; - overflow: visible !important; -} -.comment #respond { - margin: 1.5em 1.5em 1.5em 1.5em; - padding: 0 1.5em 1.5em 1.5em; - border: 1px solid #999999; -} -#respond h3 { - margin-bottom: 0; -} -#respond .cancel-comment-reply a { - margin: 0; - display: block; -} -#commentform label { - margin-left: 1em; -} -#commentform input[type="text"] { - width: 20em; -} -#commentform input, -#commentform textarea { - margin: 0; -} -#commentform #comment { - width: 100%; -} -#commentform .comment-submit-wrapper { - margin-bottom: 0; -} - -/********************************************* - Text elements -*********************************************/ -p { -} -p img.left { - float: left; - margin: 1.5em 1.5em 1.5em 0; - padding: 0; -} -p img.right { - float: right; - margin: 1.5em 0 1.5em 1.5em; -} -blockquote { - background: url('images/blockquote.png') top left no-repeat; - margin: 1.5em; - padding: 0; - color: #666666; - font-style: italic; -} -strong { - font-weight: bold; -} -em, dfn { - font-style: italic; -} -dfn { - font-weight: bold; -} -sup, sub { - height: 0; - line-height: 1.5; - vertical-align: baseline; - position: relative; -} -sup { - bottom: 1ex; -} -sub { - top: .5ex; -} -abbr, acronym { - border-bottom: 1px dotted #666; -} -address { - font-style: italic; -} -del { - color: #666666; -} -pre { - margin: 1.5em 0; - white-space: pre; -} -big { - font-size: 1.2em; - line-height: 1; -} - -/********************************************* - Lists -*********************************************/ -ul, ol { - list-style-position: outside; - margin: 0 0 0 1.4em; - padding: 0; -} -.post-content > ul, -.post-content > ol { - margin-top: 1.5em; - margin-bottom: 1.5em; -} -ol { - margin-left: 20px; - *margin-left: 24px; /* targeted IE 6, 7 fix */ -} -li { - margin: 0; - padding: 0; -} -li > * { - margin-top: 0; -} -li *:last-child { - margin-bottom: 0; -} -li > p + ul { - margin-top: -1.5em; -} -ul { - list-style-type: disc; -} -ol { - list-style-type: decimal; -} -dl { - margin: 0 0 1.5em 0; -} -dl dt { - font-weight: bold; -} -dd { - margin-left: 1.5em; -} -dd + dd { - margin-top: 1.5em; -} - -/********************************************* - Tables -*********************************************/ -table { - margin-bottom: 1.5em; - background: #F3F3F3; -} -table, td, th { - border: 1px solid #CFCFCF; - border-collapse: collapse; -} -th { - font-weight: bold; - line-height: 1.5; - background: #E8E8E8; -} -th, td, caption { - padding: .75em; -} -tr:nth-child(2n) th { - background: #F6F6F6; -} -tr:nth-child(2n) td { - background: #FFFFFF; -} -tfoot { - font-style: italic; -} -caption { - background: #EEEEEE; -} - -/********************************************* - Misc classes -*********************************************/ -.small { - font-size: .8em; - line-height: 1.875; - margin-top: 1.875em; - margin-bottom: 1.875em; -} -.large { - font-size: 1.2em; - line-height: 2.5; - margin-top: 1.25em; - margin-bottom: 1.25em; -} -.hide { - display: none; -} -.quiet { - color: #666666; -} -.loud { - color: #000000; -} -.highlight { - background: #FFFF00; -} -.added { - background: #006600; - color: #FFFFFF; -} -.removed { - background: #990000; - color: #FFFFFF; -} -.first { - margin-left: 0; - padding-left: 0; -} -.last { - margin-right: 0; - padding-right: 0; -} -.top { - margin-top: 0; - padding-top: 0; -} -.bottom { - margin-bottom: 0; - padding-bottom: 0; -} - -/********************************************* - Default styling for forms -*********************************************/ -label { - font-weight: bold; -} -fieldset { - padding: 1.4em; - margin: 0 0 1.5em 0; - border: .1em solid #CCCCCC; -} -legend { - font-weight: bold; - font-size: 1.2em; -} - -/********************************************* - Form fields -*********************************************/ -input[type=text], input[type=password], input.text, input.title, textarea, select { - font-size: 1em; - margin-top: .5em; - margin-bottom: .5em; -} -input[type=text], input[type=password], input.text, input.title, textarea { - background-color: #FFFFFF; - border: 1px solid #999999; - padding: 5px; -} -input[type=text]:focus, input[type=password]:focus, input.text:focus, input.title:focus, textarea:focus { - border-color: #666666; -} -textarea { - width: 30em; - height: 20em; -} -input[type=checkbox], input[type=radio], input.checkbox, input.radio { -/* position: relative; - top: .25em;*/ -} -.search-text-box { - margin-bottom: 0; -} -.search-submit-button { - margin: 0 !important; - padding: .2em .5em; -} - -/********************************************* - Success, notice and error boxes -*********************************************/ -.error, .notice, .success { - padding: .8em; - margin-bottom: 1em; - border: 2px solid #ddd; -} -.error { - background: #FBE3E4; - color: #8a1f11; - border-color: #FBC2C4; -} -.notice { - background: #FFF6BF; - color: #514721; - border-color: #FFD324; -} -.success { - background: #E6EFC2; - color: #264409; - border-color: #C6D880; -} -.error a { - color: #8a1f11; -} -.notice a { - color: #514721; -} -.success a { - color: #264409; -} - -/********************************************* - Widget Styling -*********************************************/ -.widget_rss li { - margin-bottom: 1.5em; -} -.widget_rss .rsswidget { - display: block; - margin: 0; -} -.widget_rss .rss-date { - display: block; - font-style: italic; - margin-bottom: 1.5em; -} -.widget_rss .rssSummary { - margin: 1.5em 0; -} - - -/********************************************* - Social Tabs -*********************************************/ -#social-tags { - position: fixed; - width: 95px; - height: 100%; - right: 0; - left: auto; - margin-right: 0; - margin-left: auto; - padding-top: 10px; - overflow: hidden; -} -#social-tags a { - position: relative; - right: -50px; - margin: 0; -} -#social-tags a:hover { - right: 0; -} - -/********************************************* - The Obligatory WP Styles -*********************************************/ -.alignright { - margin-left: 1.5em; -} -.alignleft { - margin-right: 1.5em; -} -.post img.wp-smiley { - border: none; -} diff --git a/src/com.gluster.storage.management.console.help/html/css/builder-gluster/style.css b/src/com.gluster.storage.management.console.help/html/css/builder-gluster/style.css deleted file mode 100644 index 80daf9fb..00000000 --- a/src/com.gluster.storage.management.console.help/html/css/builder-gluster/style.css +++ /dev/null @@ -1,1341 +0,0 @@ -/* -Theme Name: Gluster - Builder Theme -Description: Gluster Theme based on Builder Framework -Author: iThemes modified by glassCanopy -Template: Builder -*/ - -/* do not remove the import line */ -@import url("../Builder/style.css"); - - -/********************************************* - Default font settings and typography. - The font-size percentage is of 16px. (0.75 * 16px = 12px) -*********************************************/ -body { - font-size: 75%; - line-height: 1.5; - color: #333333; - font-family: Arial,Verdana,Helvetica,sans-serif; -} -input, select, textarea { - font-family: Arial,Verdana,Helvetica,sans-serif; -} - -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -address, dfn, samp, dl, img, ul, ol { - margin-top: 0.5em; - margin-bottom: 0.5em; -} - -/*img, li { filter:alpha(opacity=100)!important;} */ - -a img { - margin: 0; -} - -table, th, td { - border:0; - background-color:none; -} - -ul { - list-style-type:none; -} -/* -html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { - vertical-align: top; -} -*/ - - -.hentry img { - border: 0; - background: none; - padding: 0; - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; -/* width: auto !important; - height: auto !important; */ -} - -p { - font-size:110%; - line-height:1.5em; - margin:0; - padding:0 0 .5em 0; -} - -table, img, input, textarea, select { - max-width: auto; - height: auto; - -moz-box-sizing: none; - -webkit-box-sizing: none; - -ms-box-sizing: none; - box-sizing: none; -} - -.builder-module-block-outer-wrapper .widget-wrapper-left .widget, .builder-module-block-outer-wrapper .widget-wrapper-middle .widget { - padding-right: 0.25em; - padding-left:2em; -} - -/********************************************* - Main Background -*********************************************/ -body { - background: #FFFFFF; -} - -.builder-container-outer-wrapper { - background: url(/wp-content/themes/builder-gluster/images/background-top.png); - background-position:top right; - background-repeat:no-repeat; -} - -#gluster-logo { - display:block; - border:0; - position:absolute; - top:4px; - z-index:900; - width:464px; - height:86px; -} - - -/********************************************* - Universal Link Styles -*********************************************/ -a { - color: #EF7622; - text-decoration: underline; -} -a:hover { - color: #EF7622; - text-decoration: underline; -} - -/********************************************* - Headings -*********************************************/ -h1, h2, h3, h4, h5, h6 { - font-weight: bold; - color: #60A0CF; -} -h1 { - font-family: Arial, Helvetica, Sans-Serif; - font-size: 135%; - line-height: 1.5; - margin-top: 0; - margin-bottom: 0.5em; - letter-spacing: 1px; - color: #284764; -} -h2 { - - color: #60A0CF; - font-family: Verdana,Arial,Helvetica,sans-serif; - font-size: 13px; - margin: 0; - padding: 8px 0 4px 0; - line-height: 1.75em; -} -h3 { - font-size: 1.5em; - line-height: 1; - margin-top: 1em; - margin-bottom: 1em; -} -h4 { - font-size: 1.2em; - line-height: 1.25em; - margin-top: 1.25em; - margin-bottom: 1.25em; -} -h5, h6 { - font-size: 1em; -} -h6 { - font-style: italic; -} -h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { - margin: 0; -} - -.type-page .post-title { -display: none; -} - -.type-post .post-title h1 { - font-family: Arial, Helvetica, Sans-Serif; - font-size: 135%; - line-height: 1.5; - margin-top: 1em; - margin-bottom: 0em; - letter-spacing: 1px; - color: #284764; -} - -.post-title h1 { - font-family: Arial, Helvetica, Sans-Serif; - font-size: 135%; - line-height: 1.5; - margin-top: 0; - margin-bottom: 0.5em; - letter-spacing: 1px; - color: #284764; -} - -.post-content { - clear: both; - margin-top: 1em; -} - -.post-content > ul, .post-content > ol { - margin-bottom: 0.5em; - margin-top: 0.5em; -} - -.builder-module-sidebar h4.widget-title { - background: none repeat scroll 0 0 transparent; - color:#284764; - letter-spacing:1px; - font-size: 1.2em; - line-height: 1.25; - margin: 0 0 1.25em; - padding: 0; - font-weight:normal; -} - -.builder-module-content .builder-module-element { - display: block; - margin: 0 0.25em 1.5em 0.25em; - overflow: hidden; - text-align: left; -} - -.builder-module-sidebar .widget { - color: #333333; - margin: 0; - padding: 0.25em .75em 0 .75em; -} - -.widget-content p { - margin:0; - padding:0; -} - -.widget-it-content { - margin:0; - padding:0; -} - -/********************************************* - All Sidebars -*********************************************/ -.builder-module-sidebar { - background: #FFFFFF; -} - -/* fix footer link underline */ -.builder-module-footer .builder-module-element a { - text-decoration: underline; -} - -/********************************************* - Navigation Module -*********************************************/ -.builder-module-navigation { - font-size: 1em; - line-height: 1.81em; - background: none; - display: block; - width: 100%; - margin-bottom: 0; - -} -.builder-module-navigation .builder-module-element { - margin: 0 .5em; -} -.builder-module-navigation ul { - float: right; - display: block; - margin: 0; - padding: 0; -} -.builder-module-navigation ul * { - margin: 0; -} -.builder-module-navigation li { - padding: 0; -} -.builder-module-navigation li a, -.builder-module-navigation li.current_page_item li a, -.builder-module-navigation li.current-cat li a { - font-size: 1em; - padding: .1em .6em; - color: #ffffff; - font-weight: normal; - text-decoration: none; - background: none; -} -.builder-module-navigation li a:hover { - background: none; - color: #325C84; - text-decoration:none; -} -.builder-module-navigation li.current_page_item a, -.builder-module-navigation li.current-cat a { - color: #325C84; -} - -.builder-module-navigation li.current_page_item a:hover, -.builder-module-navigation li.current-cat a:hover { - color: #ffffff; - background: none; - border:none; -} - -.builder-module { - border:0px solid #ffffff; -background:none; -} -.builder-module-block { -border:0px solid #ffffff; -background:none; -} - -#menu-utility-menu li a { - background:none; - color:#FFFFFF; - font-size:90%; -} - -#menu-utility-menu li a:hover{ - background:none; - color:#FFFFFF; - text-decoration:underline; - font-size:90%; -} - -#menu-top-menu .sub-menu li.menu-item, #menu-top-menu .sub-menu li.menu-item a { -background: #67ABDD; -color:#ffffff; - -} - -#menu-top-menu .sub-menu li.menu-item a:hover, #menu-top-menu .sub-menu li.menu-item a:hover { -background:#67ABDD; -color: #325C84; - -} - -/* second level stuff */ -.builder-module-navigation li ul { - width: 14em; - border:none; - border-bottom: 0; -} -.builder-module-navigation li li { - border-bottom: .1em solid #ffffff; - width: 14em; -} -.builder-module-navigation li li a { - float: none; -} -.builder-module-navigation li li a:hover, -.builder-module-navigation li li a.sfhover { -} -.builder-module-navigation li ul ul { - /* margin: -2.9em 0 0 14em;*/ - margin: -2.05em 0 0 14em; -} -.builder-module-navigation li ul ul li { - border-left: 1px solid #89c8f9; -} - -/* LEFT NAVIGATION */ -#nav_menu-2 ul, -#nav_menu-3 ul, -#nav_menu-4 ul, -#nav_menu-5 ul, -#nav_menu-6 ul, -#nav_menu-7 ul, -#nav_menu-8 ul, -#nav_menu-9 ul, -#nav_menu-10 ul, -#nav_menu-11 ul, -#nav_menu-12 ul, -#nav_menu-13 ul, -#nav_menu-14 ul { - color:#325C84; - list-style-type:disc; - margin-left:1em; - padding-left:0; - -} -#nav_menu-2 li a:link, #nav_menu-2 li a:visited, #nav_menu-2 li a:hover, -#nav_menu-3 li a:link, #nav_menu-3 li a:visited, #nav_menu-3 li a:hover, -#nav_menu-4 li a:link, #nav_menu-4 li a:visited, #nav_menu-4 li a:hover, -#nav_menu-5 li a:link, #nav_menu-5 li a:visited, #nav_menu-5 li a:hover, -#nav_menu-6 li a:link, #nav_menu-6 li a:visited, #nav_menu-6 li a:hover, -#nav_menu-7 li a:link, #nav_menu-7 li a:visited, #nav_menu-7 li a:hover, -#nav_menu-8 li a:link, #nav_menu-8 li a:visited #nav_menu-8 li a:hover, -#nav_menu-9 li a:link, #nav_menu-9 li a:visited #nav_menu-9 li a:hover, -#nav_menu-10 li a:link, #nav_menu-10 li a:visited #nav_menu-10 li a:hover, -#nav_menu-11 li a:link, #nav_menu-11 li a:visited #nav_menu-11 li a:hover, -#nav_menu-12 li a:link, #nav_menu-12 li a:visited, #nav_menu-12 li a:hover, -#nav_menu-13 li a:link, #nav_menu-13 li a:visited, #nav_menu-13 li a:hover, -#nav_menu-14 li a:link, #nav_menu-14 li a:visited, #nav_menu-14 li a:hover { - color: #325C84; - font-weight: normal; - text-decoration: none; -} -#nav_menu-2 li.menu-item a, -#nav_menu-3 li.menu-item a, -#nav_menu-4 li.menu-item a, -#nav_menu-5 li.menu-item a, -#nav_menu-6 li.menu-item a, -#nav_menu-7 li.menu-item a, -#nav_menu-8 li.menu-item a, -#nav_menu-9 li.menu-item a, -#nav_menu-10 li.menu-item a, -#nav_menu-11 li.menu-item a, -#nav_menu-12 li.menu-item a, -#nav_menu-13 li.menu-item a, -#nav_menu-14 li.menu-item a { - color: #325C84; - font-weight: normal; - text-decoration: none; -} -#nav_menu-2 ul li ul.sub-menu, -#nav_menu-3 ul li ul.sub-menu, -#nav_menu-4 ul li ul.sub-menu, -#nav_menu-5 ul li ul.sub-menu, -#nav_menu-6 ul li ul.sub-menu, -#nav_menu-7 ul li ul.sub-menu, -#nav_menu-8 ul li ul.sub-menu, -#nav_menu-9 ul li ul.sub-menu, -#nav_menu-10 ul li ul.sub-menu, -#nav_menu-11 ul li ul.sub-menu, -#nav_menu-12 ul li ul.sub-menu, -#nav_menu-13 ul li ul.sub-menu, -#nav_menu-14 ul li ul.sub-menu { -margin-top:.2em; -list-style-type:none; -} - - - -/* HOME PAGE STYLES */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/add_volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/add_volume.svg deleted file mode 100644 index 66307f36..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/add_volume.svg +++ /dev/null @@ -1,3235 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/brick.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/brick.svg deleted file mode 100644 index 365110f2..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/brick.svg +++ /dev/null @@ -1,652 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - go - lower - down - arrow - pointer - > - - - - - Andreas Nilsson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg deleted file mode 100644 index 1fa4e0d4..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg +++ /dev/null @@ -1,3697 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/bricks.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/bricks.svg deleted file mode 100644 index 39af40f2..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/bricks.svg +++ /dev/null @@ -1,684 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - go - lower - down - arrow - pointer - > - - - - - Andreas Nilsson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/cloud.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/cloud.svg deleted file mode 100644 index d51128ac..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/cloud.svg +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg deleted file mode 100644 index 2cc8da4e..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg +++ /dev/null @@ -1,3044 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/create-volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/create-volume.svg deleted file mode 100644 index 14a5823f..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/create-volume.svg +++ /dev/null @@ -1,3006 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg deleted file mode 100644 index bfe35cce..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg +++ /dev/null @@ -1,1088 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg deleted file mode 100644 index 79f172df..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg +++ /dev/null @@ -1,2263 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk.svg deleted file mode 100644 index 730e9b27..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk.svg +++ /dev/null @@ -1,850 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_available.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk_available.svg deleted file mode 100644 index 667535c1..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_available.svg +++ /dev/null @@ -1,1983 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_error.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk_error.svg deleted file mode 100644 index 1dda3bbf..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_error.svg +++ /dev/null @@ -1,1991 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg deleted file mode 100644 index 5bffaa8f..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg +++ /dev/null @@ -1,2302 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg deleted file mode 100644 index 5d5388b2..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg +++ /dev/null @@ -1,1848 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg deleted file mode 100644 index f3cdd2ee..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg +++ /dev/null @@ -1,2585 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/download_log.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/download_log.svg deleted file mode 100644 index 2ac27d12..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/download_log.svg +++ /dev/null @@ -1,1187 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - document - settings - preferences - properties - tweak - - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg deleted file mode 100644 index 1ed67ab8..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg +++ /dev/null @@ -1,1661 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg deleted file mode 100644 index 0ee3b389..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg +++ /dev/null @@ -1,589 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/log.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/log.svg deleted file mode 100644 index 42559766..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/log.svg +++ /dev/null @@ -1,1160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - document - settings - preferences - properties - tweak - - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg deleted file mode 100644 index dc5faa1b..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg +++ /dev/null @@ -1,1790 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - cdrom - media - removable - cd - audio - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg deleted file mode 100644 index fb587339..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/offline.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/offline.svg deleted file mode 100644 index 9ee10367..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/offline.svg +++ /dev/null @@ -1,1637 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - document - settings - preferences - properties - tweak - - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg deleted file mode 100644 index bf1963df..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg +++ /dev/null @@ -1,4413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg deleted file mode 100644 index 5bc030db..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg +++ /dev/null @@ -1,713 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - go - lower - down - arrow - pointer - > - - - - - Andreas Nilsson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_server.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/offline_server.svg deleted file mode 100644 index f1f50c40..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_server.svg +++ /dev/null @@ -1,838 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg deleted file mode 100644 index 8146a910..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg +++ /dev/null @@ -1,3171 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg deleted file mode 100644 index 8cef7653..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg +++ /dev/null @@ -1,246 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/online.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/online.svg deleted file mode 100644 index c25a4232..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/online.svg +++ /dev/null @@ -1,1410 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - document - settings - preferences - properties - tweak - - - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/remove-server.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/remove-server.svg deleted file mode 100644 index 4280df60..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/remove-server.svg +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-03-08 - - - Jakub Steiner - - - - - workstation - computer - node - client - - - - http://jimmac.musichall.cz/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg deleted file mode 100644 index 450b24c8..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg +++ /dev/null @@ -1,4483 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg deleted file mode 100644 index 83055628..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg +++ /dev/null @@ -1,3248 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg deleted file mode 100644 index cd048c2b..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg +++ /dev/null @@ -1,2946 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/running_task.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/running_task.svg deleted file mode 100644 index d9cf0582..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/running_task.svg +++ /dev/null @@ -1,1498 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-10-10 - - - Andreas Nilsson - - - - - edit - paste - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg deleted file mode 100644 index f3027569..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg deleted file mode 100644 index 3ef559c7..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg +++ /dev/null @@ -1,3350 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/start_volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/start_volume.svg deleted file mode 100644 index 5e738c33..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/start_volume.svg +++ /dev/null @@ -1,3312 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg deleted file mode 100644 index 315bb09b..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg +++ /dev/null @@ -1,3268 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_clear.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_clear.svg deleted file mode 100644 index 02b0b919..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_clear.svg +++ /dev/null @@ -1,845 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Lapo Calamandrei - - - - - - media - pause - playback - video - music - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_commit.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_commit.svg deleted file mode 100644 index 29817471..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_commit.svg +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - - - go - higher - up - arrow - pointer - > - - - - - Andreas Nilsson - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_pause.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_pause.svg deleted file mode 100644 index ff9b5f3e..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_pause.svg +++ /dev/null @@ -1,821 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Lapo Calamandrei - - - - - - media - pause - playback - video - music - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_paused.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_paused.svg deleted file mode 100644 index 9d6930e1..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_paused.svg +++ /dev/null @@ -1,812 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-10-10 - - - Andreas Nilsson - - - - - edit - paste - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_resume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_resume.svg deleted file mode 100644 index 2bd8732c..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_resume.svg +++ /dev/null @@ -1,395 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Lapo Calamandrei - - - - - - play - media - music - video - player - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_running.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_running.svg deleted file mode 100644 index fa15b7b8..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_running.svg +++ /dev/null @@ -1,796 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-10-10 - - - Andreas Nilsson - - - - - edit - paste - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg deleted file mode 100644 index ce0bf238..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg +++ /dev/null @@ -1,577 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-10-10 - - - Andreas Nilsson - - - - - edit - paste - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg deleted file mode 100644 index 5fb8b116..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg +++ /dev/null @@ -1,654 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-10-10 - - - Andreas Nilsson - - - - - edit - paste - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_stop.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_stop.svg deleted file mode 100644 index 07227fd4..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_stop.svg +++ /dev/null @@ -1,748 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Lapo Calamandrei - - - - - - media - stop - playback - video - music - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg deleted file mode 100644 index d900f03f..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg +++ /dev/null @@ -1,784 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 2005-10-10 - - - Andreas Nilsson - - - - - edit - paste - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg deleted file mode 100644 index 995fb90b..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg +++ /dev/null @@ -1,500 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Terminal - 2005-10-15 - - - Andreas Nilsson - - - - - terminal - emulator - term - command line - - - - - - Jakub Steiner - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg deleted file mode 100644 index 565f6dad..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg +++ /dev/null @@ -1,393 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - View Refresh - - - reload - refresh - view - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/volume.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/volume.svg deleted file mode 100644 index b5e50a46..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/volume.svg +++ /dev/null @@ -1,2917 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/volume_option.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/volume_option.svg deleted file mode 100644 index 3fb4a928..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/volume_option.svg +++ /dev/null @@ -1,2875 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg deleted file mode 100644 index 78fdc384..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg +++ /dev/null @@ -1,3713 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/icons/tango/scalable/volumes.svg b/src/com.gluster.storage.management.console/icons/tango/scalable/volumes.svg deleted file mode 100644 index 3c99b006..00000000 --- a/src/com.gluster.storage.management.console/icons/tango/scalable/volumes.svg +++ /dev/null @@ -1,2949 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/images/gauge.png b/src/com.gluster.storage.management.console/images/gauge.png deleted file mode 100644 index 6f5764ea..00000000 Binary files a/src/com.gluster.storage.management.console/images/gauge.png and /dev/null differ diff --git a/src/com.gluster.storage.management.console/images/gauge_small.png b/src/com.gluster.storage.management.console/images/gauge_small.png deleted file mode 100644 index 71e424fe..00000000 Binary files a/src/com.gluster.storage.management.console/images/gauge_small.png and /dev/null differ diff --git a/src/com.gluster.storage.management.console/images/gluster-about.png b/src/com.gluster.storage.management.console/images/gluster-about.png deleted file mode 100644 index 9518b2b2..00000000 Binary files a/src/com.gluster.storage.management.console/images/gluster-about.png and /dev/null differ diff --git a/src/com.gluster.storage.management.console/images/login-screen-with-text.psd b/src/com.gluster.storage.management.console/images/login-screen-with-text.psd deleted file mode 100644 index f6e7ab35..00000000 Binary files a/src/com.gluster.storage.management.console/images/login-screen-with-text.psd and /dev/null differ diff --git a/src/com.gluster.storage.management.console/images/login-screen.psd b/src/com.gluster.storage.management.console/images/login-screen.psd deleted file mode 100644 index a9bfc27e..00000000 Binary files a/src/com.gluster.storage.management.console/images/login-screen.psd and /dev/null differ diff --git a/src/com.gluster.storage.management.console/images/splash-dialog.bmp b/src/com.gluster.storage.management.console/images/splash-dialog.bmp deleted file mode 100644 index 932032fb..00000000 Binary files a/src/com.gluster.storage.management.console/images/splash-dialog.bmp and /dev/null differ diff --git a/src/com.gluster.storage.management.console/images/splash-screen.psd b/src/com.gluster.storage.management.console/images/splash-screen.psd deleted file mode 100644 index 43544f41..00000000 Binary files a/src/com.gluster.storage.management.console/images/splash-screen.psd and /dev/null differ diff --git a/src/com.gluster.storage.management.console/plugin.properties b/src/com.gluster.storage.management.console/plugin.properties deleted file mode 100644 index 5393818f..00000000 --- a/src/com.gluster.storage.management.console/plugin.properties +++ /dev/null @@ -1,7 +0,0 @@ -aboutText=Gluster Management Console\n\ -Version: 1.0.0\n\n\ -Copyright (c) 2011 Gluster, Inc.\n\ -Visit http://www.gluster.com/\n\n\ -This product includes software developed by the\n\ -Eclipse Foundation http://eclipse.org/\n\ -RichClientGUI http://www.richclientgui.com/ \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/plugin.xml b/src/com.gluster.storage.management.console/plugin.xml deleted file mode 100644 index fa949443..00000000 --- a/src/com.gluster.storage.management.console/plugin.xml +++ /dev/null @@ -1,1658 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.console/preferences.ini b/src/com.gluster.storage.management.console/preferences.ini deleted file mode 100644 index 7053b209..00000000 --- a/src/com.gluster.storage.management.console/preferences.ini +++ /dev/null @@ -1,3 +0,0 @@ -org.eclipse.ui/KEY_CONFIGURATION_ID = com.gluster.storage.management.console.KeyConfig -org.eclipse.help.base/help_home=/com.gluster.storage.management.console.help/html/help_home.html -IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP=true \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/splash.bmp b/src/com.gluster.storage.management.console/splash.bmp deleted file mode 100644 index d4510414..00000000 Binary files a/src/com.gluster.storage.management.console/splash.bmp and /dev/null differ diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Activator.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Activator.java deleted file mode 100644 index 8edae7f4..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Activator.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "com.gluster.storage.management.console"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - public void editorOpened() { - System.err.println("Editor opened!"); - } - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/AlertsManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/AlertsManager.java deleted file mode 100644 index a5b3a4e6..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/AlertsManager.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * AlertsManager.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.preference.IPreferenceStore; - -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.core.model.Alert; -import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Partition; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class AlertsManager { - private List alerts = new ArrayList(); - private Cluster cluster; - - private Double CPU_USAGE_THRESHOLD; - private Double MEMORY_USAGE_THRESHOLD; - private Double DISK_SPACE_USAGE_THRESHOLD; - - public AlertsManager(Cluster cluster) { - this.cluster = cluster; - - IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - CPU_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD); - MEMORY_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD); - DISK_SPACE_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD); - } - - public List getAlerts() { - return alerts; - } - - public Alert getAlert(String id) { - for (Alert alert : getAlerts()) { - if (alert.getId().equals(id)) { - return alert; - } - } - return null; - } - - public void addAlert(Alert alert) { - alerts.add(alert); - } - - public void addAlerts(List alerts) { - this.alerts.addAll(alerts); - } - - public void setAlerts(List alerts) { - this.alerts = alerts; - } - - public Boolean removeAlert(String id) { - for (int i = 0; i < alerts.size(); i++) { - if (alerts.get(i).getId().equals(id)) { - return (alerts.remove(i) != null); - } - } - return false; - } - - public void clearAll() { - this.alerts.clear(); - } - - public void buildAlerts() { - clearAll(); - addAlerts(getServerAlerts()); - addAlerts(getVolumeAlerts()); - } - - private List getServerAlerts() { - List serverAlerts = new ArrayList(); - Alert offlineServerAlert = getOfflineServerAlerts(); - if (offlineServerAlert != null) { - serverAlerts.add(offlineServerAlert); // Single alert for offline servers - } - - for (GlusterServer server : cluster.getServers()) { - // To check off line servers - // if (server.getStatus() == SERVER_STATUS.OFFLINE) { - // serverAlerts.add(new Alert(ALERT_TYPES.OFFLINE_SERVERS_ALERT, server.getName(), "Server [" - // + server.getName() + "] is Offline")); - // continue; // If the server is Offline skip other Alert builds - // } - - // To check High CPU usage - if (server.getCpuUsage() >= CPU_USAGE_THRESHOLD) { - serverAlerts.add(new Alert(ALERT_TYPES.CPU_USAGE_ALERT, server.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.CPU_USAGE_ALERT.ordinal()] + " [" - + NumberUtil.formatNumber(server.getCpuUsage()) + "] in server [" + server.getName() - + "]")); - } - - // To check High Memory usage - Double memoryUtilized = server.getMemoryInUse() / server.getTotalMemory() * 100d; - if (memoryUtilized >= MEMORY_USAGE_THRESHOLD) { - serverAlerts.add(new Alert(ALERT_TYPES.MEMORY_USAGE_ALERT, server.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.MEMORY_USAGE_ALERT.ordinal()] + " [" - + NumberUtil.formatNumber(memoryUtilized) + "%] in server [" + server.getName() - + "]")); - } - - // To Check low disk space - serverAlerts.addAll(getLowDiskAlerts(server)); - } - return serverAlerts; - } - - private Alert getOfflineServerAlerts() { - List offlineServers = new ArrayList(); - for (GlusterServer server : cluster.getServers()) { - if (server.getStatus() == SERVER_STATUS.OFFLINE) { - offlineServers.add(server.getName()); - } - } - if (offlineServers.size() > 0) { - return new Alert(ALERT_TYPES.OFFLINE_SERVERS_ALERT, "Server", - Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_SERVERS_ALERT.ordinal()] + "(s) " - + offlineServers.toString()); - } - return null; - } - - private List getLowDiskAlerts(GlusterServer server) { - List diskAlerts = new ArrayList(); - boolean hasPartition; - Double deviceSpaceUsed; - for (Disk disk : server.getDisks()) { - hasPartition = false; - for (Partition partition : disk.getPartitions()) { - hasPartition = true; - deviceSpaceUsed = partition.getSpaceInUse() / partition.getSpace() * 100d; - if (deviceSpaceUsed >= DISK_SPACE_USAGE_THRESHOLD) { - diskAlerts.add(new Alert(ALERT_TYPES.DISK_USAGE_ALERT, partition.getQualifiedName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [" - + NumberUtil.formatNumber(deviceSpaceUsed) + "% used] in disk [" - + partition.getQualifiedName() + "]")); - } - } - if (hasPartition) { - continue; // Do not check disk usage - } - - // If it is disk - deviceSpaceUsed = disk.getSpaceInUse() / disk.getSpace() * 100d; - if (deviceSpaceUsed >= DISK_SPACE_USAGE_THRESHOLD) { - diskAlerts.add(new Alert(ALERT_TYPES.DISK_USAGE_ALERT, disk.getQualifiedName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [" - + NumberUtil.formatNumber(deviceSpaceUsed) + "% used] in [" - + disk.getQualifiedName() + "]")); - } - } - return diskAlerts; - } - - private List getVolumeAlerts() { - List volumeAlerts = new ArrayList(); - List offlineBricks = new ArrayList(); - - for (Volume volume : cluster.getVolumes()) { - if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { - volumeAlerts.add(new Alert(ALERT_TYPES.OFFLINE_VOLUME_ALERT, volume.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_ALERT.ordinal()] + " [" + volume.getName() - + "]")); - continue; - } - - // To check off line bricks - offlineBricks = new ArrayList(); - for (Brick brick : volume.getBricks()) { - if (brick.getStatus() == BRICK_STATUS.OFFLINE) { - offlineBricks.add(brick.getQualifiedName()); - } - } - // One offline brick alert per volume - if (offlineBricks.size() > 0) { - volumeAlerts.add(new Alert(ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT, volume.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT.ordinal()] + " " - + offlineBricks.toString() + " in volume " + volume.getName())); - } - } - return volumeAlerts; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Application.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Application.java deleted file mode 100644 index e84dac47..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Application.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.databinding.observable.Realm; -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.PlatformUI; - -import com.gluster.storage.management.console.dialogs.LoginDialog; -import com.gluster.storage.management.core.model.Entity; - -/** - * This class controls all aspects of the application's execution - */ -public class Application implements IApplication { - - public static final String PLUGIN_ID = "com.gluster.storage.management.console"; - private static Application instance; - private List entityListeners = Collections.synchronizedList(new ArrayList()); - private IStatusLineManager statusLineManager; - - public Application() { - instance = this; - } - - public static Application getApplication() { - return instance; - } - - public IStatusLineManager getStatusLineManager() { - return statusLineManager; - } - - public void setStatusLineManager(IStatusLineManager statusLineManager) { - this.statusLineManager = statusLineManager; - } - - private boolean login() { - LoginDialog loginDialog = new LoginDialog(new Shell(Display.getDefault())); - return (loginDialog.open() == Window.OK); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) - */ - public Object start(IApplicationContext context) { - setSystemProperties(); - - Display display = PlatformUI.createDisplay(); - - final boolean[] loginSuccess = new boolean[1]; - Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { - public void run() { - loginSuccess[0] = login(); - } - }); - - if (!loginSuccess[0]) { - return IApplication.EXIT_OK; - } - try { - int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); - if (returnCode == PlatformUI.RETURN_RESTART) { - return IApplication.EXIT_RESTART; - } - - return IApplication.EXIT_OK; - } finally { - display.dispose(); - } - } - - private void setSystemProperties() { - // TODO: Trying this to avoid the webstart authentication dialog - // to be tested, and removed if this doesn't work. - System.setProperty("javaws.cfg.jauthenticator", "none"); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.equinox.app.IApplication#stop() - */ - public void stop() { - if (!PlatformUI.isWorkbenchRunning()) - return; - final IWorkbench workbench = PlatformUI.getWorkbench(); - final Display display = workbench.getDisplay(); - display.syncExec(new Runnable() { - public void run() { - if (!display.isDisposed()) - workbench.close(); - } - }); - } - - public void addEntityListener(IEntityListener listener) { - entityListeners.add(listener); - } - - public void entityChanged(Entity entity, String[] paremeters) { - for (IEntityListener listener : entityListeners) { - listener.entityChanged(entity, paremeters); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationActionBarAdvisor.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationActionBarAdvisor.java deleted file mode 100644 index e8d2dd8c..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationActionBarAdvisor.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.ICoolBarManager; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.swt.SWT; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import com.gluster.storage.management.console.utils.GUIHelper; - -/** - * An action bar advisor is responsible for creating, adding, and disposing of the actions added to a workbench window. - * Each window will be populated with new actions. - */ -public class ApplicationActionBarAdvisor extends ActionBarAdvisor { - private IWorkbenchWindow window; - /* - * Actions - important to allocate these only in makeActions, and then use them in the fill methods. This ensures - * that the actions aren't recreated when fillActionBars is called with FILL_PROXY. - */ - private IWorkbenchAction exitAction; - private IWorkbenchAction aboutAction; - private IWorkbenchAction helpContentsAction; - - private GUIHelper guiHelper = GUIHelper.getInstance(); - - public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { - super(configurer); - } - - protected void makeActions(final IWorkbenchWindow window) { - this.window = window; - /* - * Creates the actions and registers them. Registering is needed to ensure that key bindings work. The - * corresponding commands keybindings are defined in the plugin.xml file. Registering also provides automatic - * disposal of the actions when the window is closed. - */ - exitAction = ActionFactory.QUIT.create(window); - register(exitAction); - - aboutAction = ActionFactory.ABOUT.create(window); - aboutAction.setText("&About"); - aboutAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.HELP_16x16)); - register(aboutAction); - - helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); - helpContentsAction.setText("&Management Console Help"); - helpContentsAction.setAccelerator(SWT.F1); - //helpContentsAction.setImageDescriptor(newImage) - register(helpContentsAction); - } - - protected void fillMenuBar(IMenuManager menuBar) { - // File - MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); - fileMenu.add(new Separator()); - fileMenu.add(exitAction); - - // Help - MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); - helpMenu.add(helpContentsAction); - helpMenu.add(aboutAction); - - menuBar.add(fileMenu); - // Add a group marker indicating where action set menus will appear. - // All action sets from plugin.xml will get added here - menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); - menuBar.add(helpMenu); - } - - protected void fillCoolBar(ICoolBarManager coolBar) { - // All our actions are added to toolbar through the extension point org.eclipse.ui.actionSets - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java deleted file mode 100644 index 8d6c81da..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.ui.application.IWorkbenchConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchAdvisor; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -import com.gluster.storage.management.console.jobs.DataSyncJob; -import com.gluster.storage.management.console.preferences.PreferenceConstants; - -/** - * This workbench advisor creates the window advisor, and specifies - * the perspective id for the initial window. - */ -public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { - private Job syncJob; - private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - private long JOB_INTERVAL = preferenceStore.getLong(PreferenceConstants.P_DATA_SYNC_INTERVAL) * 1000; - private IPropertyChangeListener propertyChangeListener; - - public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - return new ApplicationWorkbenchWindowAdvisor(configurer); - } - - public String getInitialWindowPerspectiveId() { - return Perspective.ID; - } - - @Override - public void initialize(IWorkbenchConfigurer configurer) { - super.initialize(configurer); - configurer.setSaveAndRestore(false); // we don't need save/restore as of now - - createPropertyChangeListener(); - preferenceStore.addPropertyChangeListener(propertyChangeListener); - } - - private void createPropertyChangeListener() { - propertyChangeListener = new IPropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(PreferenceConstants.P_DATA_SYNC_INTERVAL)) { - JOB_INTERVAL = (Integer)event.getNewValue() * 1000L; - } - } - }; - } - - @Override - public void postStartup() { - super.postStartup(); - setupBackgroundJobs(); - } - - private void setupBackgroundJobs() { - syncJob = new DataSyncJob("Retrieving Management Info"); - syncJob.schedule(JOB_INTERVAL); - syncJob.addJobChangeListener(new JobChangeAdapter() { - @Override - public void done(IJobChangeEvent event) { - super.done(event); - - // job done. schedule again after the pre-defined interval - syncJob.schedule(JOB_INTERVAL); - } - }); - } - - @Override - public boolean preShutdown() { - return syncJob.cancel(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java deleted file mode 100644 index 2411dcb5..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.ui.application.ActionBarAdvisor; -import org.eclipse.ui.application.IActionBarConfigurer; -import org.eclipse.ui.application.IWorkbenchWindowConfigurer; -import org.eclipse.ui.application.WorkbenchWindowAdvisor; - -import com.gluster.storage.management.console.utils.GUIHelper; - -public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { - private final static int DEFAULT_WIDTH = 1024; - private final static int DEFAULT_HEIGHT = 768; - private final GUIHelper guiHelper = GUIHelper.getInstance(); - - public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { - super(configurer); - } - - @Override - public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { - return new ApplicationActionBarAdvisor(configurer); - } - - @Override - public void preWindowOpen() { - super.preWindowOpen(); - - IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); - configurer.setInitialSize(new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT)); - configurer.setShowCoolBar(true); - configurer.setShowStatusLine(true); - configurer.setShowMenuBar(true); - configurer.setShowProgressIndicator(true); // shows progress indicator in status bar - } - - @Override - public void postWindowCreate() { - super.postWindowCreate(); - guiHelper.centerShellInScreen(getWindowConfigurer().getWindow().getShell()); - getWindowConfigurer().getWindow().getShell().setMaximized(true); - Application.getApplication().setStatusLineManager( - getWindowConfigurer().getActionBarConfigurer().getStatusLineManager()); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/BrickTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/BrickTableLabelProvider.java deleted file mode 100644 index 4796578e..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/BrickTableLabelProvider.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.swt.graphics.Image; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.BricksPage.BRICK_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.console.views.pages.DisksPage.DISK_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class BrickTableLabelProvider extends TableLabelProviderAdapter { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - public Image getColumnImage(Object element, int columnIndex) { - - if (!(element instanceof Brick)) { - return null; - } - - Brick brick = (Brick) element; - if (columnIndex == DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { - BRICK_STATUS status = brick.getStatus(); - - switch(status) { - case ONLINE: - return guiHelper.getImage(IImageKeys.BRICK_ONLINE_16x16); - case OFFLINE: - return guiHelper.getImage(IImageKeys.BRICK_OFFLINE_16x16); - } - } - return null; - } - - private String getDeviceFreeSpace(Device device) { - if (device != null && device.isReady() && device.getFreeSpace() != null) { - return NumberUtil.formatNumber((device.getFreeSpace() / 1024)); - } else { - return "NA"; - } - } - - private String getDeviceCapacity(Device device) { - if (device != null && device.isReady() && device.getSpace() != null && device.getSpace() != 0.0) { - return NumberUtil.formatNumber((device.getSpace() / 1024)); - } else { - return "NA"; - } - } - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Brick)) { - return null; - } - - Brick brick = (Brick) element; - Device device = GlusterDataModelManager.getInstance().getDeviceForBrickDir(brick); - return (columnIndex == BRICK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? brick.getServerName() - : columnIndex == BRICK_TABLE_COLUMN_INDICES.BRICK.ordinal() ? brick.getBrickDirectory() - : columnIndex == BRICK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? getDeviceFreeSpace(device) - : columnIndex == BRICK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? getDeviceCapacity(device) - : columnIndex == BRICK_TABLE_COLUMN_INDICES.STATUS.ordinal() ? brick.getStatusStr() : "Invalid"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java deleted file mode 100644 index 6c7449f2..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -/** - * - */ -public class ConsoleConstants { - public static final String CONSOLE_TITLE = "Gluster Management Console"; - public static final String TERMINAL_VIEW_ID = "org.eclipse.tm.terminal.view.TerminalView"; - public static final String PROPERTY_AUTO_LOGIN_PASSWORD = "auto.login.password"; - public static final String PROPERTY_AUTO_CLUSTER_NAME = "auto.cluster.name"; -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/DeviceTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/DeviceTableLabelProvider.java deleted file mode 100644 index 3d8fa432..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/DeviceTableLabelProvider.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Partition; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class DeviceTableLabelProvider extends LabelProvider implements ITableLabelProvider { - - private GUIHelper guiHelper = GUIHelper.getInstance(); - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - public enum DEVICE_COLUMN_INDICES { - DISK, PARTITION, FREE_SPACE, SPACE_IN_USE, STATUS - }; - - FontRegistry registry = new FontRegistry(); - - public DeviceTableLabelProvider() { - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (!(element instanceof Device)) { - return null; - } - - Device device = (Device) element; - if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { - DEVICE_STATUS status = device.getStatus(); - - if (status == null) { - if (element instanceof Partition) { - if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { - status = device.getStatus(); - } - } - } - - if (status == null) { - return null; - } - - if(element instanceof Disk && ((Disk)element).hasPartitions()) { - // disk has partitions. so don't show status image at disk level. - return null; - } - - switch (status) { - case INITIALIZED: - if(modelManager.isDeviceUsed(device)) { - return guiHelper.getImage(IImageKeys.DISK_IN_USE_16x16); - } else { - return guiHelper.getImage(IImageKeys.DISK_AVAILABLE_16x16); - } - case IO_ERROR: - return guiHelper.getImage(IImageKeys.IO_ERROR_16x16); - case UNINITIALIZED: - return guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED_16x16); - case INITIALIZING: - return guiHelper.getImage(IImageKeys.DISK_INITIALIZING_16x16); - default: - throw new GlusterRuntimeException("Invalid disk status [" + status + "]"); - } - } - - return null; - } - - @Override - public String getText(Object element) { - return super.getText(element); - } - - private String getDeviceFreeSpace(Device device) { - if (device.hasErrors() || device.isUninitialized()) { - return "NA"; - } else { - return NumberUtil.formatNumber((device.getFreeSpace() / 1024)); - } - } - - private String getTotalDeviceSpace(Device device) { - if (device.hasErrors() || device.isUninitialized()) { - return "NA"; - } else { - return NumberUtil.formatNumber((device.getSpace() / 1024)); - } - } - - public String getColumnText(Object element, int columnIndex) { - - if (element == null) { - return ""; - } - - Device device = (Device) element; - if (columnIndex == DEVICE_COLUMN_INDICES.DISK.ordinal()) { - // show value in "disk" column only if it's a disk - if (device instanceof Disk) { - return device.getQualifiedName(); - } else { - return ""; - } - } - - if(element instanceof Disk && ((Disk)element).hasPartitions()) { - // disk has partitions. so don't show any other details - return ""; - } - - if (columnIndex == DEVICE_COLUMN_INDICES.FREE_SPACE.ordinal()) { - return "" + getDeviceFreeSpace(device); - } else if (columnIndex == DEVICE_COLUMN_INDICES.SPACE_IN_USE.ordinal()) { - return "" + getTotalDeviceSpace(device); - } else if (columnIndex == DEVICE_COLUMN_INDICES.PARTITION.ordinal()) { - if (device instanceof Partition) { - return device.getQualifiedName(); - } else { - return ""; - } - } else if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { - if(device.isUninitialized()) { - return ""; - } - if(modelManager.isDeviceUsed(device)) { - return "In Use"; - } else { - return device.getStatusStr(); - } - } else { - return ""; - } - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/EntityGroupContentProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/EntityGroupContentProvider.java deleted file mode 100644 index 9035e4e2..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/EntityGroupContentProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import com.gluster.storage.management.core.model.EntityGroup; - -public class EntityGroupContentProvider implements - IStructuredContentProvider { - @Override - public void dispose() { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - - } - - @SuppressWarnings("rawtypes") - @Override - public Object[] getElements(Object inputElement) { - if (inputElement instanceof EntityGroup) { - return ((EntityGroup) inputElement).getChildren().toArray(); - } - return null; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java deleted file mode 100644 index 68d338f2..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterDataModelManager.java +++ /dev/null @@ -1,1036 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.preference.IPreferenceStore; - -import com.gluster.storage.management.client.DiscoveredServersClient; -import com.gluster.storage.management.client.GlusterServersClient; -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Alert; -import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Device.DEVICE_TYPE; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; -import com.gluster.storage.management.core.model.GlusterDataModel; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Partition; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.model.VolumeOptionInfo; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; - -public class GlusterDataModelManager { - private static GlusterDataModelManager instance = new GlusterDataModelManager(); - private GlusterDataModel model; - private String securityToken; - private List listeners = new ArrayList(); - private List volumeOptionsInfo; - private String clusterName; - private static Boolean syncInProgress = false; - private static final GlusterLogger logger = GlusterLogger.getInstance();; - - private GlusterDataModelManager() { - } - - public String getSecurityToken() { - return securityToken; - } - - public void setSecurityToken(String securityToken) { - this.securityToken = securityToken; - } - - public void setClusterName(String clusterName) { - this.clusterName = clusterName; - } - - public String getClusterName() { - return clusterName; - } - - public GlusterDataModel getModel() { - return model; - } - - public static GlusterDataModelManager getInstance() { - return instance; - } - - public void initializeModel(String clusterName, IProgressMonitor monitor) { - setClusterName(clusterName); - - model = fetchData(monitor); - } - - private GlusterDataModel fetchData(IProgressMonitor monitor) { - GlusterDataModel model = fetchModel(monitor); - - initializeAlerts(model.getCluster()); - initializeVolumeOptionsInfo(model.getCluster()); - - return model; - } - - public void refreshVolumeData(Volume oldVolume) { - VolumesClient volumeClient = new VolumesClient(); - Volume newVolume = volumeClient.getVolume(oldVolume.getName()); - if(!oldVolume.equals(newVolume)) { - volumeChanged(oldVolume, newVolume); - } - } - - private boolean isCancelled(IProgressMonitor monitor) { - if(monitor.isCanceled()) { - monitor.setTaskName("Data sync cancelled!"); - monitor.done(); - return true; - } else { - return false; - } - } - - public GlusterDataModel fetchModel(IProgressMonitor monitor) { - synchronized (syncInProgress) { - if(syncInProgress) { - logger.info("Previous data sync is still running. Skipping this one."); - return null; - } - syncInProgress = true; - } - - try { - logger.info("Starting data sync"); - GlusterDataModel model = new GlusterDataModel("Gluster Data Model"); - Cluster cluster = new Cluster(clusterName, model); - model.addCluster(cluster); - - monitor.beginTask("Data Sync", 6); - - monitor.setTaskName("Syncing servers..."); - initializeGlusterServers(cluster); - monitor.worked(1); - if(isCancelled(monitor)) { - return model; - } - - monitor.setTaskName("Syncing volumes..."); - initializeVolumes(cluster); - monitor.worked(1); - if(isCancelled(monitor)) { - return model; - } - - monitor.setTaskName("Syncing discovered servers..."); - initializeAutoDiscoveredServers(cluster); - monitor.worked(1); - if(isCancelled(monitor)) { - return model; - } - - monitor.setTaskName("Syncing tasks..."); - initializeTasks(cluster); - monitor.worked(1); - if(isCancelled(monitor)) { - return model; - } - - monitor.setTaskName("Syncing aggregated CPU stats..."); - initializeAggregatedCpuStats(cluster); - monitor.worked(1); - if(isCancelled(monitor)) { - return model; - } - - monitor.setTaskName("Syncing aggregated Network stats..."); - initializeAggregatedNetworkStats(cluster); - monitor.worked(1); - - monitor.done(); - return model; - } finally { - syncInProgress = false; - } - } - - public void updateModel(GlusterDataModel model) { - updateVolumes(model); - updateGlusterServers(model); - updateDiscoveredServers(model); - updateTasks(model); - updateAlerts(model); - updateServerStatistics(model); - } - - private void updateServerStatistics(GlusterDataModel newModel) { - model.getCluster().setAggregatedCpuStats(newModel.getCluster().getAggregatedCpuStats()); - model.getCluster().setAggregatedNetworkStats(newModel.getCluster().getAggregatedNetworkStats()); - for(ClusterListener listener : listeners) { - listener.aggregatedStatsChanged(); - } - } - - private void updateAlerts(GlusterDataModel newModel) { - model.getCluster().getAlerts().clear(); - - // generate alerts for "newModel" - initializeAlerts(newModel.getCluster()); - - // set the new alerts on "model" - model.getCluster().setAlerts(newModel.getCluster().getAlerts()); - - // fire event "alertsGenerated" - alertsGenerated(); - } - - private void updateTasks(GlusterDataModel newModel) { - List oldTasks = model.getCluster().getTaskInfoList(); - List newTasks = newModel.getCluster().getTaskInfoList(); - - Set addedTasks = GlusterCoreUtil.getAddedEntities(oldTasks, newTasks, true); - for(TaskInfo task : addedTasks) { - addTask(task); - } - - Set removedTasks = GlusterCoreUtil.getAddedEntities(newTasks, oldTasks, true); - for(TaskInfo task : removedTasks) { - removeTask(task); - } - - Map modifiedTasks = GlusterCoreUtil.getModifiedEntities(oldTasks, newTasks); - for(Entry entry : modifiedTasks.entrySet()) { - TaskInfo modifiedTask = entry.getKey(); - modifiedTask.copyFrom(entry.getValue()); - updateTask(modifiedTask); - } - } - - private void updateDiscoveredServers(GlusterDataModel newModel) { - List oldServers = model.getCluster().getAutoDiscoveredServers(); - List newServers = newModel.getCluster().getAutoDiscoveredServers(); - - Set addedServers = GlusterCoreUtil.getAddedEntities(oldServers, newServers, true); - for (Server addedServer : addedServers) { - addDiscoveredServer(addedServer); - } - - Set removedServers = GlusterCoreUtil.getAddedEntities(newServers, oldServers, true); - for (Server removedServer : removedServers) { - removeDiscoveredServer(removedServer); - } - - Map modifiedServers = GlusterCoreUtil.getModifiedEntities(oldServers, newServers); - for(Entry entry : modifiedServers.entrySet()) { - discoveredServerChanged(entry.getKey(), entry.getValue()); - } - } - - private void updateGlusterServers(GlusterDataModel newModel) { - List oldServers = model.getCluster().getServers(); - List newServers = newModel.getCluster().getServers(); - - Set addedServers = GlusterCoreUtil.getAddedEntities(oldServers, newServers, true); - for (GlusterServer addedServer : addedServers) { - addGlusterServer(addedServer); - } - - Set removedServers = GlusterCoreUtil.getAddedEntities(newServers, oldServers, true); - for (GlusterServer removedServer : removedServers) { - removeGlusterServer(removedServer); - } - - Map modifiedServers = GlusterCoreUtil.getModifiedEntities(oldServers, newServers); - for(Entry entry : modifiedServers.entrySet()) { - glusterServerChanged(entry.getKey(), entry.getValue()); - } - } - - public void glusterServerChanged(GlusterServer oldServer, GlusterServer newServer) { - oldServer.copyFrom(newServer); - for (ClusterListener listener : listeners) { - listener.serverChanged(oldServer, new Event(EVENT_TYPE.GLUSTER_SERVER_CHANGED, newServer)); - } - - updateDisks(oldServer, oldServer.getDisks(), newServer.getDisks()); - } - - private void updateDisks(Server server, List oldDisks, List newDisks) { - Set addedDisks = GlusterCoreUtil.getAddedEntities(oldDisks, newDisks, false); - addDisks(server, addedDisks); - - Set removedDisks = GlusterCoreUtil.getAddedEntities(newDisks, oldDisks, false); - removeDisks(server, removedDisks); - - Map modifiedDisks = GlusterCoreUtil.getModifiedEntities(oldDisks, newDisks); - disksChanged(server, modifiedDisks); - } - - private void disksChanged(Server server, Map modifiedDisks) { - if(modifiedDisks.size() == 0) { - return; - } - - for (Entry entry : modifiedDisks.entrySet()) { - entry.getKey().copyFrom(entry.getValue()); - } - for (ClusterListener listener : listeners) { - if (server instanceof GlusterServer) { - listener.serverChanged((GlusterServer) server, new Event(EVENT_TYPE.DEVICES_CHANGED, modifiedDisks)); - } else { - listener.discoveredServerChanged(server, new Event(EVENT_TYPE.DEVICES_CHANGED, modifiedDisks)); - } - } - } - - public void updateDeviceStatus(String serverName, String deviceName, DEVICE_STATUS status) { - GlusterServer server = model.getCluster().getServer(serverName); - Device device = getDeviceDetails(server, deviceName); - if (device != null) { - device.setStatus(status); - device.setType(DEVICE_TYPE.DATA); - for (ClusterListener listener : listeners) { - listener.serverChanged(server, new Event(EVENT_TYPE.DEVICES_CHANGED, device)); - } - } - } - - private Device getDeviceDetails(GlusterServer server, String deviceName) { - for (Disk disk : server.getDisks()) { - if (disk.hasPartitions()) { - for (Partition partition : disk.getPartitions()) { - if (partition.getName().equals(deviceName)) { - return partition; - } - } - } else { - if (disk.getName().equals(deviceName)) { - return (Device) disk; - } - } - } - return null; - } - - public void addDisks(Server server, Set disks) { - if(disks.size() == 0) { - return; - } - - server.addDisks(disks); - for (ClusterListener listener : listeners) { - if(server instanceof GlusterServer) { - listener.serverChanged((GlusterServer)server, new Event(EVENT_TYPE.DEVICES_ADDED, disks)); - } else { - listener.discoveredServerChanged(server, new Event(EVENT_TYPE.DEVICES_ADDED, disks)); - } - } - } - - public void removeDisks(Server server, Set disks) { - if(disks.size() == 0) { - return; - } - - for(Disk disk : disks) { - server.removeDisk(disk); - } - - for (ClusterListener listener : listeners) { - if(server instanceof GlusterServer) { - listener.serverChanged((GlusterServer)server, new Event(EVENT_TYPE.DEVICES_REMOVED, disks)); - } else { - listener.discoveredServerChanged(server, new Event(EVENT_TYPE.DEVICES_REMOVED, disks)); - } - } - } - - private void updateVolumes(GlusterDataModel newModel) { - List oldVolumes = model.getCluster().getVolumes(); - List newVolumes = newModel.getCluster().getVolumes(); - - Set addedVolumes = GlusterCoreUtil.getAddedEntities(oldVolumes, newVolumes, false); - for (Volume addedVolume : addedVolumes) { - addVolume(addedVolume); - } - - Set removedVolumes = GlusterCoreUtil.getAddedEntities(newVolumes, oldVolumes, false); - for (Volume removedVolume : removedVolumes) { - deleteVolume(removedVolume); - } - - Map modifiedVolumes = GlusterCoreUtil.getModifiedEntities(oldVolumes, newVolumes); - for(Entry entry : modifiedVolumes.entrySet()) { - volumeChanged(entry.getKey(), entry.getValue()); - } - } - - public void volumeChanged(Volume oldVolume, Volume newVolume) { - oldVolume.copyFrom(newVolume); - - if (oldVolume.getStatus() != newVolume.getStatus()) { - updateVolumeStatusAlert(newVolume, newVolume.getStatus()); - } - - for (ClusterListener listener : listeners) { - listener.volumeChanged(oldVolume, new Event(EVENT_TYPE.VOLUME_CHANGED, newVolume)); - } - updateBricks(oldVolume, oldVolume.getBricks(), newVolume.getBricks()); - } - - private void updateBricks(Volume volume, List oldBricks, List newBricks) { - Set addedBricks = GlusterCoreUtil.getAddedEntities(oldBricks, newBricks, false); - addBricks(volume, addedBricks); - - Set removedBricks = GlusterCoreUtil.getAddedEntities(newBricks, oldBricks, false); - removeBricks(volume, removedBricks); - - Map modifiedBricks = GlusterCoreUtil.getModifiedEntities(oldBricks, newBricks); - bricksChanged(volume, modifiedBricks); - } - - public void bricksChanged(Volume volume, Map modifiedBricks) { - if(modifiedBricks.size() == 0) { - return; - } - - for(Entry entry : modifiedBricks.entrySet()) { - entry.getKey().copyFrom(entry.getValue()); - } - - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_CHANGED, modifiedBricks)); - } - } - - private void initializeGlusterServers(Cluster cluster) { - cluster.setServers(new GlusterServersClient(cluster.getName()).getServers()); - } - - private void initializeAutoDiscoveredServers(Cluster cluster) { - cluster.setAutoDiscoveredServers(new DiscoveredServersClient(cluster.getName()).getDiscoveredServerDetails()); - } - - private void initializeVolumes(Cluster cluster) { - VolumesClient volumeClient = new VolumesClient(cluster.getName()); - cluster.setVolumes(volumeClient.getAllVolumes()); - } - - private void initializeVolumeOptionsInfo(Cluster cluster) { - if(cluster.getServers().isEmpty()) { - // cluster is empty. we won't be able to fetch the volume options information. - return; - } - this.volumeOptionsInfo = new VolumesClient(clusterName).getVolumeOptionsInfo(); - } - - private void initializeTasks(Cluster cluster) { - List taskInfoList = new TasksClient(cluster.getName()).getAllTasks(); - //List taskInfoList = getDummyTasks(); - cluster.setTaskInfoList(taskInfoList); - } - - public void initializeAggregatedCpuStats(Cluster cluster) { - IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD); - - cluster.setAggregatedCpuStats(new GlusterServersClient().getAggregatedCpuStats(cpuStatsPeriod)); - } - - public void initializeAggregatedNetworkStats(Cluster cluster) { - IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD); - - cluster.setAggregatedNetworkStats(new GlusterServersClient().getAggregatedNetworkStats(networkStatsPeriod)); - } - - private List getDummyTasks() { - List taskInfoList = new ArrayList(); - - // Task #1 - TaskInfo taskInfo = new TaskInfo(); - taskInfo.setType(TASK_TYPE.BRICK_MIGRATE); - taskInfo.setName("Migrate Brick-music"); - taskInfo.setPauseSupported(true); - taskInfo.setStopSupported(true); - taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_PAUSE, ""))); - - taskInfo.getStatus().setMessage("Paused"); - taskInfo.setDescription("Migrate Brick on volume [Movies] from /export/adb/music to /export/sdc/music."); - taskInfoList.add(taskInfo); - - // Task #2 - taskInfo = new TaskInfo(); - taskInfo.setType(TASK_TYPE.DISK_FORMAT); - taskInfo.setName("Initialize disk [KVM-GVSA1:sdc]"); - taskInfo.setPauseSupported(false); - taskInfo.setStopSupported(false); - taskInfo.setStatus( new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, ""))); - taskInfo.getStatus().setMessage("Format completed 80% ..."); - taskInfo.setDescription("Formatting disk [KVM-GVSA1:sdc]"); - taskInfoList.add(taskInfo); - - // Task #2 - taskInfo = new TaskInfo(); - taskInfo.setType(TASK_TYPE.VOLUME_REBALANCE); - taskInfo.setName("Rebalance volume [songs]"); - taskInfo.setPauseSupported(false); - taskInfo.setStopSupported(false); - taskInfo.setStatus( new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, ""))); - taskInfo.getStatus().setMessage("Rebalance step1: layout fix in progress"); - taskInfo.setDescription("Rebalance volume [songs]"); - taskInfoList.add(taskInfo); - - return taskInfoList; - } - - private List getDummyAlerts(Cluster cluster) { - List alerts = new ArrayList(); - for (Server server : cluster.getServers()) { - if (alerts.size() == 0) { - alerts.add(new Alert(ALERT_TYPES.CPU_USAGE_ALERT, server.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.CPU_USAGE_ALERT.ordinal()] + " [93.42 %] in " - + server.getName())); - continue; - } - - if (alerts.size() == 1) { - alerts.add(new Alert(ALERT_TYPES.MEMORY_USAGE_ALERT, server.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.MEMORY_USAGE_ALERT.ordinal()] + " [91.83 %] in " - + server.getName())); - continue; - } - - if (alerts.size() == 2) { - alerts.add(new Alert(ALERT_TYPES.OFFLINE_SERVERS_ALERT, server.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_SERVERS_ALERT.ordinal()] + " " + server.getName())); - continue; - } - - if (alerts.size() == 3) { - alerts.add(new Alert(ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT, "songs", - Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT.ordinal()] - + " [KVM-GVSA4:/export/hdb4/songs] in volume [songs]")); - continue; - } - } - return alerts; - } - - public void initializeAlerts(Cluster cluster) { - AlertsManager alertsManager = new AlertsManager(cluster); - alertsManager.buildAlerts(); - cluster.setAlerts( alertsManager.getAlerts() ); - //cluster.setAlerts( getDummyAlerts(cluster) ); - } - - public Volume addVolume(List volumes, String name, Cluster cluster, VOLUME_TYPE volumeType, - TRANSPORT_TYPE transportType, VOLUME_STATUS status) { - Volume volume = new Volume(name, cluster, volumeType, transportType, status); - volumes.add(volume); - - return volume; - } - -// private Device getDevice(String serverName, String deviceName) { -// List allDevices = getReadyDevicesOfAllServers(); -// for (Device device : allDevices) { -// if (device.getServerName().equals(serverName) && device.getName().equals(deviceName)) { -// return device; -// } -// } -// return null; -// } - - /* - * @param diskName (sda) - * - * @return The device object for given device name - */ - public Device getDeviceDetails(String deviceName) { - List allDevices = getReadyDevicesOfAllServers(); - for (Device device : allDevices) { - if (device.getName().equals(deviceName)) { - return device; - } - } - return null; - } - - - public Device getDeviceForBrickDir(Brick brick) { - Device brickDevice = null; - for (Device device : getReadyDevicesOfServer(brick.getServerName(), new ArrayList())) { - if (brick.getBrickDirectory().startsWith( device.getMountPoint() )) { - if (brickDevice == null || device.getMountPoint().length() > brickDevice.getMountPoint().length()) { - brickDevice = device; - } - } - } - return brickDevice; - } - - public List getDevicesOfVolume(Volume volume) { - Device device = null; - List volumeDevices = new ArrayList(); - for (Brick brick : volume.getBricks()) { - // device = getDevice(brick.getServerName(), brick.getDeviceName()); - device = getDeviceForBrickDir(brick); - if (device != null) { - volumeDevices.add(device); - } - } - return volumeDevices; - } - - public List getReadyDevicesOfAllServers() { - return getReadyDevicesOfAllServersExcluding(new ArrayList()); - } - - public List getReadyDevicesOfAllServersExcluding(List excludeDevices) { - List devices = new ArrayList(); - - for (Server server : model.getCluster().getServers()) { - devices.addAll( getReadyDevicesOfServer(server.getName(), excludeDevices) ); - } - return devices; - } - - public List getReadyDevicesOfServer(String serverName, List excludeDevices) { - List devices = new ArrayList(); - GlusterServer server = model.getCluster().getServer(serverName); - if (server == null || !server.isOnline()) { - return devices; - } - for (Disk disk : server.getDisks()) { - if (disk.hasPartitions()) { - for (Partition partition : disk.getPartitions()) { - if (partition.isReady() && !excludeDevices.contains(partition)) { - devices.add(partition); - } - } - } else if (disk.isReady() && !excludeDevices.contains(disk)) { - devices.add(disk); - } - } - return devices; - } - - public void addClusterListener(ClusterListener listener) { - listeners.add(listener); - } - - public void removeClusterListener(ClusterListener listener) { - listeners.remove(listener); - } - - public void addGlusterServer(GlusterServer server) { - Cluster cluster = model.getCluster(); - cluster.addServer(server); - - for (ClusterListener listener : listeners) { - listener.serverAdded(server); - } - - removeDiscoveredServer(server.getName()); - } - - public void addDiscoveredServer(Server server) { - Cluster cluster = model.getCluster(); - cluster.addDiscoveredServer(server); - - for (ClusterListener listener : listeners) { - listener.discoveredServerAdded(server); - } - } - - public void discoveredServerChanged(Server oldServer, Server newServer) { - oldServer.copyFrom(newServer); - for (ClusterListener listener : listeners) { - listener.discoveredServerChanged(oldServer, new Event(EVENT_TYPE.DISCOVERED_SERVER_CHANGED, newServer)); - } - updateDisks(oldServer, oldServer.getDisks(), newServer.getDisks()); - } - - public void removeDiscoveredServer(String serverName) { - Cluster cluster = model.getCluster(); - // TODO: Move auto-discovered servers outside the cluster - for(Server server : cluster.getAutoDiscoveredServers()) { - if(server.getName().toUpperCase().equals(serverName.toUpperCase())) { - removeDiscoveredServer(server); - return; - } - } - } - - public void removeDiscoveredServer(Server server) { - Cluster cluster = model.getCluster(); - cluster.removeDiscoveredServer(server); - - for (ClusterListener listener : listeners) { - listener.discoveredServerRemoved(server); - } - } - - public void removeGlusterServer(GlusterServer server) { - Cluster cluster = model.getCluster(); - cluster.removeServer(server); - - // can't use an iterator here. The method AbstractList.Itr#next checks for concurrent modification. - // Since listeners can end up creating new views, which add themselves as listeners, the listeners - // list can be concurrently modified which can result in an exception while using iterator. - // Hence we use List#get instead of the iterator - for(int i = 0; i < listeners.size(); i++) { - ClusterListener listener = listeners.get(i); - listener.serverRemoved(server); - } - - // add it to discovered servers list if it is online server - if (server.isOnline()) { - Server removedServer = new Server(); - removedServer.copyFrom(server); - removedServer.addDisks(server.getDisks()); - addDiscoveredServer(removedServer); - } - } - - public void deleteVolume(Volume volume) { - Cluster cluster = model.getCluster(); - cluster.deleteVolume(volume); - - // can't use an iterator here. The method AbstractList.Itr#next checks for concurrent modification. - // Since listeners can end up creating new views, which add themselves as listeners, the listeners - // list can be concurrently modified which can result in an exception while using iterator. - // Hence we use List#get instead of the iterator - for(int i = 0; i < listeners.size(); i++) { - ClusterListener listener = listeners.get(i); - listener.volumeDeleted(volume); - } - } - - public void updateVolumeStatus(Volume volume, VOLUME_STATUS newStatus) { - volume.setStatus(newStatus); - updateVolumeStatusAlert(volume, newStatus); - - if(newStatus == VOLUME_STATUS.OFFLINE) { - // mark as bricks also as offline - for(Brick brick : volume.getBricks()) { - brick.setStatus(BRICK_STATUS.OFFLINE); - } - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_CHANGED, volume.getBricks())); - } - } else { - Volume newVolume = new VolumesClient().getVolume(volume.getName()); //Getting latest brick info - updateBricks(volume, volume.getBricks(), newVolume.getBricks()); - } - - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_STATUS_CHANGED, newStatus)); - } - } - - private void updateVolumeStatusAlert(Volume volume, VOLUME_STATUS newStatus) { - Alert alert = null; - if (newStatus == VOLUME_STATUS.OFFLINE) { - alert = createOfflineVolumeAlert(volume); - for (ClusterListener listener : listeners) { - listener.alertCreated(alert); - } - } else { - alert = removeOfflineVolumeAlert(volume); - for (ClusterListener listener : listeners) { - listener.alertRemoved(alert); - } - } - } - - private Alert createOfflineVolumeAlert(Volume volume) { - Alert alert = new Alert(ALERT_TYPES.OFFLINE_VOLUME_ALERT, volume.getName(), - Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_ALERT.ordinal()] + " [" + volume.getName() + "]"); - getModel().getCluster().addAlert(alert); - return alert; - } - - private Alert removeOfflineVolumeAlert(Volume volume) { - List clusterAlerts = getModel().getCluster().getAlerts(); - Alert removedAlert = null; - for (Alert alert : clusterAlerts) { - if (alert.getType().equals(ALERT_TYPES.OFFLINE_VOLUME_ALERT) - && alert.getReference().equals(volume.getName())) { - removedAlert = alert; - clusterAlerts.remove(alert); - break; - } - } - return removedAlert; - } - - public void resetVolumeOptions(Volume volume) { - volume.getOptions().clear(); - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTIONS_RESET, null)); - } - } - - public void addBricks(Volume volume, Set bricks) { - if(bricks.size() == 0) { - return; - } - - volume.addBricks(bricks); - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_ADDED, bricks)); - } - updateVolumeTypeByBricks(volume); - } - - public void removeBricks(Volume volume, Set bricks) { - if(bricks.size() == 0) { - return; - } - - // Remove the bricks from the volume object - for (Brick brick : bricks) { - volume.removeBrick(brick); - } - - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_REMOVED, bricks)); - } - updateVolumeTypeByBricks(volume); - } - - private void updateVolumeTypeByBricks(Volume volume) { - VOLUME_TYPE volumeType = volume.getVolumeType(); - if (volumeType.equals(VOLUME_TYPE.REPLICATE) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE)) { - if (volume.getBricks().size() > volume.getReplicaCount()) { - volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); - } else { - volume.setVolumeType(VOLUME_TYPE.REPLICATE); - } - } else if (volumeType.equals(VOLUME_TYPE.STRIPE) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE)) { - if (volume.getBricks().size() > volume.getStripeCount()) { - volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); - } else { - volume.setVolumeType(VOLUME_TYPE.STRIPE); - } - } - } - - public void setVolumeOption(Volume volume, String optionKey, String optionValue) { - volume.setOption(optionKey, optionValue); - for (ClusterListener listener : listeners) { - listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTION_SET, optionKey)); - } - } - - public void addVolume(Volume volume) { - Cluster cluster = model.getCluster(); - cluster.addVolume(volume); - - for (ClusterListener listener : listeners) { - listener.volumeCreated(volume); - } - } - - public void addTask(TaskInfo taskInfo) { - Cluster cluster = model.getCluster(); - // To avoid duplicate task, Remove if already exist - TaskInfo existingTaskInfo = getTask(taskInfo.getName()); - if (getTask(taskInfo.getName()) != null) { - removeTask(existingTaskInfo); - } - cluster.addTaskInfo(taskInfo); - for (ClusterListener listener : listeners) { - listener.taskAdded(taskInfo); - } - } - - public TaskInfo getTask(String taskId) { - for (TaskInfo taskInfo: model.getCluster().getTaskInfoList()) { - if (taskInfo.getName().equals(taskId)) { - return taskInfo; - } - } - return null; - } - - public TaskInfo getTaskByReference(String reference) { - for (TaskInfo taskInfo: model.getCluster().getTaskInfoList()) { - if (taskInfo.getReference().equals(reference)) { - return taskInfo; - } - } - return null; - } - - // Updating the Task - public void updateTask(TaskInfo taskInfo) { - for (ClusterListener listener : listeners) { - listener.taskUpdated(taskInfo); - } - } - - public void removeTask(TaskInfo taskInfo) { - model.getCluster().removeTaskInfo(taskInfo); - for (ClusterListener listener : listeners) { - listener.taskRemoved(taskInfo); - } - } - - public void alertsGenerated() { - for (ClusterListener listener : listeners) { - listener.alertsGenerated(); - } - } - - public List getVolumeOptionsInfo() { - if(volumeOptionsInfo == null || volumeOptionsInfo.isEmpty()) { - initializeVolumeOptionsInfo(getModel().getCluster()); - } - return volumeOptionsInfo; - } - - public VolumeOptionInfo getVolumeOptionInfo(String optionKey) { - for (VolumeOptionInfo info : volumeOptionsInfo) { - if (info.getName().equals(optionKey)) { - return info; - } - } - throw new GlusterRuntimeException("Invalid option key [" + optionKey - + "] passed to GlusterDataModelManager#getVolumeOptionInfo"); - } - - public String getVolumeOptionDefaultValue(String optionKey) { - return getVolumeOptionInfo(optionKey).getDefaultValue(); - } - - public String getVolumeOptionDesc(String optionKey) { - return getVolumeOptionInfo(optionKey).getDescription(); - } - - public void setAccessControlList(Volume volume, String accessControlList) { - setVolumeOption(volume, Volume.OPTION_AUTH_ALLOW, accessControlList); - } - - public void setNfsEnabled(Volume volume, boolean enabled) { - setVolumeOption(volume, Volume.OPTION_NFS_DISABLE, (enabled) ? GlusterConstants.OFF : GlusterConstants.ON); - } - - public void setCifsConfig(Volume volume, boolean enabled, List cifsUsers) { - if (enabled) { - volume.enableCifs(); - volume.setCifsUsers(cifsUsers); - } else { - volume.disableCifs(); - } - } - - public Server getGlusterServer(String serverName) { - for (Server server : model.getCluster().getServers()) { - if (server.getName().equalsIgnoreCase(serverName)) { - return server; - } - } - return null; - } - - private Boolean isDeviceUsed(Volume volume, Device device) { - Device brickDevice = null; - for (Brick brick : volume.getBricks()) { - brickDevice = getDeviceForBrickDir(brick); - if (brickDevice != null && device.getName().equals(brickDevice.getName()) - && device.getServerName().equalsIgnoreCase(brick.getServerName())) { - return true; - } - } - return false; - } - - public boolean isDeviceUsed(Device device) { - if (device.getStatus() == DEVICE_STATUS.INITIALIZED) { - for (Volume volume : model.getCluster().getVolumes()) { - if (isDeviceUsed(volume, device)) { - return true; - } - } - } - return false; - } - - public List getVolumesOfServer(String serverName) { - List volumeNames = new ArrayList(); - Cluster cluster = model.getCluster(); - for (Volume volume : cluster.getVolumes()) { - for (Brick brick : volume.getBricks()) { - if (serverName.equalsIgnoreCase(brick.getServerName())) { - volumeNames.add(volume.getName()); - break; - } - } - } - return volumeNames; - } - - public List getOfflineServers() { - List offlineServers = new ArrayList(); - for(GlusterServer server : model.getCluster().getServers()) { - if (!server.isOnline()) { - offlineServers.add(server.getName()); - } - } - return offlineServers; - } - - public List getCifsEnabledVolumeNames(List selectedVolumes) { - List cifsVolumes = new ArrayList(); - for(Volume volume : selectedVolumes) { - if (volume.isCifsEnable()) { - cifsVolumes.add(volume.getName()); - } - } - return cifsVolumes; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterServerTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterServerTableLabelProvider.java deleted file mode 100644 index 71d252ef..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/GlusterServerTableLabelProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.swt.graphics.Image; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.GlusterServersPage.GLUSTER_SERVER_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class GlusterServerTableLabelProvider extends TableLabelProviderAdapter { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (!(element instanceof GlusterServer)) { - return null; - } - - GlusterServer server = (GlusterServer) element; - if(columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal()) { - SERVER_STATUS status = server.getStatus(); - if(status == SERVER_STATUS.ONLINE) { - return guiHelper.getImage(IImageKeys.STATUS_ONLINE_16x16); - } else { - return guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16); - } - } - - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof GlusterServer)) { - return null; - } - - GlusterServer server = (GlusterServer) element; - - if (server.getStatus() == SERVER_STATUS.OFFLINE - && columnIndex != GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() - && columnIndex != GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal()) { - return "NA"; - } - - return (columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() ? server.getName() - : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal() ? server.getStatusStr() - // : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.PREFERRED_NETWORK.ordinal() ? server.getPreferredNetworkInterface().getName() - : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS.ordinal() ? "" + server.getNumOfCPUs() - //: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE.ordinal() ? "" + server.getCpuUsage() - : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY.ordinal() ? "" + NumberUtil.formatNumber((server.getTotalMemory() / 1024)) - //: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE.ordinal() ? "" + server.getMemoryInUse() - : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_FREE_SPACE.ordinal() ? NumberUtil.formatNumber((server.getFreeDiskSpace() / 1024)) - : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES.ordinal() ? server.getIpAddressesAsString() - : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE.ordinal() ? NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)) - : "Invalid"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ICommandIds.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ICommandIds.java deleted file mode 100644 index 36cfd9dc..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ICommandIds.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -/** - * Interface defining the application's command IDs. - * Key bindings can be defined for specific commands. - * To associate an action with a command, use IAction.setActionDefinitionId(commandId). - * - * @see org.eclipse.jface.action.IAction#setActionDefinitionId(String) - */ -public interface ICommandIds { - - public static final String CMD_OPEN = "com.gluster.storage.management.console.open"; - public static final String CMD_OPEN_MESSAGE = "com.gluster.storage.management.console.openMessage"; - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IEntityListener.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IEntityListener.java deleted file mode 100644 index 91d90afe..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IEntityListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import com.gluster.storage.management.core.model.Entity; - -/** - * Any class that is interested in changes to entities in application scope should implement this interface and register - * with the application using {@link Application#addEntityListener(IEntityListener)} - * - * @author root - * - */ -public interface IEntityListener { - /** - * This method is called whenever any attribute of an entity in application scope changes - * @param entity Entity that has changed - * @param paremeters List of attribute names that have changed. This can be null. - */ - public void entityChanged(Entity entity, String[] paremeters); -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java deleted file mode 100644 index cecdb002..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/IImageKeys.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -public interface IImageKeys { - - - public static final String CLUSTER_16x16 = "icons/tango/16x16/cluster.png"; - - public static final String VOLUMES_16x16 = "icons/tango/16x16/volumes.png"; - public static final String VOLUME_16x16 = "icons/tango/16x16/volume.png"; - public static final String CREATE_VOLUME_32x32 = "icons/tango/32x32/create-volume.png"; - public static final String START_VOLUME_32x32 = "icons/tango/32x32/start-volume.png"; - public static final String STOP_VOLUME_32x32 = "icons/tango/32x32/stop-volume.png"; - public static final String RESET_VOLUME_OPTIONS_32x32 = "icons/tango/32x32/reset-volume-option.png"; - public static final String VOLUME_OPTIONS_16x16 = "icons/tango/16x16/volume-options.png"; - public static final String CREATE_VOLUME_48x48 = "icons/tango/48x48/create-volume.png"; - public static final String REMOVE_VOLUME_32x32 = "icons/tango/32x32/remove-volume.png"; - public static final String VOLUME_REBALANCE_32x32 = "icons/tango/32x32/volume-rebalance.png"; - public static final String VOLUME_REBALANCE_22x22 = "icons/tango/22x22/volume-rebalance.png"; - public static final String BRICK_MIGRATE_32x32 = "icons/tango/32x32/migrate-brick.png"; - public static final String BRICK_MIGRATE_22x22 = "icons/tango/22x22/migrate-brick.png"; - public static final String ADD_BRICK_32x32 = "icons/tango/32x32/add-brick.png"; - public static final String REMOVE_BRICK_32x32 = "icons/tango/32x32/remove-brick.png"; - public static final String BRICK_OFFLINE_22x22 = "icons/tango/22x22/offline-brick.png"; - public static final String BRICKS_16x16 = "icons/tango/16x16/bricks.png"; - public static final String BRICK_ONLINE_16x16 = "icons/tango/16x16/online-brick.png"; - public static final String BRICK_OFFLINE_16x16 = "icons/tango/16x16/offline-brick.png"; - public static final String VOLUME_OFFLINE_22x22 = "icons/tango/22x22/offline-volume.png"; - - public static final String SERVERS_16x16 = "icons/tango/16x16/servers.png"; - public static final String SERVER_16x16 = "icons/tango/16x16/server.png"; - public static final String SERVER_WARNING_22x22 = "icons/tango/22x22/server-warning.png"; - public static final String MEMORY_USAGE_ALERT_22x22 = "icons/tango/22x22/high-memory-usage.png"; - public static final String SERVER_OFFLINE_22x22 = "icons/tango/22x22/offline-server.png"; - public static final String ADD_SERVER_32x32 = "icons/tango/32x32/add-server.png"; - public static final String ADD_SERVER_48x48 = "icons/tango/48x48/add-server.png"; - public static final String REMOVE_SERVER_32x32 = "icons/tango/32x32/remove-server.png"; - - public static final String DISK_16x16 = "icons/tango/16x16/disk.png"; - public static final String DISKS_16x16 = "icons/tango/16x16/disk.png"; - public static final String DISK_UNINITIALIZED_16x16 = "icons/tango/16x16/disk-uninitialized.png"; - public static final String IO_ERROR_16x16 = "icons/tango/16x16/disk-error.png"; - public static final String DISK_AVAILABLE_16x16 = "icons/tango/16x16/disk-available.png"; - public static final String DISK_INITIALIZING_16x16 = "icons/tango/16x16/disk-initialisation.png"; - public static final String DISK_INITIALIZING_22x22 = "icons/tango/22x22/disk-initialisation.png"; - public static final String DISK_IN_USE_16x16 = "icons/tango/16x16/disk-inuse.png"; - public static final String LOW_DISK_SPACE_22x22 = "icons/tango/22x22/low-diskspace.png"; - - public static final String STATUS_OFFLINE_16x16 = "icons/tango/16x16/status-offline.png"; - public static final String STATUS_ONLINE_16x16 = "icons/tango/16x16/status-online.png"; - - public static final String HELP_16x16 = "icons/tango/16x16/question.png"; - public static final String SEARCH_22x22 = "icons/tango/22x22/system-search.png"; - public static final String ARROW_UP_16x16 = "icons/tango/16x16/arrow-up.png"; - public static final String ARROW_DOWN_16x16 = "icons/tango/16x16/arrow-down.png"; - - public static final String DOWNLOAD_LOG_32x32 = "icons/tango/32x32/download-log.png"; - - - public static final String PAUSE_TASK_32x32 = "icons/tango/32x32/pause.png"; - public static final String RESUME_TASK_32x32 = "icons/tango/32x32/start.png"; - public static final String STOP_TASK_32x32 = "icons/tango/32x32/stop.png"; - public static final String CLEAR_TASK_32x32 = "icons/tango/32x32/clear-task.png"; - public static final String COMMIT_TASK_32x32 = "icons/tango/32x32/commit-task.png"; - public static final String PAUSE_TASK_16x16 = "icons/tango/16x16/pause.png"; - public static final String RESUME_TASK_16x16 = "icons/tango/16x16/start.png"; - public static final String STOP_TASK_16x16 = "icons/tango/16x16/stop.png"; - public static final String CLEAR_TASK_16x16 = "icons/tango/16x16/close_task.png"; - public static final String COMPLETED_TASK_16x16 = "icons/tango/16x16/task-completed.png"; - - public static final String OVERLAY_OFFLINE_8x8 = "icons/tango/8x8/offline.png"; - public static final String OVERLAY_ONLINE_8x8 = "icons/tango/8x8/online.png"; - public static final String OVERLAY_STAR_8x8 = "icons/tango/8x8/star.png"; - - public static final String SPLASH_IMAGE = "splash.bmp"; - public static final String DIALOG_SPLASH_IMAGE = "images/splash-dialog.bmp"; - - public static final String GAUGE_SMALL = "images/gauge_small.png"; - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java deleted file mode 100644 index 54ed5349..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - - -import com.gluster.storage.management.console.views.GlusterServerSummaryView.NETWORK_INTERFACE_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.NetworkInterface; - -public class NetworkInterfaceTableLabelProvider extends TableLabelProviderAdapter { - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof NetworkInterface)) { - return null; - } - - NetworkInterface networkInterface = (NetworkInterface) element; - String columnText = (columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.INTERFACE.ordinal() ? networkInterface.getName() - : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.MODEL.ordinal() ? networkInterface.getModel() - : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.SPEED.ordinal() ? networkInterface.getSpeed() - : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.IP_ADDRESS.ordinal() ? networkInterface.getIpAddress() - : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.NETMASK.ordinal() ? networkInterface.getNetMask() - : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.GATEWAY.ordinal() ? networkInterface.getDefaultGateway() - : "Invalid"); - return ((columnText == null || columnText.trim().equals("")) ? CoreConstants.NA : columnText); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Perspective.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Perspective.java deleted file mode 100644 index 9593bb88..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/Perspective.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IPerspectiveFactory; - -public class Perspective implements IPerspectiveFactory { - - /** - * The ID of the perspective as specified in the extension. - */ - public static final String ID = Perspective.class.getName(); - - public void createInitialLayout(IPageLayout layout) { - layout.setEditorAreaVisible(false); - //layout.addStandaloneView(ClusterView.ID, false, IPageLayout.LEFT, 0.30f, layout.getEditorArea()); - //layout.addStandaloneView(DetailsView.ID, false, IPageLayout.RIGHT, 0.70f, layout.getEditorArea()); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerDiskTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerDiskTableLabelProvider.java deleted file mode 100644 index d733701c..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerDiskTableLabelProvider.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.swt.graphics.Image; - -import static com.gluster.storage.management.console.DeviceTableLabelProvider.DEVICE_COLUMN_INDICES; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.ServerDisksPage.SERVER_DISK_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Partition; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter { - private GUIHelper guiHelper = GUIHelper.getInstance(); - private GlusterDataModelManager glusterDataModelManager = GlusterDataModelManager.getInstance(); - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (!(element instanceof Device)) { - return null; - } - - Device device = (Device) element; - if (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { - DEVICE_STATUS status = device.getStatus(); - - if (status == null) { - return null; - } - - if(element instanceof Disk && ((Disk)element).hasPartitions()) { - // disk has partitions. so don't show status image at disk level. - return null; - } - - switch (status) { - case INITIALIZED: - if(glusterDataModelManager.isDeviceUsed(device)) { - return guiHelper.getImage(IImageKeys.DISK_IN_USE_16x16); - } else { - return guiHelper.getImage(IImageKeys.DISK_AVAILABLE_16x16); - } - case IO_ERROR: - return guiHelper.getImage(IImageKeys.IO_ERROR_16x16); - case UNINITIALIZED: - return guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED_16x16); - case INITIALIZING: - return guiHelper.getImage(IImageKeys.DISK_INITIALIZING_16x16); - default: - throw new GlusterRuntimeException("Invalid disk status [" + status + "]"); - } - } - - return null; - } - - private String getDeviceFreeSpace(Device device) { - if (device.hasErrors() || device.isUninitialized()) { - return "NA"; - } else { - return NumberUtil.formatNumber((device.getFreeSpace() / 1024)); - } - } - - private String getTotalDeviceSpace(Device device) { - if (device.hasErrors() || device.isUninitialized()) { - return "NA"; - } else { - return NumberUtil.formatNumber((device.getSpace() / 1024)); - } - } - - public String getColumnText(Object element, int columnIndex) { - Device device = (Device) element; - if (columnIndex == DEVICE_COLUMN_INDICES.DISK.ordinal()) { - // show value in "disk" column only if it's a disk - if (device instanceof Disk) { - return device.getName(); - } else { - return ""; - } - } - - if(element instanceof Disk && ((Disk)element).hasPartitions()) { - // disk has partitions. so don't show any other details - return ""; - } - - if (columnIndex == DEVICE_COLUMN_INDICES.FREE_SPACE.ordinal()) { - return "" + getDeviceFreeSpace(device); - } else if (columnIndex == DEVICE_COLUMN_INDICES.SPACE_IN_USE.ordinal()) { - return "" + getTotalDeviceSpace(device); - } else if (columnIndex == DEVICE_COLUMN_INDICES.PARTITION.ordinal()) { - if (device instanceof Partition) { - return device.getName(); - } else { - return ""; - } - } else if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { - if(device.isUninitialized()) { - return ""; - } - if(glusterDataModelManager.isDeviceUsed(device)) { - return "In Use"; - } else { - return device.getStatusStr(); - } - } else { - return ""; - } - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerTableLabelProvider.java deleted file mode 100644 index eccf67ec..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ServerTableLabelProvider.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.ServersPage.SERVER_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class ServerTableLabelProvider extends TableLabelProviderAdapter { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Server)) { - return null; - } - - Server server = (Server) element; - return (columnIndex == SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() ? server.getName() - : columnIndex == SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES.ordinal() ? server.getIpAddressesAsString() - : columnIndex == SERVER_TABLE_COLUMN_INDICES.NUM_OF_DISKS.ordinal() ? "" - + server.getNumOfDisks() : columnIndex == SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE - .ordinal() ? NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)) - // : columnIndex == SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS.ordinal() ? "" + - // server.getNumOfCPUs() - // : columnIndex == SERVER_TABLE_COLUMN_INDICES.CPU_USAGE.ordinal() ? "" + server.getCpuUsage() - // : columnIndex == SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY.ordinal() ? "" + - // server.getTotalMemory() - // : columnIndex == SERVER_TABLE_COLUMN_INDICES.MEMORY_IN_USE.ordinal() ? "" + - // server.getMemoryInUse() - // : columnIndex == SERVER_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE.ordinal() ? "" + - // server.getDiskSpaceInUse() - : "Invalid"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TableLabelProviderAdapter.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TableLabelProviderAdapter.java deleted file mode 100644 index 5c527082..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TableLabelProviderAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.swt.graphics.Image; - -public class TableLabelProviderAdapter implements ITableLabelProvider { - - @Override - public void addListener(ILabelProviderListener listener) { - // do nothing - - } - - @Override - public void dispose() { - // do nothing - } - - @Override - public boolean isLabelProperty(Object element, String property) { - return true; - } - - @Override - public void removeListener(ILabelProviderListener listener) { - // do nothing - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - return null; - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TasksTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TasksTableLabelProvider.java deleted file mode 100644 index 66fbefd3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/TasksTableLabelProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * TasksTableLabelProvider.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console; - -import org.eclipse.swt.graphics.Image; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.TasksPage.TASK_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; - - -public class TasksTableLabelProvider extends TableLabelProviderAdapter { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - public Image getColumnImage(Object element, int columnIndex) { - - if (!(element instanceof TaskInfo)) { - return null; - } - - TaskInfo taskInfo = (TaskInfo) element; - if (columnIndex == TASK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { - int statusCode = taskInfo.getStatus().getCode(); - - switch (statusCode) { - case Status.STATUS_CODE_SUCCESS: - return guiHelper.getImage(IImageKeys.COMPLETED_TASK_16x16); - case Status.STATUS_CODE_PAUSE: - return guiHelper.getImage(IImageKeys.PAUSE_TASK_16x16); - case Status.STATUS_CODE_RUNNING: - return guiHelper.getImage(IImageKeys.RESUME_TASK_16x16); - case Status.STATUS_CODE_FAILURE: - return guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16); - default: - break; - } - } - - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof TaskInfo)) { - return null; - } - - TaskInfo taskInfo = (TaskInfo) element; - return (columnIndex == TASK_TABLE_COLUMN_INDICES.TASK.ordinal()) ? taskInfo.getDescription().trim() : taskInfo.getStatus().getMessage().trim(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeLogTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeLogTableLabelProvider.java deleted file mode 100644 index 07c5cc77..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeLogTableLabelProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - - -import com.gluster.storage.management.console.views.pages.VolumeLogsPage.LOG_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.VolumeLogMessage; -import com.gluster.storage.management.core.utils.DateUtil; - -public class VolumeLogTableLabelProvider extends TableLabelProviderAdapter { - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof VolumeLogMessage)) { - return null; - } - - VolumeLogMessage logMessage = (VolumeLogMessage) element; - return (columnIndex == LOG_TABLE_COLUMN_INDICES.DATE.ordinal() ? DateUtil.formatDate(logMessage.getTimestamp()) - : columnIndex == LOG_TABLE_COLUMN_INDICES.TIME.ordinal() ? DateUtil.formatTime(logMessage.getTimestamp()) - : columnIndex == LOG_TABLE_COLUMN_INDICES.BRICK.ordinal() ? logMessage.getBrick() - : columnIndex == LOG_TABLE_COLUMN_INDICES.SEVERITY.ordinal() ? "" + logMessage.getSeverity() - : columnIndex == LOG_TABLE_COLUMN_INDICES.MESSAGE.ordinal() ? logMessage.getMessage() : "Invalid"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsContentProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsContentProvider.java deleted file mode 100644 index 1289f0f4..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsContentProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import com.gluster.storage.management.core.model.VolumeOptions; - -/** - * @author root - * - */ -public class VolumeOptionsContentProvider implements IStructuredContentProvider { - - @Override - public void dispose() { - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - @Override - public Object[] getElements(Object inputElement) { - if (inputElement instanceof VolumeOptions) { - return ((VolumeOptions) inputElement).getOptions().toArray(); - } - return null; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java deleted file mode 100644 index 5a1089de..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import java.util.Map.Entry; - -import com.gluster.storage.management.console.views.pages.VolumeOptionsPage.OPTIONS_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.VolumeOption; - -public class VolumeOptionsTableLabelProvider extends TableLabelProviderAdapter { - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Entry)) { - return null; - } - - VolumeOption option = (VolumeOption)element; - return (columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal() ? option.getKey() - : columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal() ? option.getValue() - : "Invalid"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeTableLabelProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeTableLabelProvider.java deleted file mode 100644 index 908c23d5..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/VolumeTableLabelProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.swt.graphics.Image; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.VolumesPage.VOLUME_TABLE_COLUMN_INDICES; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; - -public class VolumeTableLabelProvider implements ITableLabelProvider { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - public void addListener(ILabelProviderListener listener) { - } - - @Override - public void dispose() { - } - - @Override - public boolean isLabelProperty(Object element, String property) { - return false; - } - - @Override - public void removeListener(ILabelProviderListener listener) { - } - - @Override - public Image getColumnImage(Object element, int columnIndex) { - if (!(element instanceof Volume)) { - return null; - } - - Volume volume = (Volume) element; - if(columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS.ordinal()) { - VOLUME_STATUS status = volume.getStatus(); - if(status == VOLUME_STATUS.ONLINE) { - return guiHelper.getImage(IImageKeys.STATUS_ONLINE_16x16); - } else { - return guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16); - } - } - - return null; - } - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Volume)) { - return null; - } - - Volume volume = (Volume) element; - return (columnIndex == VOLUME_TABLE_COLUMN_INDICES.NAME.ordinal() ? volume.getName() - : columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_TYPE.ordinal() ? volume.getVolumeTypeStr() - : columnIndex == VOLUME_TABLE_COLUMN_INDICES.TRANSPORT_TYPE.ordinal() ? volume.getTransportTypeStr() - : columnIndex == VOLUME_TABLE_COLUMN_INDICES.NUM_OF_BRICKS.ordinal() ? "" + volume.getNumOfBricks() - : columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS.ordinal() ? volume.getStatusStr() : "Invalid"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java deleted file mode 100644 index 29481286..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractActionDelegate.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.internal.UIPlugin; - -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.model.Entity; - -/** - * All action delegates in the application should extend from this class. It provides common functionality of grabbing - * the Window object on initialization and extracting the selected entity in case of selection change on the navigation - * tree. - */ -@SuppressWarnings("restriction") -public abstract class AbstractActionDelegate implements IWorkbenchWindowActionDelegate { - protected IWorkbenchWindow window; - protected static final GlusterLogger logger = GlusterLogger.getInstance(); - - // the latest selected entity - protected Entity selectedEntity; - - @Override - public void run(final IAction action) { - try { - performAction(action); - } catch (final Exception e) { - final String actionDesc = action.getDescription(); - logger.error("Exception while running action [" + actionDesc + "]", e); - showErrorDialog(actionDesc, e.getMessage()); - } - } - - abstract protected void performAction(final IAction action); - - @Override - public void selectionChanged(IAction action, ISelection selection) { - if (selection instanceof StructuredSelection) { - Entity selectedEntity = (Entity) ((StructuredSelection) selection).getFirstElement(); - - if (this.selectedEntity == selectedEntity) { - // entity selection has not changed. do nothing. - return; - } - - if (selectedEntity != null) { - this.selectedEntity = selectedEntity; - } - } - } - - @Override - public void init(IWorkbenchWindow window) { - this.window = window; - } - - protected Shell getShell() { - return getWindow().getShell(); - } - - protected IWorkbenchWindow getWindow() { - return window == null ? UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow() : window; - } - - protected void showInfoDialog(final String title, final String message) { - MessageDialog.openInformation(getShell(), title, message); - } - - protected void showWarningDialog(final String title, final String message) { - MessageDialog.openWarning(getShell(), title, message); - } - - protected void showErrorDialog(final String title, final String message) { - MessageDialog.openError(getShell(), title, message); - } - - protected boolean showConfirmDialog(final String title, final String message) { - return MessageDialog.openQuestion(getShell(), title, message); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java deleted file mode 100644 index 1669d273..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; - -import com.gluster.storage.management.console.ConsoleConstants; - -/** - * Any action that can potentially run for a long time, and supports monitoring and progress dialog should extend from - * this class - */ -public abstract class AbstractMonitoredActionDelegate extends AbstractActionDelegate { - /* (non-Javadoc) - * @see com.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) - */ - @Override - protected void performAction(final IAction action) { - try { - new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() { - - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - performAction(action, monitor); - } - }); - } catch (Exception e) { - String errMsg = "Exception while performing action [" + action.getDescription() + "] : [" + e.getMessage() + "]"; - logger.error(errMsg, e); - showErrorDialog(ConsoleConstants.CONSOLE_TITLE, errMsg); - } - } - - abstract void performAction(IAction action, IProgressMonitor monitor); -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ActionConstants.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ActionConstants.java deleted file mode 100644 index a1b70ad0..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ActionConstants.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -public class ActionConstants { - public static final String ACTION_SET_CLUSTER = "com.gluster.storage.management.console.actionsets.gluster"; - public static final String ACTION_SET_VOLUMES = "com.gluster.storage.management.console.actionsets.volumes"; - public static final String ACTION_SET_VOLUME = "com.gluster.storage.management.console.actionsets.volume"; - public static final String ACTION_SET_DISKS = "com.gluster.storage.management.console.actionsets.disks"; - public static final String ACTION_SET_DISK = "com.gluster.storage.management.console.actionsets.disk"; - public static final String ACTION_SET_GLUSTER_SERVERS = "com.gluster.storage.management.console.actionsets.glusterservers"; - public static final String ACTION_SET_GLUSTER_SERVER = "com.gluster.storage.management.console.actionsets.glusterserver"; - public static final String ACTION_SET_DISCOVERED_SERVERS = "com.gluster.storage.management.console.actionsets.serversdiscovered"; - public static final String ACTION_SET_DISCOVERED_SERVER = "com.gluster.storage.management.console.actionsets.serverdiscovered"; - public static final String ACTION_SET_TASK = "com.gluster.storage.management.console.actionsets.task"; - public static final String ACTION_SET_EDIT = "com.gluster.storage.management.console.actionsets.edit"; - - public static final String COMMAND_CREATE_VOLUME = "com.gluster.storage.management.console.commands.CreateVolume"; - public static final String COMMAND_ADD_SERVER = "com.gluster.storage.management.console.commands.AddServer"; -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddBrickAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddBrickAction.java deleted file mode 100644 index 479353ff..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddBrickAction.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * AddBrickAction.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ - -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardDialog; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.dialogs.AddBrickWizard; -import com.gluster.storage.management.core.model.Volume; - -public class AddBrickAction extends AbstractActionDelegate { - private Volume volume; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - public void dispose() { - window = null; - } - - @Override - protected void performAction(IAction action) { - // TODO: open a dialog box - // MessageDialog.openInformation(getShell(), "Action captured", action.getDescription() + "\n" + - // volume.getName()); - AddBrickWizard wizard = new AddBrickWizard(volume); // Also add single page - - WizardDialog dialog = new WizardDialog(getShell(), wizard); - dialog.create(); - dialog.getShell().setSize(1024, 600); - dialog.open(); - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - - if (selectedEntity instanceof Volume) { - this.volume = (Volume) selectedEntity; - // action.setEnabled(volume.getStatus() == VOLUME_STATUS.ONLINE); - } - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddServerAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddServerAction.java deleted file mode 100644 index c3b24eba..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AddServerAction.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.net.URI; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; - -import com.gluster.storage.management.client.GlusterServersClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.dialogs.ServerAdditionDialog; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Server; - -public class AddServerAction extends AbstractMonitoredActionDelegate { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - protected void performAction(final IAction action, IProgressMonitor monitor) { - GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - GlusterServersClient glusterServersClient = new GlusterServersClient(); - - Set selectedServers = GUIHelper.getInstance().getSelectedEntities(getWindow(), Server.class); - Set successServers = new HashSet(); - Set partSuccessServers = new HashSet(); - String errMsg = ""; - String partErrMsg = ""; - - if (selectedServers.isEmpty()) { - monitor.beginTask("Starting Manual Server Addition", 1); - addServerManually(); - monitor.worked(1); - monitor.done(); - return; - } - - monitor.beginTask("Adding Selected Servers...", selectedServers.size()); - for (Server server : selectedServers) { - if(monitor.isCanceled()) { - break; - } - - monitor.setTaskName("Adding server [" + server.getName() + "]..."); - - try { - URI newServerURI = glusterServersClient.addServer(server.getName()); - modelManager.addGlusterServer(glusterServersClient.getGlusterServer(newServerURI)); - successServers.add(server); - } catch (Exception e) { - if (!errMsg.isEmpty()) { - errMsg += CoreConstants.NEWLINE; - } - errMsg += "Server " + server.getName() + ". Error: [" + e.getMessage() + "]"; - } - monitor.worked(1); - } - monitor.done(); - - showStatusMessage(action.getDescription(), selectedServers, successServers, partSuccessServers, errMsg, - partErrMsg); - } - - private void addServerManually() { - try { - // To open a dialog for server addition - ServerAdditionDialog dialog = new ServerAdditionDialog(getShell()); - dialog.open(); - } catch (Exception e) { - logger.error("Error in Manual server addition", e); - showErrorDialog("Add server", "Add server failed! [" + e.getMessage() + "]"); - } - } - - private void showStatusMessage(String dialogTitle, Set selectedServers, Set successServers, - Set partSuccessServers, String errMsg, String partErrMsg) { - if (successServers.size() == selectedServers.size()) { - if (selectedServers.size() == 1) { - showInfoDialog(dialogTitle, "Server [" + selectedServers.iterator().next() + "] added successfully!"); - } else { - showInfoDialog(dialogTitle, "Following servers added successfully!" + CoreConstants.NEWLINE - + selectedServers); - } - return; - } - - String finalMsg = ""; - if (successServers.size() == 0 && partSuccessServers.size() == 0) { - finalMsg = "Server Addition Failed! Error(s):" + CoreConstants.NEWLINE + errMsg; - } else { - finalMsg = (successServers.isEmpty() ? "" : "Following servers added successfully : " - + CoreConstants.NEWLINE + successServers + CoreConstants.NEWLINE) - + (partSuccessServers.isEmpty() ? "" : "Following servers were added to cluster, but with some errors: " - + CoreConstants.NEWLINE + partErrMsg + CoreConstants.NEWLINE) - + (errMsg.isEmpty() ? "" : CoreConstants.NEWLINE - + "Following errors occurred on other selected servers: " + CoreConstants.NEWLINE + errMsg); - } - showErrorDialog(dialogTitle, finalMsg); - } - - @Override - public void dispose() { - System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ChangePasswordAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ChangePasswordAction.java deleted file mode 100644 index a06f13b4..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ChangePasswordAction.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -import com.gluster.storage.management.console.dialogs.ChangePasswordDialog; - -public class ChangePasswordAction extends AbstractActionDelegate { - - @Override - protected void performAction(IAction action) { - try { - // To open a dialog for change password - ChangePasswordDialog dialog = new ChangePasswordDialog(getShell()); - dialog.open(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void dispose() { - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ClearTaskAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ClearTaskAction.java deleted file mode 100644 index 7cb9a873..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ClearTaskAction.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; - -public class ClearTaskAction extends AbstractActionDelegate { - private TaskInfo taskInfo; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - - try { - new TasksClient().deleteTask(taskInfo.getName()); // taskId - modelManager.removeTask(taskInfo); - action.setEnabled(false); // TODO disable other task buttons - } catch (Exception e) { - showErrorDialog(actionDesc, - "Task [" + taskInfo.getName() + "] could not be cleared! Error: [" + e.getMessage() + "]"); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - action.setEnabled(false); - if (selectedEntity instanceof TaskInfo) { - taskInfo = (TaskInfo) selectedEntity; - action.setEnabled(taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS - || taskInfo.getStatus().getCode() == Status.STATUS_CODE_FAILURE); - } else { - action.setEnabled(false); - } - } - - @Override - public void dispose() { - - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CommitTaskAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CommitTaskAction.java deleted file mode 100644 index e2e1e12c..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CommitTaskAction.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gluster.storage.management.console.actions; - - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.model.Volume; - -public class CommitTaskAction extends AbstractActionDelegate { - private TaskInfo taskInfo; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - try { - new TasksClient().commitTask(taskInfo.getName()); - taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_SUCCESS, "Committed"))); - modelManager.removeTask(taskInfo); - showInfoDialog(actionDesc, "Commit successful"); - } catch (Exception e) { - showErrorDialog(actionDesc, - "Task [" + taskInfo.getName() + "] could not be Committed! Error: [" + e.getMessage() + "]"); - return; // Prevent to update model - } - - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { - @Override - public void run() { - try { - String volumeName = taskInfo.getReference().split("#")[0]; //Extract volume name from reference - Volume oldVolume = modelManager.getModel().getCluster().getVolume(volumeName); - Volume newVolume = (new VolumesClient()).getVolume(volumeName); - - modelManager.volumeChanged(oldVolume, newVolume); - } catch (Exception e) { - String errMsg = "Volume brick update failed! [" + e.getMessage() + "]"; - logger.error(errMsg, e); - showInfoDialog(actionDesc, errMsg); - } - } - }); - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - action.setEnabled(false); - if (selectedEntity instanceof TaskInfo) { - taskInfo = (TaskInfo) selectedEntity; - action.setEnabled(taskInfo.getCommitSupported() - && taskInfo.getStatus().getCode() == Status.STATUS_CODE_COMMIT_PENDING); - } - } - - public void updateVolume(String volumeName) { - - } - - @Override - public void dispose() { - - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CreateVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CreateVolumeAction.java deleted file mode 100644 index f8590171..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/CreateVolumeAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; - -import com.gluster.storage.management.console.dialogs.CreateVolumeWizard; - -public class CreateVolumeAction extends AbstractActionDelegate { - @Override - protected void performAction(IAction action) { - CreateVolumeWizard wizard = new CreateVolumeWizard(); - - WizardDialog dialog = new WizardDialog(getShell(), wizard) { - @Override - protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { - Button button = super.createButton(parent, id, label, defaultButton); - if (id == IDialogConstants.FINISH_ID) { - button.setText("&Create"); - } - return button; - } - }; - dialog.create(); - dialog.getShell().setSize(510, 620); - dialog.open(); - } - - @Override - public void dispose() { - window = null; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java deleted file mode 100644 index ba2ef5c7..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; - -public class DeleteVolumeAction extends AbstractMonitoredActionDelegate { - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private List selectedVolumes = new ArrayList(); - private List selectedVolumeNames = new ArrayList(); - private List onlineVolumeNames = new ArrayList(); - private List deletedVolumeNames = new ArrayList(); - private List failedVolumes = new ArrayList(); - - @Override - protected void performAction(final IAction action, IProgressMonitor monitor) { - final String actionDesc = action.getDescription(); - - collectVolumeNames(); - String warningMessage; - List cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); - List offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); - // One or more servers are offline, Show warning if cifs is enabled - if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { - Integer userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), - "Performing CIFS updates when one or more servers are offline can trigger " - + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE - + "Are you sure you want to continue?", MessageDialog.QUESTION, - new String[] { "No", "Yes" }, -1).open(); - if (userAction != 1) { - return; // Do not delete volume services - } - } - - if (onlineVolumeNames.size() > 0) { // Getting confirmation for stop and delete - warningMessage = "Following volume(s) " + onlineVolumeNames + " are online, " + CoreConstants.NEWLINE - + "Are you sure to continue?" + CoreConstants.NEWLINE + selectedVolumeNames; - } else { - warningMessage = "Are you sure to delete the volumes " + selectedVolumeNames + " ?"; - } - - final Integer deleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance() - .getImage(IImageKeys.VOLUME_16x16), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel", - "Delete volume and data", "Delete volume, keep data" }, -1).open(); - if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) - return; - } - - String errorMessage = deleteVolumes(selectedVolumes, deleteOption, monitor); - - // Display the success or failure info - if (deletedVolumeNames.size() == 0) { // No volume(s) deleted successfully - showErrorDialog(actionDesc, "Volume(s) could not be deleted! " + CoreConstants.NEWLINE + errorMessage); - } else { - String info = "Volume(s) " + deletedVolumeNames + " deleted successfully!"; - if (!failedVolumes.isEmpty()) { - info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes - + " could not be deleted!" + CoreConstants.NEWLINE + errorMessage; - } - - if (selectedVolumes.size() == deletedVolumeNames.size()) { - showInfoDialog(actionDesc, info); - } else { - showWarningDialog(actionDesc, info); - } - } - } - - private String deleteVolumes(List volumes, final Integer deleteOption, IProgressMonitor monitor) { - deletedVolumeNames.clear(); - failedVolumes.clear(); - VolumesClient vc = new VolumesClient(); - boolean confirmDeleteDir = (deleteOption == 1) ? true : false; - - String errorMessage = ""; - - // To calculate the total work we need to sum volumes size + online volumes (because we treat stop and delete as - // separate steps) - List onlineVolumes = getOnlineVolumes(volumes); - monitor.beginTask("Deleting Selected Volumes...", volumes.size() + onlineVolumes.size()); - - // Deletion of a volume results in changes to the model, and ultimately updates the "selectedVolumes" list, - // over which we are iterating, thus resulting in ConcurrentModificationException. To avoid this, we iterate - // over an array obtained from the list. - for (Volume volume : volumes.toArray(new Volume[0])) { - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { // stop if online volume - monitor.setTaskName("Stopping volume [" + volume.getName() + "]"); - try { - vc.stopVolume(volume.getName(), false); - } catch (Exception e1) { - // try again with force = true - try { - vc.stopVolume(volume.getName(), true); - } catch(Exception e2) { - // force stop also failed. - // Mark as deletion failed, append error message. - errorMessage += CoreConstants.NEWLINE + "Stop [" + volume.getName() + "] : [" + e2.getMessage() - + "]"; - failedVolumes.add(volume); - // since we are not going to perform delete on this volume, - // mark the deletion task as worked - monitor.worked(1); - - // continue to next volume without trying to delete this one - continue; - } - } finally { - // worked for "stop" operation - monitor.worked(1); - } - } - - monitor.setTaskName("Deleting volume [" + volume.getName() + "]"); - try { - vc.deleteVolume(volume.getName(), confirmDeleteDir); - modelManager.deleteVolume(volume); - deletedVolumeNames.add(volume.getName()); - } catch (Exception e) { - // Volume delete succeeded and post delete operation (directory cleanup, CIFS etc) may fail - if (vc.volumeExists(volume.getName())) { - errorMessage += CoreConstants.NEWLINE + "Delete [" + volume.getName() + "] : [" + e.getMessage() + "]"; - failedVolumes.add(volume); - } else { - errorMessage += CoreConstants.NEWLINE + "Volume [" + volume.getName() - + "] deleted, but following error occured: [" + e.getMessage() + "]"; - modelManager.deleteVolume(volume); - deletedVolumeNames.add(volume.getName()); - } - } finally { - monitor.worked(1); - } - } - monitor.done(); - return errorMessage; - } - - private List getOnlineVolumes(List volumes) { - List onlineVolumes = new ArrayList(); - for (Volume volume : volumes) { - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - onlineVolumes.add(volume); - } - } - return onlineVolumes; - } - - private void collectVolumeNames() { - selectedVolumeNames.clear(); - onlineVolumeNames.clear(); - for (Volume volume : selectedVolumes) { - selectedVolumeNames.add(volume.getName()); - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - onlineVolumeNames.add(volume.getName()); - } - } - } - - @Override - public void dispose() { - System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - Set selectedVolumeSet = GUIHelper.getInstance().getSelectedEntities(getWindow(), Volume.class); - selectedVolumes.clear(); - if (selectedVolumeSet == null || selectedVolumeSet.isEmpty()) { - super.selectionChanged(action, selection); - if (selectedEntity instanceof Volume) { - selectedVolumes.add((Volume) selectedEntity); - } - } else { - selectedVolumes.addAll(selectedVolumeSet); //TODO reverse the collection to maintain the selected order - } - - action.setEnabled( (selectedVolumes.size() > 0) ); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java deleted file mode 100644 index 81abb01f..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Volume; - -/** - * - */ -public class DownloadVolumeLogsAction extends AbstractActionDelegate { - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - public void dispose() { - } - - @Override - protected void performAction(IAction action) { - final VolumesClient client = new VolumesClient(); - Volume volume = guiHelper.getSelectedEntity(getWindow(), Volume.class); - - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - dialog.setFilterNames(new String[] { "GZipped Tar (*.tar.gz)" }); - dialog.setFilterExtensions(new String[] { "*.tar.gz" }); - String filePath = dialog.open(); - - if (filePath == null) { - return; - } - - String title = "Download Volume Logs [" + volume.getName() + "]"; - try { - client.downloadLogs(volume.getName(), filePath); - showInfoDialog(title, "Volume logs downloaded successfully to [" + filePath + "]"); - } catch (Exception e) { - showErrorDialog(title, e.getMessage()); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/EditVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/EditVolumeAction.java deleted file mode 100644 index 610cbdf6..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/EditVolumeAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -public class EditVolumeAction extends AbstractActionDelegate { - @Override - protected void performAction(IAction action) { - System.out.println("Running [" + this.getClass().getSimpleName() + "]"); - } - - @Override - public void dispose() { - System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java deleted file mode 100644 index 51cf49c1..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ExportSshKeysAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * ExportSshKeysAction.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; - -import com.gluster.storage.management.client.KeysClient; - -/** - * @author root - * - */ -public class ExportSshKeysAction extends AbstractActionDelegate { - - @Override - protected void performAction(IAction action) { - final KeysClient client = new KeysClient(); - FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - dialog.setFilterNames(new String[] { "Tar (*.tar)" }); - dialog.setFilterExtensions(new String[] { "*.tar" }); - String filePath = dialog.open(); - - if (filePath == null) { - return; - } - - String title = "Export SSH Keys"; - try { - client.exportSshKeys(filePath); - showInfoDialog(title, "SSH keys exported successfully to [" + filePath + "]"); - } catch (Exception e) { - showErrorDialog(title, e.getMessage()); - } - } - - - @Override - public void dispose() { - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java deleted file mode 100644 index 9201aadb..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import java.util.Set; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchPart; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.VolumeBricksView; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.utils.StringUtil; - -public class ForceStartVolumeAction extends AbstractActionDelegate { - - private Volume volume; - private GUIHelper guiHelper = GUIHelper.getInstance(); - private Set bricks; - - @Override - public void dispose() { - - } - - @Override - protected void performAction(IAction action) { - // volume brick service will be started, do you want to continue? - final String actionDesc = action.getDescription(); - boolean confirmed = showConfirmDialog( - actionDesc, - "The offline Bricks [" + StringUtil.collectionToString(bricks, ", ") + "] of Volume [" - + volume.getName() + "] will be started. Are you sure you want to continue?"); - if (!confirmed) { - return; - } - try { - new VolumesClient().startVolume(volume.getName(), true); - showInfoDialog(actionDesc, "Offline Bricks of Volume [" + volume.getName() + "] started successfully!"); - } catch (Exception e) { - showErrorDialog(actionDesc, e.getMessage()); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - action.setEnabled(false); - volume = guiHelper.getSelectedEntity(window, Volume.class); - if (volume != null) { - // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view - IWorkbenchPart view = guiHelper.getActiveView(); - if (view instanceof VolumeBricksView) { - // volume bricks view is open. check if any offline brick is selected - bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); - for (Brick brick : bricks) { - if (brick.getStatus() == BRICK_STATUS.OFFLINE) { - action.setEnabled(true); - } else { - // if any one of the selected brick is online, the disable the button - action.setEnabled(false); - break; - } - } - } - } - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ImportSshKeysAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ImportSshKeysAction.java deleted file mode 100644 index 4bdb3835..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ImportSshKeysAction.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; - -import com.gluster.storage.management.client.KeysClient; - -public class ImportSshKeysAction extends AbstractActionDelegate { - - @Override - protected void performAction(IAction action) { - final KeysClient client = new KeysClient(); - - Display.getDefault().asyncExec(new Runnable() { - - @Override - public void run() { - FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); - dialog.setText("Open"); - dialog.setFilterNames(new String[] { "ssh-keys (*.tar)" }); - dialog.setFilterExtensions(new String[] { "*.tar" }); - - String selectedFile = dialog.open(); - if (selectedFile == null) { - return; - } - - String title = "Import SSH Keys"; - try { - client.importSshKeys(selectedFile); - showInfoDialog(title, "SSH keys imported successfully!"); - } catch (Exception e) { - showErrorDialog(title, e.getMessage()); - } - } - }); - } - - @Override - public void dispose() { - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java deleted file mode 100644 index a8667c33..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateBrickAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.util.Set; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardDialog; - -import com.gluster.storage.management.console.dialogs.MigrateBrickWizard; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Volume; - -public class MigrateBrickAction extends AbstractActionDelegate { - private Volume volume; - private Brick brick; - - @Override - protected void performAction(IAction action) { - MigrateBrickWizard wizard = new MigrateBrickWizard(volume, brick); - - WizardDialog dialog = new WizardDialog(window.getShell(), wizard); - dialog.create(); - dialog.getShell().setSize(1024, 600); - dialog.open(); - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - Set bricks; - if (selectedEntity instanceof Volume) { - volume = (Volume) selectedEntity; - } - - action.setEnabled(false); - if (selectedEntity instanceof Brick) { - bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); - if ( bricks.iterator().hasNext()) { - brick = bricks.iterator().next(); - } else { - brick = null; - } - action.setEnabled(brick != null); - } - } - - @Override - public void dispose() { - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateVolumeAction.java deleted file mode 100644 index 66013222..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/MigrateVolumeAction.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -public class MigrateVolumeAction extends AbstractActionDelegate { - @Override - protected void performAction(IAction action) { - System.out.println("Running [" + this.getClass().getSimpleName() + "]"); - } - - @Override - public void dispose() { - System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PauseTaskAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PauseTaskAction.java deleted file mode 100644 index 92a79c73..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PauseTaskAction.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * PauseTaskAction.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskStatus; - - -public class PauseTaskAction extends AbstractActionDelegate { - private TaskInfo taskInfo; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - - try { - new TasksClient().pauseTask(taskInfo.getName()); - taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_PAUSE, "Paused"))); - modelManager.updateTask(taskInfo); - } catch (Exception e) { - showErrorDialog(actionDesc, - "Task [" + taskInfo.getDescription() + "] could not be Paused! Error: [" + e.getMessage() + "]"); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - action.setEnabled(false); - if (selectedEntity instanceof TaskInfo) { - taskInfo = (TaskInfo) selectedEntity; - action.setEnabled(taskInfo.getPauseSupported() && taskInfo.getStatus().getCode() == Status.STATUS_CODE_RUNNING); - } - } - - @Override - public void dispose() { - // TODO Auto-generated method stub - - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PreferencesAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PreferencesAction.java deleted file mode 100644 index b81a2a51..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/PreferencesAction.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.actions.ActionFactory; - -public class PreferencesAction extends AbstractActionDelegate { - - @Override - public void dispose() { - - } - - @Override - protected void performAction(IAction action) { - ActionFactory.PREFERENCES.create(window).run(); - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java deleted file mode 100644 index 016ffb8b..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RebalanceVolumeAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.net.URI; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.Volume; - -public class RebalanceVolumeAction extends AbstractActionDelegate { - private Volume volume; - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - try { - TaskInfo existingTaskInfo = GlusterDataModelManager.getInstance().getTaskByReference(volume.getName()); - if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS - && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { - showInfoDialog(actionDesc, "Volume [" + volume.getName() - + "] rebalance is already in progress! Try later."); - return; - } - - URI uri = new VolumesClient().rebalanceStart(volume.getName(), false, false, false); - // Add the task to model - TasksClient taskClient = new TasksClient(); - TaskInfo taskInfo = taskClient.getTaskInfo(uri); - if (taskInfo != null) { - GlusterDataModelManager.getInstance().addTask(taskInfo); - } - showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] rebalance started successfully!"); - guiHelper.showTaskView(); - } catch (Exception e) { - showErrorDialog(actionDesc, "Volume rebalance could not be started on [" + volume.getName() + "]! Error: [" - + e.getMessage() + "]"); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - - Volume selectedVolume = guiHelper.getSelectedEntity(getWindow(), Volume.class); - if (selectedVolume != null) { - volume = selectedVolume; - action.setEnabled(true); - } else { - action.setEnabled(false); - } - } - - @Override - public void dispose() { - System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RefreshDataAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RefreshDataAction.java deleted file mode 100644 index 4d492f8d..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RefreshDataAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -import com.gluster.storage.management.console.jobs.DataSyncJob; - -/** - * - */ -public class RefreshDataAction extends AbstractActionDelegate { - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - @Override - public void dispose() { - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) - */ - @Override - protected void performAction(IAction action) { - new DataSyncJob("Retrieving Management Info").schedule(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java deleted file mode 100644 index 105ab0da..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IWorkbenchPart; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.VolumeBricksView; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.utils.StringUtil; - -public class RemoveBrickAction extends AbstractActionDelegate { - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private GUIHelper guiHelper = GUIHelper.getInstance(); - private Set bricks; - private Volume volume; - boolean confirmDelete = false; - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - List brickList = getBrickList(bricks); - Integer deleteOption = new MessageDialog(getShell(), "Remove Bricks(s)", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), "Are you sure you want to remove following bricks from volume [" + volume.getName() - + "] ? " + CoreConstants.NEWLINE + StringUtil.collectionToString(brickList, ", "), MessageDialog.QUESTION, new String[] { - "Cancel", "Remove bricks, delete data", "Remove bricks, keep data" }, -1).open(); - if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) - return; - } - - if (deleteOption == 1) { - confirmDelete = true; - } - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { - public void run() { - VolumesClient client = new VolumesClient(); - try { - client.removeBricks(volume.getName(), bricks, confirmDelete); - // Update model with removed bricks in the volume - modelManager.removeBricks(volume, bricks); - - showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] bricks(s) removed successfully!"); - } catch (Exception e) { - showErrorDialog(actionDesc, "Volume [" + volume.getName() - + "] bricks(s) could not be removed! Error: [" + e.getMessage() + "]"); - } - } - }); - } - - @Override - public void dispose() { - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - - action.setEnabled(false); - volume = guiHelper.getSelectedEntity(window, Volume.class); - if (volume != null) { - // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view - IWorkbenchPart view = guiHelper.getActiveView(); - if (view instanceof VolumeBricksView) { - // volume bricks view is open. check if any brick is selected - bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); - action.setEnabled(bricks.size() > 0); - } - } - } - - private List getBrickList(Set bricks) { - List brickList = new ArrayList(); - for (Brick brick : bricks) { - brickList.add(brick.getServerName() + ":" + brick.getBrickDirectory()); - } - return brickList; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveServerAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveServerAction.java deleted file mode 100644 index 7f33828a..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveServerAction.java +++ /dev/null @@ -1,159 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.GlusterServersClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.GlusterServer; - -public class RemoveServerAction extends AbstractMonitoredActionDelegate { - private static final GlusterLogger logger = GlusterLogger.getInstance(); - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private GUIHelper guiHelper = GUIHelper.getInstance(); - - @Override - protected void performAction(final IAction action, IProgressMonitor monitor) { - final String actionDesc = action.getDescription(); - - Set selectedServers = guiHelper.getSelectedEntities(getWindow(), GlusterServer.class); - - if (!validate(action, selectedServers)) { - return; - } - - boolean confirmed = showConfirmDialog(actionDesc, "Are you sure you want to remove the server(s) " - + selectedServers + " ?"); - if (!confirmed) { - return; - } - - Set successServers = new HashSet(); - String errMsg = ""; - monitor.beginTask("Removing Selected Servers...", selectedServers.size()); - for (GlusterServer server : selectedServers) { - monitor.setTaskName("Removing server [" + server.getName() + "]..."); - - GlusterServersClient client = new GlusterServersClient(); - try { - client.removeServer(server.getName()); - GlusterServer glusterServer = server; - modelManager.removeGlusterServer(glusterServer); - successServers.add(server); - } catch (Exception e) { - if (!serverExists(server.getName())) { - modelManager.removeGlusterServer(server); - } - errMsg += "[" + server.getName() + "] : " + e.getMessage() + CoreConstants.NEWLINE; - } - monitor.worked(1); - } - monitor.done(); - showStatusMessage(action.getDescription(), selectedServers, successServers, errMsg); - } - - private Boolean serverExists(String serverName) { - try { - GlusterServersClient client = new GlusterServersClient(); - GlusterServer server = client.getGlusterServer(serverName); - return (server != null && server.getName().length() > 0); - } catch (Exception e) { - logger.error("Error while getting server info", e); - return false; - } - } - - private void showStatusMessage(String dialogTitle, Set selectedServers, Set successServers, - String errMsg) { - if (successServers.size() == selectedServers.size()) { - if(selectedServers.size() == 1) { - showInfoDialog(dialogTitle, "Server [" + selectedServers.iterator().next() + "] removed successfully!"); - } else { - showInfoDialog(dialogTitle, "Following servers removed successfully: " + CoreConstants.NEWLINE - + selectedServers + CoreConstants.NEWLINE + errMsg); - } - return; - } - - if (successServers.size() == 0) { - errMsg = "Server Removal Failed! Error(s):" + CoreConstants.NEWLINE + errMsg; - } else { - errMsg = "Following servers removed successfully : " + CoreConstants.NEWLINE + successServers - + CoreConstants.NEWLINE + "Following errors occurred on other selected servers: " - + CoreConstants.NEWLINE + errMsg; - } - showErrorDialog(dialogTitle, errMsg); - } - - private boolean validate(IAction action, Set selectedServers) { - Map> usedServers = new HashMap>(); - for (GlusterServer server : selectedServers) { - List configuredVolumes = modelManager.getVolumesOfServer(server.getName()); - - if (configuredVolumes.size() > 0) { - usedServers.put(server, configuredVolumes); - } - } - - if (usedServers.size() > 0) { - if (usedServers.size() == 1) { - showErrorDialog(action.getDescription(), "Server [" + usedServers.keySet().iterator().next() - + "] cannot be removed as it is being used by volume(s): " + CoreConstants.NEWLINE - + usedServers.values().iterator().next() ); - } else { - String serverList = ""; - for (Entry> entry : usedServers.entrySet()) { - serverList += entry.getKey() + " -> " + entry.getValue() + CoreConstants.NEWLINE; - } - showErrorDialog(action.getDescription(), - "Following servers cannot be removed as they are being used by volume(s): " - + CoreConstants.NEWLINE + serverList ); - } - return false; - } - return true; - } - - public void dispose() { - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - Set selectedServers = GUIHelper.getInstance().getSelectedEntities(getWindow(), - GlusterServer.class); - if(selectedServers == null || selectedServers.isEmpty()) { - action.setEnabled(false); - } else { - action.setEnabled(true); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java deleted file mode 100644 index cd2b3ff5..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Display; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Volume; - -public class ResetVolumeOptionsAction extends AbstractActionDelegate { - private Volume volume; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - public void dispose() { - } - - @Override - protected void performAction(final IAction action) { - Display.getDefault().asyncExec(new Runnable() { - - @Override - public void run() { - final String actionDesc = action.getDescription(); - - boolean confirmed = showConfirmDialog(actionDesc, - "Are you sure you want to reset all options of the volume [" + volume.getName() + "] ?"); - if (!confirmed) { - return; - } - - try { - new VolumesClient().resetVolumeOptions(volume.getName()); - showInfoDialog(actionDesc, "Volume options for [" + volume.getName() + "] reset successfully!"); - modelManager.resetVolumeOptions(volume); - } catch (Exception e) { - showErrorDialog(actionDesc, "Volume options for [" + volume.getName() - + "] could not be reset! Error: [" + e.getMessage() + "]"); - } - } - }); - } - - /* - * (non-Javadoc) - * - * @see - * com.gluster.storage.management.console.actions.AbstractActionDelegate#selectionChanged(org.eclipse.jface.action.IAction - * , org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IAction action, ISelection selection) { - volume = GUIHelper.getInstance().getSelectedEntity(getWindow(), Volume.class); - if (volume != null) { - action.setEnabled(volume.getOptions().size() > 0); - } else { - action.setEnabled(false); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResumeTaskAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResumeTaskAction.java deleted file mode 100644 index d672a760..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ResumeTaskAction.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskStatus; - -public class ResumeTaskAction extends AbstractActionDelegate { - private TaskInfo taskInfo; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - - try { - new TasksClient().resumeTask(taskInfo.getName()); - taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, "Resumed"))); - modelManager.updateTask(taskInfo); - } catch (Exception e) { - showErrorDialog(actionDesc, - "Task [" + taskInfo.getDescription() + "] could not be Resumed! Error: [" + e.getMessage() + "]"); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - action.setEnabled(false); - if (selectedEntity instanceof TaskInfo) { - taskInfo = (TaskInfo) selectedEntity; - action.setEnabled(taskInfo.getStatus().getCode() == Status.STATUS_CODE_PAUSE); - } - } - - @Override - public void dispose() { - - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ServerAdditionAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ServerAdditionAction.java deleted file mode 100644 index f47f6347..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ServerAdditionAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -import com.gluster.storage.management.console.dialogs.ServerAdditionDialog; -import com.gluster.storage.management.console.utils.GlusterLogger; - -public class ServerAdditionAction extends AbstractActionDelegate { - private static final GlusterLogger logger = GlusterLogger.getInstance(); - @Override - public void dispose() { - // TODO Auto-generated method stub - - } - - @Override - protected void performAction(IAction action) { - try { - // To open a dialog for server addition - ServerAdditionDialog dialog = new ServerAdditionDialog(getShell()); - dialog.open(); - } catch (Exception e) { - logger.error("Error in Manual server addition", e); - e.printStackTrace(); - } - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java deleted file mode 100644 index a0fc2331..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.osgi.internal.signedcontent.Base64; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.AlertsManager; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; - -public class StartVolumeAction extends AbstractMonitoredActionDelegate { - //private Volume volume; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private List selectedVolumes = new ArrayList(); - private List selectedVolumeNames = new ArrayList(); - private List offlineVolumeNames = new ArrayList(); - - @Override - protected void performAction(IAction action, IProgressMonitor monitor) { - final String actionDesc = action.getDescription(); - - collectVolumeNames(); - - if (offlineVolumeNames.size() == 0) { - showWarningDialog(actionDesc, "Volumes " + selectedVolumeNames + " already started!"); - return; // Volume already started. Don't do anything. - } - - VolumesClient vc = new VolumesClient(); - Volume newVolume = new Volume(); - List startedVolumes = new ArrayList(); - List failedVolumes = new ArrayList(); - String errorMessage = ""; - List cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); - List offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); - // One or more servers are offline, Show warning if cifs is enabled - if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { - Integer userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), - "Performing CIFS updates when one or more servers are offline can trigger " - + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE - + "Are you sure you want to continue?", MessageDialog.QUESTION, - new String[] { "No", "Yes" }, -1).open(); - if (userAction != 1) { - return; // Do not start volume services - } - } - - monitor.beginTask("Starting Selected Volumes...", selectedVolumes.size()); - // Starting of a volume results in changes to the model, and ultimately updates the "selectedVolumes" list, - // over which we are iterating, thus resulting in ConcurrentModificationException. To avoid this, we iterate - // over an array obtained from the list. - for (Volume volume : selectedVolumes.toArray(new Volume[0])) { - if(monitor.isCanceled()) { - break; - } - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - monitor.worked(1); - continue; // skip if already started - } - try { - monitor.setTaskName("Starting volume [" + volume.getName() + "]"); - vc.startVolume(volume.getName(), false); - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE); - startedVolumes.add(volume.getName()); - } catch (Exception e) { - failedVolumes.add(volume.getName()); - // If any post volume start activity failed, update the volume status - if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.ONLINE) { - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE); - } - errorMessage += e.getMessage() + CoreConstants.NEWLINE; - } - - // Update the model by fetching latest volume info (NOT JUST STATUS) - try { - modelManager.refreshVolumeData(volume); - } catch (Exception e) { - errorMessage += "Updating volume info failed on UI. [" + e.getMessage() + "]"; - } - monitor.worked(1); - } - monitor.done(); - - // Display the success or failure info - if (startedVolumes.size() == 0) { // No volume(s) started successfully - showErrorDialog(actionDesc, "Volume(s) " + failedVolumes + " could not be started!" - + CoreConstants.NEWLINE + "Error: [" + errorMessage + "]"); - } else { - String info = "Volume(s) " + startedVolumes + " started successfully!"; - if (!errorMessage.equals("")) { - info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes - + " failed to start! [" + errorMessage + "]"; - } - if (selectedVolumes.size() == startedVolumes.size()) { - showInfoDialog(actionDesc, info); - } else { - showWarningDialog(actionDesc, info); - } - } - } - - private void collectVolumeNames() { - selectedVolumeNames.clear(); - offlineVolumeNames.clear(); - for (Volume volume : selectedVolumes) { - selectedVolumeNames.add(volume.getName()); - if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { - offlineVolumeNames.add(volume.getName()); - } - } - } - - @Override - public void dispose() { - - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - Set selectedVolumeNames = GUIHelper.getInstance().getSelectedEntities(getWindow(), Volume.class); - selectedVolumes.clear(); - if (selectedVolumeNames == null || selectedVolumeNames.isEmpty()) { - super.selectionChanged(action, selection); - if (selectedEntity instanceof Volume) { - selectedVolumes.add((Volume) selectedEntity); - } - } else { - selectedVolumes.addAll(selectedVolumeNames); //TODO reverse the collection to maintain the selected order - } - - action.setEnabled(false); - // To enable the action - for (Volume volume : selectedVolumes) { - if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { - action.setEnabled(true); - break;// If find an online volume, enable the action - } - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopTaskAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopTaskAction.java deleted file mode 100644 index 25afa320..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopTaskAction.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; - -public class StopTaskAction extends AbstractActionDelegate { - private TaskInfo taskInfo; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - @Override - protected void performAction(final IAction action) { - final String actionDesc = action.getDescription(); - - try { - new TasksClient().stopTask(taskInfo.getName()); - // On successful stop clear from the task list - modelManager.removeTask(taskInfo); - action.setEnabled(false); // TODO disable other task buttons - } catch (Exception e) { - showErrorDialog(actionDesc, - "Task [" + taskInfo.getDescription() + "] could not be Stopped! Error: [" + e.getMessage() + "]"); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - action.setEnabled(false); - if (selectedEntity instanceof TaskInfo) { - taskInfo = (TaskInfo) selectedEntity; - action.setEnabled(taskInfo.getStopSupported() - && (taskInfo.getStatus().getCode() == Status.STATUS_CODE_PAUSE - || taskInfo.getStatus().getCode() == Status.STATUS_CODE_RUNNING)); - } - } - - @Override - public void dispose() { - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java deleted file mode 100644 index 85103963..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; - -public class StopVolumeAction extends AbstractMonitoredActionDelegate { - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private List selectedVolumes = new ArrayList(); - private List selectedVolumeNames = new ArrayList(); - private List onlineVolumeNames = new ArrayList(); - private List stoppedVolumes = new ArrayList(); - private List failedVolumes = new ArrayList(); - private String errorMessage = null; - - @Override - protected void performAction(final IAction action, IProgressMonitor monitor) { - collectVolumeNames(); - - if (onlineVolumeNames.size() == 0) { - showWarningDialog(action.getDescription(), "Volumes " + selectedVolumeNames + " already stopped!"); - return; // Volumes already stopped, Don't do anything. - } - - Integer userAction = new MessageDialog(getShell(), "Stop Volume", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), "Are you sure you want to stop the following volumes?" - + CoreConstants.NEWLINE + onlineVolumeNames, MessageDialog.QUESTION, - new String[] { "No", "Yes" }, -1).open(); - - if (userAction <= 0) { // user select cancel or pressed escape key - return; - } - - List cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); - List offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); - // One or more servers are offline, Show warning if cifs is enabled - if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { - userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), - "Performing CIFS updates when one or more servers are offline can trigger " - + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE - + "Are you sure you want to continue?", MessageDialog.QUESTION, - new String[] { "No", "Yes" }, -1).open(); - if (userAction != 1) { - return; // Do not stop volume services - } - } - - stopVolumes(selectedVolumes, false, monitor); - - // Check for errors, trying to force stop in case of errors - checkForErrors(action, monitor, true); - } - - private void checkForErrors(final IAction action, IProgressMonitor monitor, boolean tryForceStop) { - String message = null; - if (stoppedVolumes.size() == 0) { // No volume(s) stopped successfully - message = "Volume(s) " + failedVolumes + " could not be stopped! " + CoreConstants.NEWLINE - + "Error: [" + errorMessage + "]"; - if(tryForceStop) { - forceStopVolumes(action.getDescription(), message + CoreConstants.NEWLINE - + "Do you want to stop forcefully?", monitor); - // check for errors without trying to force stop in case of errors - checkForErrors(action, monitor, false); - return; - } else { - showErrorDialog(action.getDescription(), message); - return; - } - } else { - message = "Volume(s) " + stoppedVolumes + " stopped successfully!"; - if (!errorMessage.isEmpty()) { - if (failedVolumes.size() > 0) { - message = message + CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volume(s) " - + failedVolumes + " could not be stopped! [" + errorMessage + "]"; - if(tryForceStop) { - forceStopVolumes(action.getDescription(), message + CoreConstants.NEWLINE - + "Do you want to stop forcefully?", monitor); - // check for errors without trying to force stop in case of errors - checkForErrors(action, monitor, false); - return; - } - } else { // Stop volume success, but post stop volume fails, append the error message - message += CoreConstants.NEWLINE + CoreConstants.NEWLINE + errorMessage; - } - } - - if (errorMessage.isEmpty()) { - showInfoDialog(action.getDescription(), message); - } else { - showWarningDialog(action.getDescription(), message); - } - } - } - - private void forceStopVolumes(String actionDesc, String message, IProgressMonitor monitor) { - boolean forceStop = showConfirmDialog(actionDesc, message); - if (!forceStop) { - return; - } - stopVolumes(failedVolumes, true, monitor); - } - - private void stopVolumes(List volumes, Boolean force, IProgressMonitor monitor) { - VolumesClient vc = new VolumesClient(); - Volume newVolume = new Volume(); - stoppedVolumes.clear(); - failedVolumes.clear(); - errorMessage = ""; - - monitor.beginTask("Stopping Selected Volumes...", volumes.size()); - // Stopping of a volume results in changes to the model, and ultimately updates the "selectedVolumes" list, - // over which we are iterating, thus resulting in ConcurrentModificationException. To avoid this, we iterate - // over an array obtained from the list. - for (Volume volume : volumes.toArray(new Volume[0])) { - if(monitor.isCanceled()) { - break; - } - - if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { - monitor.worked(1); - continue; // skip if already stopped - } - try { - monitor.setTaskName("Stopping volume [" + volume.getName() + "]"); - vc.stopVolume(volume.getName(), force); - stoppedVolumes.add(volume.getName()); - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); - } catch (Exception e) { - // If any post volume stop activity failed, update the volume status - if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.OFFLINE) { - // stop volume succeed, so add it to stoppedVolumes - stoppedVolumes.add(volume.getName()); - modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); - errorMessage += "Volume [" + volume.getName() + "] stopped, but following error occured: [" - + e.getMessage() + "]"; - } else { - failedVolumes.add(volume); - errorMessage += "[" + volume.getName() + "] : " + e.getMessage() + CoreConstants.NEWLINE; - } - } - - // Update the model by fetching latest volume info (NOT JUST STATUS) - try { - modelManager.refreshVolumeData(volume); - } catch (Exception e) { - errorMessage += "Failed to update volume info on UI. [" + e.getMessage() + "]"; - } - monitor.worked(1); - } - monitor.done(); - } - - private void collectVolumeNames() { - selectedVolumeNames.clear(); - onlineVolumeNames.clear(); - for (Volume volume : selectedVolumes) { - selectedVolumeNames.add(volume.getName()); - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - onlineVolumeNames.add(volume.getName()); - } - } - } - - @Override - public void dispose() { - } - - /* - * (non-Javadoc) - * - * @see - * com.gluster.storage.management.console.actions.AbstractActionDelegate#selectionChanged(org.eclipse.jface.action.IAction - * , org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IAction action, ISelection selection) { - Set selectedVolumeNames = GUIHelper.getInstance().getSelectedEntities(getWindow(), Volume.class); - selectedVolumes.clear(); - if (selectedVolumeNames == null || selectedVolumeNames.isEmpty()) { - super.selectionChanged(action, selection); - if (selectedEntity instanceof Volume) { - selectedVolumes.add((Volume) selectedEntity); - } - } else { - selectedVolumes.addAll(selectedVolumeNames); //TODO reverse the collection to maintain the selected order - } - - action.setEnabled(false); - // To enable the action - for (Volume volume : selectedVolumes) { - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - action.setEnabled(true); - break; // If find an online volume, enable the action - } - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/SupportAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/SupportAction.java deleted file mode 100644 index 5d0bc833..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/SupportAction.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -import com.gluster.storage.management.console.dialogs.GlusterSupportDialog; - -/** - * - */ -public class SupportAction extends AbstractActionDelegate { - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) - */ - @Override - protected void performAction(IAction action) { - GlusterSupportDialog dialog = new GlusterSupportDialog(getShell()); - dialog.create(); - dialog.getShell().setSize(770, 430); - dialog.open(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - @Override - public void dispose() { - - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TerminalAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TerminalAction.java deleted file mode 100644 index 992cc11b..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TerminalAction.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; - -import com.gluster.storage.management.console.utils.GUIHelper; - -/** - * - */ -public class TerminalAction extends AbstractActionDelegate { - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() - */ - @Override - public void dispose() { - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) - */ - @Override - protected void performAction(IAction action) { - GUIHelper.getInstance().showTerminalView(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TestPopupMenuAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TestPopupMenuAction.java deleted file mode 100644 index 0cf32adf..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/TestPopupMenuAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -public class TestPopupMenuAction implements IObjectActionDelegate { - - private Shell shell; - - /** - * Constructor for Action1. - */ - public TestPopupMenuAction() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - shell = targetPart.getSite().getShell(); - } - - /** - * @see IActionDelegate#run(IAction) - */ - public void run(IAction action) { - MessageDialog.openInformation( - shell, - "glustersp-gui", - "New Action was executed."); - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java deleted file mode 100644 index 4c538be4..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/VolumeLogRotateAction.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.gluster.storage.management.console.actions; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IWorkbenchPart; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.VolumeBricksView; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; - - -public class VolumeLogRotateAction extends AbstractActionDelegate { - - private Volume volume; - private GUIHelper guiHelper = GUIHelper.getInstance(); - private Set bricks; - - @Override - public void dispose() { - } - - @Override - protected void performAction(IAction action) { - final String actionDesc = action.getDescription(); - List selectedBricks = new ArrayList(); - boolean confirmed = showConfirmDialog(actionDesc, - "Are you sure you want to Rotate logs for volume [" + volume.getName() + "] ? "); - if (!confirmed) { - return; - } - - if (bricks != null) { - selectedBricks = GlusterCoreUtil.getQualifiedBrickList(bricks); - } - try { - new VolumesClient().volumeLogRotate(volume.getName(), selectedBricks); - showInfoDialog(actionDesc, "Volume logs for [" + volume.getName() + "] rotated successfully!"); - } catch (Exception e) { - showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] log rotation failed! Error: [" + e.getMessage() + "]"); - } - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - super.selectionChanged(action, selection); - volume = guiHelper.getSelectedEntity(window, Volume.class); - - if (volume != null) { - // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view - IWorkbenchPart view = guiHelper.getActiveView(); - if (view instanceof VolumeBricksView) { - // volume bricks view is open. check if any brick is selected - bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); - } - } - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickPage.java deleted file mode 100644 index b2cb3582..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickPage.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * AddDiskPage.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.dialogs; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.richclientgui.toolbox.duallists.DualListComposite.ListContentChangedListener; -import com.richclientgui.toolbox.duallists.IRemovableContentProvider; - -/** - * @author root - * - */ -public class AddBrickPage extends WizardPage { - private List availableDevices = new ArrayList(); - private List selectedDevices = new ArrayList(); - private Volume volume = null; - private BricksSelectionPage page = null; - - - public static final String PAGE_NAME = "add.disk.volume.page"; - - /** - * @param pageName - */ - protected AddBrickPage(Volume volume) { - super(PAGE_NAME); - this.volume = volume; - setTitle("Add Brick"); - - String description = "Add bricks to [" + volume.getName() + "] "; - if ( volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { - description += "(in multiples of " + volume.getReplicaCount() + ")"; - } else if (volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - description += "(in multiples of " + volume.getStripeCount() + ")"; - } - setDescription(description); - - availableDevices = getAvailableDevices(volume); - - setPageComplete(false); - setErrorMessage("Please select bricks to be added to the volume [" + volume.getName() +"]"); - } - - - private boolean isDeviceUsed(Volume volume, Device device){ - for (Brick volumeBrick : volume.getBricks()) { - if ( device.getQualifiedBrickName(volume.getName()).equals(volumeBrick.getQualifiedName())) { - return true; - } - } - return false; - } - - protected List getAvailableDevices(Volume volume) { - List availableDevices = new ArrayList(); - for (Device device : GlusterDataModelManager.getInstance().getReadyDevicesOfAllServers()) { - if ( ! isDeviceUsed(volume, device) ) { - availableDevices.add(device); - } - } - return availableDevices; - } - - public Set getChosenDevices() { - return new HashSet(page.getChosenDevices()); - } - - public Set getChosenBricks( String volumeName ) { - return page.getChosenBricks(volumeName); - } - - private boolean isValidDiskSelection(int diskCount) { - if ( diskCount == 0) { - return false; - } - switch (volume.getVolumeType()) { - case DISTRIBUTED_REPLICATE: - return (diskCount % volume.getReplicaCount() == 0); - case DISTRIBUTED_STRIPE: - return (diskCount % volume.getStripeCount() == 0); - } - return true; - } - - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createControl(Composite parent) { - getShell().setText("Add Brick"); - List chosenDevices = new ArrayList(); // or volume.getDisks(); - - page = new BricksSelectionPage(parent, SWT.NONE, availableDevices, chosenDevices, volume.getName()); - page.addDiskSelectionListener(new ListContentChangedListener() { - @Override - public void listContentChanged(IRemovableContentProvider contentProvider) { - List newChosenDevices = page.getChosenDevices(); - - // validate chosen disks - if(isValidDiskSelection(newChosenDevices.size())) { - clearError(); - } else { - setError(); - } - } - }); - setControl(page); - } - - private void setError() { - String errorMessage = null; - if ( volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTE) { - errorMessage = "Please select at least one brick!"; - } else if( volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { - errorMessage = "Please select bricks in multiples of " + volume.getReplicaCount(); - } else { - errorMessage = "Please select bricks in multiples of " + volume.getStripeCount(); - } - - setPageComplete(false); - setErrorMessage(errorMessage); - } - - private void clearError() { - setErrorMessage(null); - setPageComplete(true); - } - - public BricksSelectionPage getDialogPage() { - return this.page; - } - - public void setPageComplete() { - - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickWizard.java deleted file mode 100644 index 734dd5e4..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/AddBrickWizard.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * AddDiskWizard.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.dialogs; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.Wizard; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.utils.StringUtil; - -/** - * - */ -public class AddBrickWizard extends Wizard { - private AddBrickPage page; - private Volume volume; - - public AddBrickWizard(Volume volume) { - setWindowTitle("Gluster Management Console - Add Brick"); - setHelpAvailable(false); // TODO: Introduce wizard help - this.volume = volume; - } - - public void addPages() { - page = new AddBrickPage(volume); - addPage(page); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#performFinish() - */ - @Override - public boolean performFinish() { - Set bricks = page.getChosenBricks(volume.getName()); - VolumesClient volumeClient = new VolumesClient(); - try { - Set brickList = getBrickList(bricks); - - volumeClient.addBricks(volume.getName(), brickList); - - // Update model with new bricks in the volume - GlusterDataModelManager.getInstance().addBricks(volume, bricks); - - MessageDialog.openInformation(getShell(), "Add brick(s) to Volume", "Volume [" + volume.getName() - + "] is expanded with bricks [" + StringUtil.collectionToString(brickList, ", ") + "]"); - return true; - } catch (Exception e) { - MessageDialog.openError(getShell(), "Add brick(s) to Volume", e.getMessage()); - return false; - } - } - - private Set getBrickList(Set bricks) { - Set brickList = new HashSet(); - for(Brick brick : bricks) { - brickList.add(brick.getServerName() + ":" + brick.getBrickDirectory()); - } - return brickList; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.Wizard#canFinish() - */ - @Override - public boolean canFinish() { - return super.canFinish() && page.isPageComplete(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/BricksSelectionPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/BricksSelectionPage.java deleted file mode 100644 index 1e4de2ef..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/BricksSelectionPage.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.TableLabelProviderAdapter; -import com.gluster.storage.management.console.utils.EntityViewerFilter; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.utils.NumberUtil; -import com.richclientgui.toolbox.duallists.CustomTableDualListComposite; -import com.richclientgui.toolbox.duallists.DualListComposite.ListContentChangedListener; -import com.richclientgui.toolbox.duallists.IRemovableContentProvider; -import com.richclientgui.toolbox.duallists.RemovableContentProvider; -import com.richclientgui.toolbox.duallists.TableColumnData; - -public class BricksSelectionPage extends Composite { - private enum DISK_TABLE_COLUMN_INDICES { - SERVER, BRICK_DIRECTORY, FREE_SPACE, TOTAL_SPACE - } - - private static final String[] DISK_TABLE_COLUMNS_NAMES = { "Server", "Brick Directory", "Free Space (GB)", - "Total Space (GB)" }; - - private GUIHelper guiHelper = GUIHelper.getInstance(); - private CustomTableDualListComposite dualTableViewer; - private Text filterText; - // This list keeps track of the order of the disks as user changes the same by clicking on up/down arrow buttons - private List chosenDevices = new ArrayList(); - - private IRemovableContentProvider chosenBricksContentProvider; - - private Button btnUp; - - private Button btnDown; - - public BricksSelectionPage(final Composite parent, int style, List allDevices, List selectedDevices, - String volumeName) { - super(parent, style); - - createPage(allDevices, selectedDevices, volumeName); - - parent.layout(); - } - - public void addDiskSelectionListener(ListContentChangedListener listener) { - dualTableViewer.addChosenListChangedSelectionListener(listener); - } - - private TableLabelProviderAdapter getDiskLabelProvider(final String volumeName) { - return new TableLabelProviderAdapter() { - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Device)) { - return null; - } - - Device device = (Device) element; - return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? device.getServerName() - : columnIndex == DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY.ordinal() ? device.getMountPoint() - + "/" + volumeName - : columnIndex == DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? NumberUtil - .formatNumber((device.getFreeSpace() / 1024)) - : columnIndex == DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? NumberUtil - .formatNumber((device.getSpace() / 1024)) : "Invalid"); - } - }; - } - - private int indexOf(List disks, Disk searchDisk) { - for (Disk disk : disks) { - if (disk.getQualifiedName().equals(searchDisk.getQualifiedName())) { - return disks.indexOf(disk); - } - } - return -1; - } - - private void createPage(List allDevice, List selectedDevice, String volumeName) { - setupPageLayout(); - - filterText = guiHelper.createFilterText(this); - new Label(this, SWT.NONE); - - createDualTableViewer(allDevice, selectedDevice, volumeName); - createFilter(filterText, false); // attach filter text to the dual table viewer for auto-filtering - - Composite buttonContainer = new Composite(this, SWT.NONE); - buttonContainer.setLayout(new GridLayout(1, false)); - GridData buttonContainerData = new GridData(SWT.FILL, SWT.CENTER, true, true); - buttonContainerData.minimumWidth = 40; - buttonContainer.setLayoutData(buttonContainerData); - - btnUp = new Button(buttonContainer, SWT.PUSH); - GridData btnUpData = new GridData(SWT.LEFT, SWT.BOTTOM, true, false); - btnUpData.minimumWidth = 30; - btnUp.setLayoutData(btnUpData); - btnUp.setImage(guiHelper.getImage(IImageKeys.ARROW_UP_16x16)); - btnUp.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - chosenDevices = getChosenDevices(); - List selectedDevices = getSelectedChosenDevices(); - - chosenBricksContentProvider.removeElements(chosenDevices); - for (Device device : selectedDevices) { - int index = chosenDevices.indexOf(device); - Device deviceAbove = chosenDevices.get(index - 1); - chosenDevices.set(index - 1, device); - chosenDevices.set(index, deviceAbove); - } - chosenBricksContentProvider.addElements(chosenDevices); - dualTableViewer.refreshChosenViewer(); - updateButtons(); - } - }); - - btnDown = new Button(buttonContainer, SWT.PUSH); - GridData btnDownData = new GridData(SWT.LEFT, SWT.TOP, true, false); - btnDownData.minimumWidth = 30; - btnDown.setLayoutData(btnDownData); - btnDown.setImage(guiHelper.getImage(IImageKeys.ARROW_DOWN_16x16)); - btnDown.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - - chosenDevices = getChosenDevices(); - List selectedDevices = getSelectedChosenDevices(); - - chosenBricksContentProvider.removeElements(chosenDevices); - for (Device disk : selectedDevices) { - int index = chosenDevices.indexOf(disk); - Device deviceBelow = chosenDevices.get(index + 1); - chosenDevices.set(index + 1, disk); - chosenDevices.set(index, deviceBelow); - } - chosenBricksContentProvider.addElements(chosenDevices); - dualTableViewer.refreshChosenViewer(); - updateButtons(); - - } - }); - } - - private List getSelectedChosenDevices() { - TableItem[] selectedItems = dualTableViewer.getChosenTable().getSelection(); - List selectedDevices = new ArrayList(); - for (TableItem item : selectedItems) { - selectedDevices.add((Device) item.getData()); - } - return selectedDevices; - } - - private void createFilter(final Text filterText, boolean caseSensitive) { - final String initialFilterString = filterText.getText(); - - final EntityViewerFilter filter = new EntityViewerFilter(initialFilterString, caseSensitive); - // On every keystroke inside the text field, update the filter string - filterText.addKeyListener(new KeyAdapter() { - private String filterString = initialFilterString; - - @Override - public void keyReleased(KeyEvent e) { - String enteredString = filterText.getText(); - if (enteredString.equals(filterString)) { - // Filter string has not changed. don't do anything - return; - } - - // Update filter string - filterString = enteredString; - filter.setFilterString(filterString); - - // Refresh viewer with newly filtered content - dualTableViewer.refreshAvailableViewer(); - dualTableViewer.refreshChosenViewer(); - } - }); - - dualTableViewer.setAvailableViewerFilter(filter); - dualTableViewer.setChosenViewerFilter(filter); - } - - private void createDualTableViewer(List allDevices, List selectedDevices, String volumeName) { - TableColumnData[] columnData = createColumnData(); - ITableLabelProvider diskLabelProvider = getDiskLabelProvider(volumeName); - - dualTableViewer = new CustomTableDualListComposite(this, SWT.NONE, columnData, columnData); - - dualTableViewer.setViewerLabels("Available:", "Selected:"); - - dualTableViewer.setAvailableTableLinesVisible(false); - dualTableViewer.setAvailableTableHeaderVisible(true); - dualTableViewer.setAvailableContentProvider(new RemovableContentProvider(getAvailableDevice(allDevices, - selectedDevices))); - dualTableViewer.setAvailableLabelProvider(diskLabelProvider); - - dualTableViewer.setChosenTableLinesVisible(true); - dualTableViewer.setChosenTableHeaderVisible(true); - - chosenBricksContentProvider = new RemovableContentProvider(selectedDevices); - dualTableViewer.setChosenContentProvider(chosenBricksContentProvider); - dualTableViewer.setChosenLabelProvider(diskLabelProvider); - - dualTableViewer.getChosenTable().addSelectionListener(new SelectionAdapter() { - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - } - - private void updateButtons() { - btnUp.setEnabled(true); - btnDown.setEnabled(true); - List selectedChosenDevices = getSelectedChosenDevices(); - List chosenDevices = getChosenDevices(); - for (Device device : selectedChosenDevices) { - int index = chosenDevices.indexOf(device); - if (index == 0) { - btnUp.setEnabled(false); - } - if (index == chosenDevices.size() - 1) { - btnDown.setEnabled(false); - } - } - } - - /** - * @param allDevices - * @param selectedDevices - * @return - */ - private List getAvailableDevice(List allDevices, List selectedDevices) { - List availableDevices = new ArrayList(); - for (Device device : allDevices) { - if (!selectedDevices.contains(device)) { - availableDevices.add(device); - } - } - return availableDevices; - } - - private TableColumnData[] createColumnData() { - DISK_TABLE_COLUMN_INDICES[] columns = DISK_TABLE_COLUMN_INDICES.values(); - TableColumnData[] columnData = new TableColumnData[columns.length]; - int columnNum; - for (DISK_TABLE_COLUMN_INDICES column : columns) { - columnNum = column.ordinal(); - columnData[columnNum] = new TableColumnData(columnNum, DISK_TABLE_COLUMNS_NAMES[columnNum], 100); - } - return columnData; - } - - private void setupPageLayout() { - final GridLayout layout = new GridLayout(2, false); - layout.verticalSpacing = 10; - layout.marginTop = 10; - setLayout(layout); - - setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - } - - public List getChosenDevices() { - Object[] devicesArr = chosenBricksContentProvider.getElements(dualTableViewer); - if (devicesArr != null) { - List devices = new ArrayList(); - for (Object device : devicesArr) { - devices.add((Device) device); - } - return devices; - } - return null; - } - - public Set getChosenBricks(String volumeName) { - Object[] bricksArr = chosenBricksContentProvider.getElements(dualTableViewer); - - if (bricksArr != null) { - Set bricks = new HashSet(); - for (Object device : bricksArr) { - bricks.add(new Brick(((Device) device).getServerName(), BRICK_STATUS.ONLINE, ((Device) device) - .getMountPoint() + "/" + volumeName)); // Assumption mount point is not having trailing "/" - } - return bricks; - } - return null; - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ChangePasswordDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ChangePasswordDialog.java deleted file mode 100644 index 1576ffe3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ChangePasswordDialog.java +++ /dev/null @@ -1,284 +0,0 @@ -/** - * ChangePasswordDialog.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.dialogs; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.UpdateValueStrategy; -import org.eclipse.core.databinding.beans.PojoProperties; -import org.eclipse.core.databinding.validation.ValidationStatus; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.swt.WidgetProperties; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.client.UsersClient; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.validators.StringRequiredValidator; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.ConnectionDetails; - -public class ChangePasswordDialog extends Dialog { - public static final int RETURN_CODE_ERROR = 2; - private Text oldPassword; - private Text newPassword; - private Text confirmPassword; - private Button okButton; - - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private Composite composite; - - private final ConnectionDetails connectionDetails = new ConnectionDetails("gluster", ""); - - public ChangePasswordDialog(Shell shell) { - super(shell); - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - newShell.setText("Gluster Management Console"); - addEscapeListener(newShell); - } - - private void addEscapeListener(Shell shell) { - shell.addTraverseListener(new TraverseListener() { - - @Override - public void keyTraversed(TraverseEvent e) { - if (e.keyCode == SWT.ESC) { - cancelPressed(); - } - } - }); - } - - /** - * Overriding to make sure that the dialog is centered in screen - */ - @Override - protected void initializeBounds() { - super.initializeBounds(); - - guiHelper.centerShellInScreen(getShell()); - } - - private void configureDialogLayout(Composite composite) { - GridLayout layout = (GridLayout) composite.getLayout(); - layout.numColumns = 2; - layout.marginLeft = 20; - layout.marginRight = 20; - layout.marginTop = 20; - layout.horizontalSpacing = 20; - layout.verticalSpacing = 20; - } - - // ------------------------------------------ - - private void createLabel(Composite composite, String label) { - Label passwordLabel = new Label(composite, SWT.NONE); - passwordLabel.setText(label); - passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - } - - private Text createPasswordText(Composite composite) { - Text field = new Text(composite, SWT.BORDER | SWT.PASSWORD); - GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); - layoutData.widthHint = convertWidthInCharsToPixels(32); - field.setLayoutData(layoutData); - return field; - } - - @Override - protected Control createDialogArea(Composite parent) { - // parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); - parent.setBackgroundMode(SWT.INHERIT_FORCE); - - composite = (Composite) super.createDialogArea(parent); - configureDialogLayout(composite); - - createLabel(composite, "Old Password:"); - oldPassword = createPasswordText(composite); - - createLabel(composite, "New Password:"); - newPassword = createPasswordText(composite); - - createLabel(composite, "Confirm Password:"); - confirmPassword = createPasswordText(composite); - - createListeners(); - - return composite; - } - - /** - * - */ - private void createListeners() { - ModifyListener listener = new ModifyListener() { - - @Override - public void modifyText(ModifyEvent e) { - updateButtonStatus(); - } - }; - - oldPassword.addModifyListener(listener); - newPassword.addModifyListener(listener); - confirmPassword.addModifyListener(listener); - } - - private void updateButtonStatus() { - String oldPwd = oldPassword.getText(); - String newPwd = newPassword.getText(); - String confirmPwd = confirmPassword.getText(); - if(oldPwd.isEmpty() || newPwd.isEmpty() || confirmPwd.isEmpty()) { - okButton.setEnabled(false); - return; - } - - if(!newPwd.equals(confirmPwd)) { - okButton.setEnabled(false); - return; - } - - if (confirmPwd.equals(CoreConstants.DEFAULT_PASSWORD) || isContainsWhiteSpace(confirmPwd)) { - okButton.setEnabled(false); - return; - } - - if (newPwd.length() < 4 ) { // Minimum password length is 4 - okButton.setEnabled(false); - return; - } - - okButton.setEnabled(true); - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - okButton = createButton(parent, IDialogConstants.OK_ID, "&Change", true); - okButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - - setupDataBinding(); - } - - public boolean isContainsWhiteSpace(String text) { - return text.matches(".*[\\s\\\\].*"); // White space or backslash - } - - public class ConfirmPasswordValidator extends StringRequiredValidator { - public ConfirmPasswordValidator(String errorText, ControlDecoration controlDecoration, Control linkedControl) { - super(errorText, controlDecoration, linkedControl); - } - - @Override - public IStatus validate(Object value) { - - IStatus status = super.validate(value); - if (status.isOK()) { - String errMsg = null; - if (errMsg == null && isContainsWhiteSpace( newPassword.getText())) { - errMsg = "Password should not contain space or back slash characters"; - } - - if (!value.equals(newPassword.getText())) { - errMsg = "Passwords mismatched"; - } - - if (errMsg == null && value.equals(CoreConstants.DEFAULT_PASSWORD)) { - errMsg = "New password should not be a default password"; - } - - if(errMsg != null) { - controlDecoration.setDescriptionText(errMsg); - controlDecoration.show(); - linkedControl.setEnabled(false); - return ValidationStatus.error(errMsg); - } - } - return status; - } - }; - - private void setupDataBinding() { - DataBindingContext dataBindingContext = new DataBindingContext(SWTObservables.getRealm(Display.getCurrent())); - UpdateValueStrategy passwordBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - UpdateValueStrategy newPwdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - UpdateValueStrategy confirmPwdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - - // The Validator shows error decoration and disables OK button on - // validation failure - passwordBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter old password!", - guiHelper.createErrorDecoration(oldPassword), null)); - - dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(oldPassword), - PojoProperties.value("password").observe(connectionDetails), passwordBindingStrategy, - passwordBindingStrategy); - - newPwdBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter new password!", guiHelper - .createErrorDecoration(newPassword), null)); - - dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(newPassword), - PojoProperties.value("newPassword").observe(connectionDetails), newPwdBindingStrategy, - newPwdBindingStrategy); - - confirmPwdBindingStrategy.setBeforeSetValidator(new ConfirmPasswordValidator("Please enter confirm password!", - guiHelper.createErrorDecoration(confirmPassword), null)); - - dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(confirmPassword), - PojoProperties.value("confirmNewPassword").observe(connectionDetails), confirmPwdBindingStrategy, - confirmPwdBindingStrategy); - } - - protected void okPressed() { - String user = connectionDetails.getUserId(); - String oldPassword = connectionDetails.getPassword(); - String newPassword = connectionDetails.getNewPassword(); - - UsersClient usersClient = new UsersClient(); - try { - usersClient.changePassword(user, oldPassword, newPassword); - MessageDialog.openInformation(getShell(), "Change password", "Password changed successfully!"); - this.close(); - } catch (Exception e) { - MessageDialog.openError(getShell(), "Change password Failed", e.getMessage()); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java deleted file mode 100644 index cbbcbd46..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java +++ /dev/null @@ -1,474 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.console.Activator; -import com.gluster.storage.management.console.ConsoleConstants; -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.console.utils.GUIHelper; - -/** - * Cluster selection dialog, which prompts for the cluster name to be managed - */ -public class ClusterSelectionDialog extends Dialog { - private static final String MESSAGE_SELECT_CLUSTER = "Select the Cluster you want to manage in this session."; - private static final String MESSAGE_CREATE_CLUSTER = "Create an empty Cluster and start adding servers to it."; - private static final String MESSAGE_REGISTER_CLUSTER = "Register an existing Cluster with the Management Gateway and start managing it using the Management Console."; - - protected enum CLUSTER_MODE { SELECT, CREATE, REGISTER }; - - private Combo clusterNameCombo = null; - private Text newClusterNameText = null; - private Text existingClusterNameText = null; - private Text serverNameText = null; - private Button okButton; - - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private Composite composite; - private ControlDecoration newClusterNameErrorDecoration; - private ControlDecoration existingClusterNameErrorDecoration; - private ControlDecoration serverNameErrorDecoration; - private List clusters; - private Button selectButton; - private Button createButton; - private Button registerButton; - private Composite clusterSelectionComposite; - private Composite clusterCreationComposite; - private Composite clusterRegisterComposite; - private StackLayout stackLayout; - - private String clusterName; - private CLUSTER_MODE clusterMode; - private String serverName; - private Button dontAskAgainButton; - IPreferenceStore preferenceStore; - - public ClusterSelectionDialog(Shell parentShell, List clusters) { - super(parentShell); - this.clusters = clusters; - preferenceStore = Activator.getDefault().getPreferenceStore(); - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - newShell.setText("Gluster Management Console - Select Cluster"); - addEscapeListener(newShell); - } - - private void addEscapeListener(Shell shell) { - shell.addTraverseListener(new TraverseListener() { - - @Override - public void keyTraversed(TraverseEvent e) { - if (e.keyCode == SWT.ESC) { - cancelPressed(); - } - } - }); - } - - private void createClusterNameLabel(Composite composite) { - Label clusterNameLabel = new Label(composite, SWT.NONE); - clusterNameLabel.setText("Cluster &Name:"); - clusterNameLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - } - - private void createClusterNameCombo(Composite composite) { - clusterNameCombo = new Combo(composite, SWT.READ_ONLY); - clusterNameCombo.setItems(clusters.toArray(new String[0])); - clusterNameCombo.select(0); - - String clusterName = preferenceStore.getString(PreferenceConstants.P_DEFAULT_CLUSTER_NAME); - if(clusterName != null && !clusterName.isEmpty()) { - selectCluster(clusterName); - } - } - - public void selectCluster(String clusterName) { - for(int i = 0; i < clusters.size(); i++) { - if(clusterNameCombo.getItem(i).equals(clusterName)) { - clusterNameCombo.select(i); - break; - } - } - } - - private void configureDialogLayout(Composite composite) { - GridLayout layout = (GridLayout) composite.getLayout(); - layout.numColumns = 3; - layout.marginLeft = 20; - layout.marginRight = 20; - layout.marginTop = 20; - layout.horizontalSpacing = 20; - layout.verticalSpacing = 20; - } - - /** - * Overriding to make sure that the dialog is centered in screen - */ - @Override - protected void initializeBounds() { - super.initializeBounds(); - - guiHelper.centerShellInScreen(getShell()); - } - - @Override - protected Control createDialogArea(Composite parent) { - //parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); - // Makes sure that child composites inherit the same background - parent.setBackgroundMode(SWT.INHERIT_FORCE); - - composite = (Composite) super.createDialogArea(parent); - configureDialogLayout(composite); - - createRadioButtons(); - createSubComposites(); - - setupAutoSelectionIfRequired(); - - return composite; - } - - private void setupAutoSelectionIfRequired() { - if (clusters.size() == 0) { - return; - } - - final String clusterName = System.getProperty(ConsoleConstants.PROPERTY_AUTO_CLUSTER_NAME, null); - if (clusterName == null) { - return; - } - - getShell().addShellListener(new ShellAdapter() { - @Override - public void shellActivated(ShellEvent e) { - super.shellActivated(e); - clusterNameCombo.setText(clusterName); - okPressed(); - } - }); - } - - - private void createSubComposites() { - Composite subComposite = new Composite(composite, SWT.NONE); - GridData data = new GridData(); - data.horizontalSpan = 3; - subComposite.setLayoutData(data); - stackLayout = new StackLayout(); - subComposite.setLayout(stackLayout); - - createClusterSelectionComposite(subComposite, stackLayout); - createClusterCreationComposite(subComposite); - createClusterRegisterComposite(subComposite); - - createRadioButtonListeners(subComposite); - if(clusters.size() > 0) { - selectButton.setSelection(true); - stackLayout.topControl = clusterSelectionComposite; - clusterNameCombo.setFocus(); - } else { - createButton.setSelection(true); - stackLayout.topControl = clusterCreationComposite; - newClusterNameText.setFocus(); - } - subComposite.layout(); - } - - private void createClusterRegisterComposite(Composite composite) { - clusterRegisterComposite = new Composite(composite, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing = 15; - clusterRegisterComposite.setLayout(layout); - - createClusterNameLabel(clusterRegisterComposite); - existingClusterNameText = createText(clusterRegisterComposite); - existingClusterNameText.setToolTipText("Enter a name for the cluster being registered."); - existingClusterNameErrorDecoration = createErrorDecoration(existingClusterNameText, "Please enter a cluster name!"); - existingClusterNameErrorDecoration.show(); - - createClusterServerLabel(clusterRegisterComposite); - serverNameText = createText(clusterRegisterComposite); - serverNameText.setToolTipText("Enter host name / IP address of one of the servers of the cluster."); - serverNameErrorDecoration = createErrorDecoration(serverNameText, "Please enter a server name!"); - serverNameErrorDecoration.show(); - } - - private void createClusterServerLabel(Composite composite) { - Label serverNameLabel = new Label(composite, SWT.NONE); - serverNameLabel.setText("Server Na&me:"); - serverNameLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - } - - private void createClusterCreationComposite(Composite subComposite) { - clusterCreationComposite = new Composite(subComposite, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - layout.horizontalSpacing = 15; - clusterCreationComposite.setLayout(layout); - - createClusterNameLabel(clusterCreationComposite); - newClusterNameText = createText(clusterCreationComposite); - newClusterNameText.setToolTipText("Enter name of the cluster to be created"); - newClusterNameErrorDecoration = createErrorDecoration(newClusterNameText, "Please enter cluster name!"); - newClusterNameErrorDecoration.show(); - } - - private Text createText(Composite parent) { - Text text = new Text(parent, SWT.NONE); - GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); - int width = convertWidthInCharsToPixels(32); - layoutData.widthHint = width; - layoutData.minimumWidth = width; - text.setLayoutData(layoutData); - - text.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - validate(); - } - }); - - return text; - } - - private void createClusterSelectionComposite(Composite subComposite, StackLayout stackLayout) { - clusterSelectionComposite = new Composite(subComposite, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - clusterSelectionComposite.setLayout(layout); - - createClusterNameLabel(clusterSelectionComposite); - createClusterNameCombo(clusterSelectionComposite); - createPreferenceCheckbox(clusterSelectionComposite); - - stackLayout.topControl = clusterSelectionComposite; - } - - private void createPreferenceCheckbox(Composite composite) { - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); - layoutData.verticalIndent = 5; - layoutData.horizontalSpan = 2; - - dontAskAgainButton = new Button(composite, SWT.CHECK); - dontAskAgainButton.setLayoutData(layoutData); - dontAskAgainButton.setText("&Don't ask again"); - dontAskAgainButton.setEnabled(true); - dontAskAgainButton.setSelection(false); - dontAskAgainButton.setToolTipText("Always manage the selected cluster without showing this dialog box." - + "This preference can later be changed from the \"Settings\" menu."); - } - - private void createRadioButtons() { - { - if (clusters.size() > 0) { - selectButton = new Button(composite, SWT.RADIO); - selectButton.setText("&Select"); - selectButton.setToolTipText(MESSAGE_SELECT_CLUSTER); - } - } - { - createButton = new Button(composite, SWT.RADIO); - createButton.setText("&Create"); - createButton.setToolTipText(MESSAGE_CREATE_CLUSTER); - } - { - registerButton = new Button(composite, SWT.RADIO); - registerButton.setText("&Register"); - registerButton.setToolTipText(MESSAGE_REGISTER_CLUSTER); - } - } - - private void validate() { - okButton.setEnabled(false); - - if(selectButton != null && selectButton.getSelection()) { - okButton.setEnabled(true); - return; - } - - if(createButton.getSelection()) { - String newClusterName = newClusterNameText.getText().trim(); - if(newClusterName.isEmpty()) { - newClusterNameErrorDecoration.setDescriptionText("Please enter a cluster name!"); - newClusterNameErrorDecoration.show(); - } else if(clusters.contains(newClusterName)) { - newClusterNameErrorDecoration.setDescriptionText("Cluster [" + newClusterName + "] already exists!"); - newClusterNameErrorDecoration.show(); - } else { - okButton.setEnabled(true); - newClusterNameErrorDecoration.hide(); - } - } - - if(registerButton.getSelection()) { - okButton.setEnabled(true); - String clusterName = existingClusterNameText.getText().trim(); - if(existingClusterNameText.getText().trim().isEmpty()) { - existingClusterNameErrorDecoration.setDescriptionText("Please enter a cluster name!"); - existingClusterNameErrorDecoration.show(); - okButton.setEnabled(false); - } else if(clusters.contains(clusterName)) { - existingClusterNameErrorDecoration.setDescriptionText("Cluster [" + clusterName + "] already exists!"); - existingClusterNameErrorDecoration.show(); - okButton.setEnabled(false); - } else { - existingClusterNameErrorDecoration.hide(); - } - - if(serverNameText.getText().trim().isEmpty()) { - serverNameErrorDecoration.show(); - okButton.setEnabled(false); - } else { - serverNameErrorDecoration.hide(); - } - } - } - - private void createRadioButtonListeners(final Composite parent) { - if (clusters.size() > 0) { - selectButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - stackLayout.topControl = clusterSelectionComposite; - clusterNameCombo.select(0); - validate(); - parent.layout(); - clusterNameCombo.setFocus(); - } - }); - } - createButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - stackLayout.topControl = clusterCreationComposite; - validate(); - parent.layout(); - newClusterNameText.setFocus(); - } - }); - registerButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - stackLayout.topControl = clusterRegisterComposite; - validate(); - parent.layout(); - existingClusterNameText.setFocus(); - } - }); - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - - setupDataBinding(); - } - - private ControlDecoration createErrorDecoration(Text text, String message) { - ControlDecoration errorDecoration = guiHelper.createErrorDecoration(text); - errorDecoration.setDescriptionText(message); - errorDecoration.hide(); - return errorDecoration; - } - - /** - * Sets up data binding between the text fields and the connection details object. Also attaches a "string required" - * validator to the "password" text field. This validator is configured to do the following on validation failure
- *
  • show an ERROR decorator
  • disable the "Login" button - */ - private void setupDataBinding() { - clusterNameCombo.addModifyListener(new ModifyListener() { - - @Override - public void modifyText(ModifyEvent e) { - if(clusterNameCombo.getText().trim().isEmpty()) { - okButton.setEnabled(false); - newClusterNameErrorDecoration.show(); - } else { - okButton.setEnabled(true); - newClusterNameErrorDecoration.hide(); - } - } - }); - } - - @Override - protected void okPressed() { - if(selectButton != null && selectButton.getSelection()) { - clusterMode = CLUSTER_MODE.SELECT; - clusterName = clusterNameCombo.getText(); - - if(dontAskAgainButton.getSelection()) { - preferenceStore.setValue(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, false); - preferenceStore.setValue(PreferenceConstants.P_DEFAULT_CLUSTER_NAME, clusterName); - } else { - preferenceStore.setValue(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, true); - } - } else if(createButton.getSelection()) { - clusterMode = CLUSTER_MODE.CREATE; - clusterName = newClusterNameText.getText().trim(); - } else if(registerButton.getSelection()) { - clusterMode = CLUSTER_MODE.REGISTER; - clusterName = existingClusterNameText.getText().trim(); - serverName = serverNameText.getText().trim(); - } - super.okPressed(); - } - - public String getClusterName() { - return clusterName; - } - - public CLUSTER_MODE getClusterMode() { - return clusterMode; - } - - public String getServerName() { - return serverName; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java deleted file mode 100644 index d7d98d24..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumePage1.java +++ /dev/null @@ -1,473 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.utils.ValidationUtil; - -public class CreateVolumePage1 extends WizardPage { - public static final String PAGE_NAME = "create.volume.page.1"; - private Text txtName; - private ComboViewer typeComboViewer; - private Text txtAccessControl; - private Text txtCifsUsers; - private Volume volume = new Volume(); - private Button btnNfs; - private Button btnCIFS; - private Button btnStartVolume; - private Link linkCustomize; - private List allDevices; - private List selectedDevices; - - /** - * Create the wizard. - */ - public CreateVolumePage1() { - super(PAGE_NAME); - setTitle("Create Volume"); - setDescription("Create a new Volume by choosing bricks from the cluster servers and configuring the volume properties."); - - // by default, we create volume with all available disks - allDevices = GlusterDataModelManager.getInstance().getReadyDevicesOfAllServers(); - selectedDevices = allDevices; // volume.setDisks(allDisks); - } - - /** - * Create contents of the wizard. - * @param parent - */ - public void createControl(Composite parent) { - setPageComplete(false); - Composite container = createContainer(parent); - - createEmptyRow(container); - - createNameLabel(container); - createNameText(container); - - createTypeLabel(container); - createTypeCombo(container); - -// createTransportTypeLabel(container); -// createTransportTypeValueLabel(container); - - createDisksLabel(container); - createDisksCustomizeLink(container); - - createNasProtocolLabel(container); - createNasProtocolCheckboxes(container); - - createCifsUserLabel(container); - createCifsUserText(container); - - createEmptyLabel(container); - createCifsUserInfoLabel(container); - - createAccessControlLabel(container); - createAccessControlText(container); - - createEmptyLabel(container); - createAccessControlInfoLabel(container); - - createStartVolumeLabel(container); - createStartVolumeCheckbox(container); - } - - private void createStartVolumeCheckbox(Composite container) { - btnStartVolume = new Button(container, SWT.CHECK); - btnStartVolume.setSelection(true); - } - - private void createStartVolumeLabel(Composite container) { - Label lblStartVolume = new Label(container, SWT.NONE); - lblStartVolume.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblStartVolume.setText("Start Volume: "); - } - - private void createCifsUserInfoLabel(Composite container) { - Label lblCifsUserInfo = new Label(container, SWT.TOP); - lblCifsUserInfo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); - lblCifsUserInfo.setText("(Comma separated list user names)"); - } - - private void createAccessControlInfoLabel(Composite container) { - Label lblAccessControlInfo = new Label(container, SWT.TOP); - lblAccessControlInfo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); - lblAccessControlInfo.setText("(Comma separated list of IP addresses/hostnames)"); - } - - private void createEmptyLabel(Composite container) { - new Label(container, SWT.NONE); - } - - private void createAccessControlText(Composite container) { - txtAccessControl = new Text(container, SWT.BORDER); - txtAccessControl.setText("*"); - GridData accessControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - accessControlData.widthHint = 300; - txtAccessControl.setLayoutData(accessControlData); - txtAccessControl.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - validateForm(); - } - }); - } - - private void createAccessControlLabel(Composite container) { - Label lblAccessControl = new Label(container, SWT.NONE); - lblAccessControl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblAccessControl.setText("Allow Access From: "); - } - - private void createCifsUserLabel(Composite container) { - Label lblAccessControl = new Label(container, SWT.NONE); - lblAccessControl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblAccessControl.setText("CIFS Users: "); - } - - private void createCifsUserText(Composite container) { - txtCifsUsers = new Text(container, SWT.BORDER); -// txtCifsUsers.setText("testuser1,testuser2,testuser3"); - GridData cifsControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - cifsControlData.widthHint = 300; - txtCifsUsers.setLayoutData(cifsControlData); - txtCifsUsers.addModifyListener(new ModifyListener() { - - @Override - public void modifyText(ModifyEvent e) { - validateForm(); - } - }); - } - - private void createNasProtocolCheckboxes(Composite container) { - Button btnGluster = new Button(container, SWT.CHECK); - btnGluster.setEnabled(false); - btnGluster.setSelection(true); - btnGluster.setText("Gluster"); - createEmptyLabel(container); - - btnNfs = new Button(container, SWT.CHECK); - btnNfs.setEnabled(true); - btnNfs.setSelection(true); - btnNfs.setText("NFS"); - createEmptyLabel(container); - - btnCIFS = new Button(container, SWT.CHECK); - btnCIFS.setEnabled(true); - btnCIFS.setSelection(false); - btnCIFS.setText("CIFS"); - btnCIFS.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - validateForm(); - } - @Override - public void widgetDefaultSelected(SelectionEvent e) { - validateForm(); - } - }); - } - - private void createNasProtocolLabel(Composite container) { - Label lblNasProtocol = new Label(container, SWT.RIGHT); - lblNasProtocol.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblNasProtocol.setText("Access Protocol: "); - } - - private void createDisksCustomizeLink(Composite container) { - linkCustomize = new Link(container, SWT.UNDERLINE_LINK); - linkCustomize.setText("All Brick(s) (customize)" ); - linkCustomize.setEnabled(false); - linkCustomize.addListener (SWT.Selection, new Listener () { - public void handleEvent(Event event) { - Display.getDefault().asyncExec(new Runnable() { - - @Override - public void run() { - SelectDisksDialog dialog = new SelectDisksDialog(getShell(), allDevices, selectedDevices, txtName.getText().trim()); - - dialog.create(); - if(dialog.open() == Window.OK) { - // user has customized disks. get them from the dialog box. - selectedDevices = dialog.getSelectedDevices(); - linkCustomize.setText("" + selectedDevices.size() + " Brick(s) (customize)"); - validateForm(); - } - } - }); - } - }); - } - - private void createDisksLabel(Composite container) { - Label lblDisks = new Label(container, SWT.RIGHT); - lblDisks.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblDisks.setText("Bricks: "); - } - - private void createTypeCombo(Composite container) { - typeComboViewer = new ComboViewer(container, SWT.READ_ONLY); - Combo typeCombo = typeComboViewer.getCombo(); - GridData typeComboData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - typeCombo.setLayoutData(typeComboData); - typeComboViewer.setContentProvider(new ArrayContentProvider()); - - VOLUME_TYPE[] volumeTypes = new VOLUME_TYPE[3]; - volumeTypes[0] = VOLUME_TYPE.DISTRIBUTE; - volumeTypes[1] = VOLUME_TYPE.REPLICATE; - volumeTypes[2] = VOLUME_TYPE.STRIPE; - - typeComboViewer.setInput(volumeTypes); - typeCombo.select(0); // default type = Plain Distribute - typeComboViewer.setLabelProvider(new LabelProvider() { - @Override - public String getText(Object element) { - return Volume.getVolumeTypeStr((VOLUME_TYPE)element); - } - }); - typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - validateForm(); - } - }); - } - - private void createTypeLabel(Composite container) { - Label lblType = new Label(container, SWT.NONE); - lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblType.setText("Type: "); - } - - private void createNameText(Composite container) { - txtName = new Text(container, SWT.BORDER); - GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - txtNameData.widthHint = 300; - txtName.setTextLimit(32); - txtName.setLayoutData(txtNameData); - txtName.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - validateForm(); - } - }); - } - - private void createNameLabel(Composite container) { - Label lblName = new Label(container, SWT.NONE); - lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblName.setText("Name: "); - } - - private void createEmptyRow(Composite container) { - createEmptyLabel(container); - createEmptyLabel(container); - } - - private Composite createContainer(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - setControl(container); - - GridLayout gl_container = new GridLayout(2, false); - gl_container.verticalSpacing = 10; - gl_container.marginHeight = 10; - gl_container.marginLeft = 20; - gl_container.horizontalSpacing = 10; - container.setLayout(gl_container); - return container; - } - - public Volume getVolume() { - volume.setName(txtName.getText()); - - IStructuredSelection selection = (IStructuredSelection)typeComboViewer.getSelection(); - volume.setVolumeType((VOLUME_TYPE)selection.getFirstElement()); - volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); - volume.setStripeCount(Volume.DEFAULT_STRIPE_COUNT); - - volume.setTransportType(TRANSPORT_TYPE.ETHERNET); // Support only for Ethernet - Set nasProtocols = new HashSet(); - nasProtocols.add(NAS_PROTOCOL.GLUSTERFS); - nasProtocols.add(NAS_PROTOCOL.NFS); - - volume.setAccessControlList(txtAccessControl.getText()); - - if (btnNfs.getSelection()) { - volume.enableNFS(); - } else { - volume.disableNFS(); - } - - if (btnCIFS.getSelection()) { - volume.enableCifs(); - volume.setCifsUsers(Arrays.asList(txtCifsUsers.getText().split(","))); - } else { - volume.disableCifs(); - } - - addVolumeBricks(); - return volume; - } - - private void addVolumeBricks() { - // first clear existing bricks, if any - volume.getBricks().clear(); - - for (Device device : selectedDevices) { - Brick brick = new Brick(device.getServerName(), BRICK_STATUS.ONLINE, device.getMountPoint() + "/" - + volume.getName()); - volume.addBrick(brick); - } - } - - public Boolean startVolumeAfterCreation() { - return btnStartVolume.getSelection(); - } - - public Boolean volumeExists(String volumeName) { - List volumes = GlusterDataModelManager.getInstance().getModel().getCluster().getVolumes(); - for (Volume volume : volumes) { - if (volume.getName().equals(volumeName)) { - setErrorMessage("Volume name already exists."); - return false; - } - } - return true; - } - - private void validateForm() { - clearErrors(); - validateVolumeName(); - validateCifsUsers(); - validateAccessControl(); - validateDisks(); - } - - private void validateDisks() { - int diskCount = selectedDevices.size(); - - if(diskCount < 1) { - setError("At least one brick must be selected!"); - } - - VOLUME_TYPE volumeType = (VOLUME_TYPE) ((IStructuredSelection) typeComboViewer - .getSelection()).getFirstElement(); - if ((volumeType == VOLUME_TYPE.DISTRIBUTED_REPLICATE || volumeType == VOLUME_TYPE.REPLICATE ) && diskCount % 2 != 0) { - setError("Mirror type volume requires bricks in multiples of two"); - } else if ((volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE || volumeType == VOLUME_TYPE.STRIPE) && diskCount % 4 != 0) { - setError("Stripe type volume requires bricks in multiples of four"); - } - } - - private void validateAccessControl() { - String accessControl = txtAccessControl.getText().trim(); - if (accessControl.length() == 0) { - setError("Please enter Access Control"); - return; - } - - if (!ValidationUtil.isValidAccessControl(accessControl)) { - setError("Invalid IP address/Host name [" + ValidationUtil.getInvalidIpOrHostname(accessControl) - + "]. Please enter a valid value!"); - } - } - - - private void validateCifsUsers() { - if (btnCIFS.getSelection()) { - String cifsUserList = txtCifsUsers.getText().trim(); - if (cifsUserList.length() == 0) { - setError("Please enter cifs user name"); - return; - } - } - } - - private void validateVolumeName() { - String volumeName = txtName.getText().trim(); - String volumeNameToken = "^[a-zA-Z][a-zA-Z0-9\\-]*"; - - if (volumeName.length() > 0) { - linkCustomize.setEnabled(true); - } - - if(volumeName.length() == 0) { - setError("Please enter Volume Name"); - linkCustomize.setEnabled(false); - } - - if (!volumeName.matches(volumeNameToken)) { - setError("Please enter valid Volume Name"); - } - - if(!volumeExists(volumeName)) { - setError("Volume [" + volumeName + "] already exists!"); - } - } - - private void clearErrors() { - setErrorMessage(null); - setPageComplete(true); - } - - private void setError(String errorMsg) { - setPageComplete(false); - setErrorMessage(errorMsg); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java deleted file mode 100644 index 1558749c..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.util.List; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.Wizard; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; - -public class CreateVolumeWizard extends Wizard { - private static final String title = "Gluster Management Console - Create Volume"; - private CreateVolumePage1 page; - - public CreateVolumeWizard() { - setWindowTitle(title); - setHelpAvailable(false); // TODO: Introduce wizard help - } - - @Override - public void addPages() { - page = new CreateVolumePage1(); - addPage(page); - } - - @Override - public boolean performFinish() { - Volume newVolume = page.getVolume(); - VolumesClient volumesClient = new VolumesClient(); - - try { - List servers = GlusterDataModelManager.getInstance().getOfflineServers(); - // One or more servers are offline, Show warning if cifs is enabled - if (newVolume.isCifsEnable() && servers != null && servers.size() > 0) { - Integer userAction = new MessageDialog(getShell(), "Create Volume", GUIHelper.getInstance().getImage( - IImageKeys.VOLUME_16x16), - "Performing CIFS updates when one or more servers are offline can trigger " - + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE - + "Are you sure you want to continue?", MessageDialog.QUESTION, new String[] { "No", - "Yes" }, -1).open(); - if (userAction != 1) { - return false; // To stay on the create dialog - } - } - - volumesClient.createVolume(newVolume); - - // Set proper volume type before assign to model - VOLUME_TYPE volumetype = newVolume.getVolumeType(); - if (volumetype == VOLUME_TYPE.REPLICATE && newVolume.getBricks().size() > newVolume.getReplicaCount()) { - newVolume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); - } else if (volumetype == VOLUME_TYPE.STRIPE && newVolume.getBricks().size() > newVolume.getStripeCount()) { - newVolume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); - } - - handleSuccess(newVolume, volumesClient); - } catch (Exception e) { - String errMsg = e.getMessage(); - // the error could be in to post-volume-create processing. check if this is the case. - if (volumesClient.volumeExists(newVolume.getName())) { - handlePartSuccess(newVolume, volumesClient, errMsg); - } else { - MessageDialog.openError(getShell(), title, "Volume creation failed! Error: " + errMsg); - return false; - } - } - - return true; - } - - public void handleSuccess(Volume newVolume, VolumesClient volumesClient) { - String message = "Volume created successfully!"; - newVolume.setStatus(VOLUME_STATUS.OFFLINE); - boolean warning = false; - if (page.startVolumeAfterCreation()) { - try { - volumesClient.startVolume(newVolume.getName(), false); - newVolume.setStatus(VOLUME_STATUS.ONLINE); - message = "Volume created and started successfully!"; - } catch(Exception e) { - message = "Volume created successfuly, but couldn't be started. Error: " + e.getMessage(); - warning = true; - } - } - - // update the model - GlusterDataModelManager.getInstance().addVolume(newVolume); - if (warning) { - MessageDialog.openWarning(getShell(), title, message); - } else { - MessageDialog.openInformation(getShell(), title, message); - } - } - - public void handlePartSuccess(Volume newVolume, VolumesClient volumesClient, String errMsg) { - // volume exists. error was in post-volume-create - newVolume.setStatus(VOLUME_STATUS.OFFLINE); - boolean error = false; - String message1 = null; - if (page.startVolumeAfterCreation()) { - if (MessageDialog.openConfirm(getShell(), title, "Volume created, but following error(s) occured: " - + errMsg + CoreConstants.NEWLINE + CoreConstants.NEWLINE - + "Do you still want to start the volume [" + newVolume.getName() + "]?")) { - try { - volumesClient.startVolume(newVolume.getName(), false); - newVolume.setStatus(VOLUME_STATUS.ONLINE); - message1 = "Volume [" + newVolume.getName() + "] started successfully!"; // Only start operation - } catch(Exception e1) { - message1 = "Volume couldn't be started. Error: " + e1.getMessage(); - error = true; - } - } - - if (error) { - MessageDialog.openWarning(getShell(), title, message1); - } else if (message1.trim().length() > 0) { - MessageDialog.openInformation(getShell(), title, message1); - } - } else { // Start volume is not checked - MessageDialog.openWarning(getShell(), title, - "Volume created, but following error(s) occured: " + errMsg); - } - - // Fetching actual volume info (because of partial success) - Volume volume = newVolume; - try { - volume = volumesClient.getVolume(newVolume.getName()); - }catch (Exception e) { - GlusterLogger.getInstance().error("Fetching volume details failed:" + e.getMessage()); - } - GlusterDataModelManager.getInstance().addVolume(volume); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/GlusterSupportDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/GlusterSupportDialog.java deleted file mode 100644 index a2659650..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/GlusterSupportDialog.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.net.MalformedURLException; -import java.net.URL; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.FormDialog; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; - -import com.gluster.storage.management.console.utils.GUIHelper; - -public class GlusterSupportDialog extends FormDialog { - - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private FormToolkit toolkit; - private ScrolledForm form; - private Composite parent; - - public GlusterSupportDialog(Shell shell) { - super(shell); - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - this.parent = newShell; - newShell.setText("Gluster Management Console - Support Information"); - } - - protected void createFormContent(IManagedForm mform) { - form = mform.getForm(); - toolkit = mform.getToolkit(); - form.getBody().setLayout(new GridLayout()); - createSections(); - } - - private void createSections() { - contactGlusterSupportSection(); - commingSoonSection(); - form.layout(); - form.getParent().layout(); - } - - - private void contactGlusterSupportSection() { - Composite section = guiHelper.createSection(form, toolkit, "Contact Gluster Support", null, 1, false); - - FormText formText = toolkit.createFormText(section, false); - toolkit.createLabel(section, "Call 1-800-805-5215", SWT.NONE); - toolkit.createLabel(section, "or", SWT.NONE); - toolkit.createLabel(section, "Email:support@gluster.com", SWT.NONE); -// String supportInfo = "
    " + -// "Call 1-800-805-5215
    " + -// "or
    " + -// "Email:support@gluster.com" + -// "
    "; -// formText.setText(supportInfo, true, true); - GridData layoutData = new GridData(); - layoutData.widthHint = 730; - layoutData.grabExcessHorizontalSpace = true; - formText.setLayoutData(layoutData); - } - - private void commingSoonSection() { - Composite section = guiHelper.createSection(form, toolkit, "Coming Soon", null, 7, false); - FormText formText = toolkit.createFormText(section, true); - String commingSoonInfo = "
    " + - "The following features of GlusterFS will soon be supported in upcoming releases of Gluster Management Console " + - "
  • Geo-replication
  • " + - "
  • Directory Quota
  • " + - "
  • Top and Profile
  • " + - "
  • POSIX ACLs Support

  • " + - "More information about these features can be found at
    " + - "http://www.gluster.com/community/documentation/index.php/Gluster_3.2:_What_is_New_in_this_Release" + - "
    "; - formText.setText(commingSoonInfo, true, true); - GridData layoutData = new GridData(); - layoutData.widthHint = 700; - layoutData.grabExcessHorizontalSpace = true; - formText.setLayoutData(layoutData); - formText.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - System.out.println("Link activated: " + e.getHref()); - try { - PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() - .openURL(new URL((String) e.getHref())); - } catch (PartInitException e1) { - e1.printStackTrace(); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } - } - }); - } - - @Override - protected Control createButtonBar(Composite parent) { - return null; - } - /** - * Overriding to make sure that the dialog is centered in screen - */ - @Override - protected void initializeBounds() { - super.initializeBounds(); - guiHelper.centerShellInScreen(getShell()); - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java deleted file mode 100644 index 870de286..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/InitDiskDialog.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * - * InitializeDiskTypeSelection.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.Hyperlink; - -import com.gluster.storage.management.console.utils.GUIHelper; - -public class InitDiskDialog extends Dialog { - - private Combo formatTypeCombo = null; - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private Composite initializeDiskTypeComposite; - private Composite composite; - private String fsType; - private String mountPoint; - private Text mountPointText; - private String deviceName; - private List fsTypes; - private static final String DEFAULT_MOUNT_POINT = "/export/"; - - public InitDiskDialog(Shell parentShell, String deviceName, List fsTypes) { - super(parentShell); - this.fsTypes = fsTypes; - this.deviceName = deviceName; - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - newShell.setText("Gluster Management Console - Select File System Type"); - addEscapeListener(newShell); - } - - private void addEscapeListener(Shell shell) { - shell.addTraverseListener(new TraverseListener() { - - @Override - public void keyTraversed(TraverseEvent e) { - if (e.keyCode == SWT.ESC) { - cancelPressed(); - } - } - }); - } - - @Override - protected Control createDialogArea(Composite parent) { - // Makes sure that child composites inherit the same background - parent.setBackgroundMode(SWT.INHERIT_FORCE); - - composite = (Composite) super.createDialogArea(parent); - configureDialogLayout(composite); - createComposite(composite); - return composite; - } - - private void configureDialogLayout(Composite composite) { - GridLayout layout = (GridLayout) composite.getLayout(); - layout.numColumns = 3; - layout.marginLeft = 20; - layout.marginRight = 20; - layout.marginTop = 20; - layout.horizontalSpacing = 20; - layout.verticalSpacing = 20; - } - - private void createComposite(Composite composite) { - initializeDiskTypeComposite = new Composite(composite, SWT.NONE); - GridLayout layout = new GridLayout(3, false); - initializeDiskTypeComposite.setLayout(layout); - - createLabel(initializeDiskTypeComposite, "File system "); - createFormatTypeCombo(initializeDiskTypeComposite); - createLabel(initializeDiskTypeComposite, "Mount point "); - createMountPointText(initializeDiskTypeComposite); - createChangeLink(initializeDiskTypeComposite); - } - - private void createLabel(Composite composite, String labelText) { - Label formatTypeLabel = new Label(composite, SWT.NONE); - formatTypeLabel.setText(labelText); - formatTypeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); - } - - private void createFormatTypeCombo(Composite composite) { - formatTypeCombo = new Combo(composite, SWT.READ_ONLY); - formatTypeCombo.setItems(fsTypes.toArray(new String[0])); - formatTypeCombo.select(0); - new Label(composite, SWT.NONE); - } - - private void createMountPointText(Composite container) { - mountPointText = new Text(container, SWT.BORDER); - GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - txtNameData.widthHint = 400; - mountPointText.setTextLimit(100); - mountPointText.setLayoutData(txtNameData); - mountPointText.setText(DEFAULT_MOUNT_POINT + deviceName); - mountPointText.setEnabled(false); - mountPointText.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - validateMountPoint(); - } - }); - } - - private void createChangeLink(Composite container) { - final Hyperlink changeLink = new Hyperlink(container, SWT.UNDERLINE_SINGLE); - changeLink.setText("change"); - changeLink.setUnderlined(true); - changeLink.setForeground(new Color(Display.getDefault(), 0, 0, 255)); - - changeLink.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(HyperlinkEvent e) { - if (!mountPointText.isEnabled()) { - changeLink.setVisible(false); - mountPointText.setEnabled(true); - } - } - }); - } - - @Override - protected void okPressed() { - fsType = formatTypeCombo.getText().trim(); - mountPoint = mountPointText.getText().trim(); - if (validateForm()) { - super.okPressed(); - } else { - MessageDialog.openError(getShell(), "Initialize Disk - Error", "Please enter a valid mount point"); - } - } - - @Override - public void cancelPressed() { - super.cancelPressed(); - } - - private boolean validateMountPoint() { - String mountPoint = mountPointText.getText().trim(); - if (mountPoint.isEmpty()) { - return false; - } - return mountPoint.matches("^/.+"); - } - - private boolean validateForm() { - return (!formatTypeCombo.getText().trim().isEmpty() && validateMountPoint()); - } - - /** - * Overriding to make sure that the dialog is centered in screen - */ - @Override - protected void initializeBounds() { - super.initializeBounds(); - - guiHelper.centerShellInScreen(getShell()); - } - - public String getFSType() { - return fsType; - } - - public String getMountPoint() { - return mountPoint; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/LoginDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/LoginDialog.java deleted file mode 100644 index 6120f5e3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/LoginDialog.java +++ /dev/null @@ -1,359 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.databinding.DataBindingContext; -import org.eclipse.core.databinding.UpdateValueStrategy; -import org.eclipse.core.databinding.beans.PojoProperties; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.databinding.swt.SWTObservables; -import org.eclipse.jface.databinding.swt.WidgetProperties; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.client.ClustersClient; -import com.gluster.storage.management.client.UsersClient; -import com.gluster.storage.management.console.Activator; -import com.gluster.storage.management.console.ConsoleConstants; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.dialogs.ClusterSelectionDialog.CLUSTER_MODE; -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.validators.StringRequiredValidator; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.ConnectionDetails; - -/** - * Login dialog, which prompts for the user's account info, and has Login and Cancel buttons. - */ -public class LoginDialog extends Dialog { - public static final int RETURN_CODE_ERROR = 2; - private Text userIdText = null; - private Text passwordText = null; - private Button okButton; - - private final ConnectionDetails connectionDetails = new ConnectionDetails("gluster", ""); - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private Composite composite; - - public LoginDialog(Shell parentShell) { - super(parentShell); - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - newShell.setText("Gluster Management Console"); - addEscapeListener(newShell); - } - - private void addEscapeListener(Shell shell) { - shell.addTraverseListener(new TraverseListener() { - - @Override - public void keyTraversed(TraverseEvent e) { - if (e.keyCode == SWT.ESC) { - cancelPressed(); - } - } - }); - } - - private void createUserIdLabel(Composite composite) { - Label userIdLabel = new Label(composite, SWT.NONE); - userIdLabel.setText("&User ID:"); - userIdLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - } - - private void createUserIdText(Composite composite) { - userIdText = new Text(composite, SWT.BORDER); - userIdText.setText("gluster"); - userIdText.setEnabled(false); - - GridData layoutData = new GridData(convertWidthInCharsToPixels(32), 15); - userIdText.setLayoutData(layoutData); - } - - private void createPasswordLabel(Composite composite) { - Label passwordLabel = new Label(composite, SWT.NONE); - passwordLabel.setText("&Password:"); - passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - } - - private void createPasswordText(Composite composite) { - passwordText = new Text(composite, SWT.BORDER | SWT.PASSWORD); - - GridData layoutData = new GridData(convertWidthInCharsToPixels(32), 15); - passwordText.setLayoutData(layoutData); - } - - private void configureDialogLayout(Composite composite) { - GridLayout layout = (GridLayout) composite.getLayout(); - layout.numColumns = 2; - layout.marginLeft = 10; - layout.marginRight = 10; - layout.marginTop = 30; - layout.marginBottom = 0; - layout.horizontalSpacing = 20; - layout.verticalSpacing = 10; - } - - private void configureButtonCompositeLayout(Composite composite) { - GridLayout layout = (GridLayout) composite.getLayout(); - layout.marginLeft = 20; - layout.marginRight = 20; - layout.marginTop = 0; - layout.horizontalSpacing = 10; - layout.verticalSpacing = 10; - } - - /** - * Overriding to make sure that the dialog is centered in screen - */ - @Override - protected void initializeBounds() { - super.initializeBounds(); - - getShell().setSize(390, 240); - guiHelper.centerShellInScreen(getShell()); - } - - @Override - protected Control createDialogArea(Composite parent) { - parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); - // Makes sure that child composites inherit the same background - parent.setBackgroundMode(SWT.INHERIT_FORCE); - - composite = (Composite) super.createDialogArea(parent); - configureDialogLayout(composite); - GridData layoutData = new GridData(390, 110); - composite.setLayoutData(layoutData); - - createUserIdLabel(composite); - createUserIdText(composite); - - createPasswordLabel(composite); - createPasswordText(composite); - - setupAutoLoginIfRequired(); - return composite; - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - configureButtonCompositeLayout(parent); - - GridData layoutData = new GridData(390, 130); - layoutData.horizontalAlignment = SWT.CENTER; - layoutData.verticalAlignment = SWT.TOP; - layoutData.grabExcessHorizontalSpace = true; - parent.setLayoutData(layoutData); - - layoutData = new GridData(); - layoutData.widthHint = 70; - layoutData.horizontalAlignment = SWT.RIGHT; - layoutData.grabExcessHorizontalSpace = true; - - Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", false); - cancelButton.setLayoutData(layoutData); - - layoutData = new GridData(); - layoutData.widthHint = 70; - layoutData.horizontalAlignment = SWT.LEFT; - layoutData.grabExcessHorizontalSpace = true; - - okButton = createButton(parent, IDialogConstants.OK_ID, "&Login", true); - okButton.setLayoutData(layoutData); - - setupDataBinding(); - } - - private void setupAutoLoginIfRequired() { - final String password = System.getProperty(ConsoleConstants.PROPERTY_AUTO_LOGIN_PASSWORD, null); - if (password == null) { - return; - } - getShell().addShellListener(new ShellAdapter() { - @Override - public void shellActivated(ShellEvent e) { - super.shellActivated(e); - - if (passwordText.getText().isEmpty()) { - // Check whether the password has been passed as system parameter. This can be used for avoiding - // human intervention on login dialog while running SWTBot automated tests. - passwordText.setText(password); - okPressed(); - } - } - }); - } - - /** - * Sets up data binding between the text fields and the connection details object. Also attaches a "string required" - * validator to the "password" text field. This validator is configured to do the following on validation failure
    - *
  • show an ERROR decorator
  • disable the "Login" button - */ - private void setupDataBinding() { - DataBindingContext dataBindingContext = new DataBindingContext(SWTObservables.getRealm(Display.getCurrent())); - UpdateValueStrategy passwordBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - - // The Validator shows error decoration and disables OK button on - // validation failure - passwordBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter password!", guiHelper - .createErrorDecoration(passwordText), okButton)); - - dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(passwordText), - PojoProperties.value("password").observe(connectionDetails), passwordBindingStrategy, - passwordBindingStrategy); - - UpdateValueStrategy userIdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); - dataBindingContext - .bindValue(WidgetProperties.text(SWT.Modify).observe(userIdText), PojoProperties.value("userId") - .observe(connectionDetails), userIdBindingStrategy, userIdBindingStrategy); - } - - protected void okPressed() { - String user = connectionDetails.getUserId(); - String password = connectionDetails.getPassword(); - - UsersClient usersClient = new UsersClient(); - try { - usersClient.authenticate(user, password); - } catch(Exception e) { - MessageDialog.openError(getShell(), "Authentication Failed", e.getMessage()); - setReturnCode(RETURN_CODE_ERROR); - return; - } - - // authentication successful. close the login dialog and open the next one. - close(); - - IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - boolean showClusterSelectionDialog = preferenceStore.getBoolean(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG); - - // If the password is default, Let user to change the password - if (password.equalsIgnoreCase(CoreConstants.DEFAULT_PASSWORD)) { - String oldSecurityTokeString = GlusterDataModelManager.getInstance().getSecurityToken(); - ChangePasswordDialog dialog = new ChangePasswordDialog(getShell()); - - if (dialog.open() == Dialog.CANCEL) { - MessageDialog.openError(getShell(), "Change password Cancelled", - "Password must be changed on first login!" + CoreConstants.NEWLINE + "Application will close."); - cancelPressed(); - return; - } - - // after first login, cluster selection dialog must be shown. - showClusterSelectionDialog = true; - } - - ClustersClient clustersClient = new ClustersClient(); - - CLUSTER_MODE mode; - String clusterName = null; - if (!showClusterSelectionDialog) { - clusterName = preferenceStore.getString(PreferenceConstants.P_DEFAULT_CLUSTER_NAME); - if (clusterName == null || clusterName.isEmpty()) { - // Cluster name not available in preferences. Hence we must show the cluster selection dialog. - showClusterSelectionDialog = true; - } else { - mode = CLUSTER_MODE.SELECT; - } - } - - String serverName = null; - - if (showClusterSelectionDialog) { - ClusterSelectionDialog clusterDialog = new ClusterSelectionDialog(getParentShell(), - clustersClient.getClusterNames()); - int userAction = clusterDialog.open(); - if (userAction == Window.CANCEL) { - MessageDialog.openError(getShell(), "Login Cancelled", - "User cancelled login at cluster selection. Application will close!"); - cancelPressed(); - return; - } - mode = clusterDialog.getClusterMode(); - clusterName = clusterDialog.getClusterName(); - serverName = clusterDialog.getServerName(); - } else { - mode = CLUSTER_MODE.SELECT; - } - - try { - createOrRegisterCluster(clustersClient, clusterName, serverName, mode); - - final String clusterName1 = clusterName; - new ProgressMonitorDialog(getShell()).run(true, false, new IRunnableWithProgress() { - - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - GlusterDataModelManager.getInstance().initializeModel(clusterName1, monitor); - } - }); - super.okPressed(); - } catch (Exception e) { - String errMsg; - if(e instanceof InvocationTargetException) { - errMsg = ((InvocationTargetException) e).getTargetException().getMessage(); - } else { - errMsg = e.getMessage(); - } - setReturnCode(RETURN_CODE_ERROR); - MessageDialog.openError(getShell(), "Gluster Management Console", errMsg); - } - } - - public void createOrRegisterCluster(ClustersClient clustersClient, String clusterName, String serverName, - CLUSTER_MODE mode) { - switch (mode) { - case SELECT: - return; - case CREATE: - clustersClient.createCluster(clusterName); - break; - case REGISTER: - clustersClient.registerCluster(clusterName, serverName); - break; - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java deleted file mode 100644 index e3d9d2bf..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickPage1.java +++ /dev/null @@ -1,302 +0,0 @@ -/** - * MigrateBrickPage1.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ - -package com.gluster.storage.management.console.dialogs; - -import java.util.List; - -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.TableLabelProviderAdapter; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.utils.NumberUtil; - -public class MigrateBrickPage1 extends WizardPage { - private static final String PAGE_NAME = "migrate.disk.page.1"; - - private enum DISK_TABLE_COLUMN_INDICES { - SERVER, BRICK_DIRECTORY, FREE_SPACE, TOTAL_SPACE - } - - private static final String[] DISK_TABLE_COLUMN_NAMES = { "Server", "Brick Directory", "Free Space (GB)", "Total Space (GB)" }; - - private Volume volume; - private Brick fromBrick; - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - - private TableViewer tableViewerTo; - - private TableViewer tableViewerFrom; - - private Button autoCompleteCheckbox; - - private ITableLabelProvider getBrickLabelProvider(final String volumeName) { - return new TableLabelProviderAdapter() { - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Brick)) { - return null; - } - Brick brick = (Brick) element; - GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - Device device = modelManager.getDeviceForBrickDir(brick); - // convert MB to GB - String freeSpace = (device == null ? "NA" : NumberUtil.formatNumber(device.getFreeSpace() / 1024)); - String totalSpace = (device == null ? "NA" : NumberUtil.formatNumber(device.getSpace() / 1024)); - return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? brick.getServerName() - : columnIndex == DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY.ordinal() ? brick.getBrickDirectory() - : columnIndex == DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? freeSpace - : columnIndex == DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? totalSpace - : "Invalid"); - } - }; - } - - private ITableLabelProvider getDiskLabelProvider(final String volumeName) { - return new TableLabelProviderAdapter() { - - @Override - public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof Device)) { - return null; - } - Device device = (Device) element; - return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? device.getServerName() - : columnIndex == DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY.ordinal() ? device.getMountPoint() + "/" + volumeName - : columnIndex == DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? NumberUtil.formatNumber(device.getFreeSpace() / 1024 ) /* Coverted to GB */ - : columnIndex == DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? NumberUtil.formatNumber(device.getSpace() / 1024) : "Invalid"); - } - }; - } - - private void setupDiskTable(Composite parent, Table table) { - table.setHeaderVisible(true); - table.setLinesVisible(false); - - TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, DISK_TABLE_COLUMN_NAMES); - parent.setLayout(tableColumnLayout); - - setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SERVER, SWT.CENTER, 100); - setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY, SWT.CENTER, 100); - setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.FREE_SPACE, SWT.CENTER, 90); - setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE, SWT.CENTER, 90); - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - public void setColumnProperties(Table table, DISK_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } - - /** - * Create the wizard. - */ - public MigrateBrickPage1(Volume volume, Brick brick) { - super(PAGE_NAME); - this.volume = volume; - this.fromBrick = brick; - setTitle("Migrate Brick [" + volume.getName() + "]"); - setPageDescription(fromBrick.getQualifiedName(), null); - setPageComplete(false); - } - - private void setPageDescription(String source, String target) { - if (source == null) { - source = ""; - } - if (target == null) { - target = ""; - } - setDescription("Migrate data from \"" + source + "\" to \"" + target + "\""); - } - - private Object getSelectedItem(TableViewer tableViewer) { - TableItem[] selectedItems = tableViewer.getTable().getSelection(); - Object selectedDevice = null; - for (TableItem item : selectedItems) { - selectedDevice = item.getData(); - } - return selectedDevice; - } - - private void setupPageLayout(Composite container) { - final GridLayout layout = new GridLayout(2, false); - layout.verticalSpacing = 10; - layout.horizontalSpacing = 10; - layout.marginTop = 10; - layout.marginLeft = 10; - layout.marginRight = 10; - container.setLayout(layout); - } - - private Composite createTableViewerComposite(Composite parent) { - Composite tableViewerComposite = new Composite(parent, SWT.NONE); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - return tableViewerComposite; - } - - public String getSourceBrickDir() { - Brick sourceBrick = (Brick)getSelectedItem(tableViewerFrom); - return sourceBrick.getQualifiedName(); - } - - public String getTargetBrickDir() { - Device targetDevice = (Device)getSelectedItem(tableViewerTo); - if (targetDevice == null) { - return ""; - } - return targetDevice.getQualifiedBrickName(volume.getName()); - } - - public Boolean getAutoCommitSelection() { - return autoCompleteCheckbox.getSelection(); - } - - /** - * Create contents of the wizard. - * - * @param parent - */ - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - setControl(container); - - setupPageLayout(container); - - GridData labelLayoutData = new GridData(SWT.LEFT, SWT.BOTTOM, true, false); - labelLayoutData.minimumWidth = 100; - labelLayoutData.verticalAlignment = SWT.BOTTOM; - //labelLayoutData.verticalIndent = 10; - - Label lblFromDisk = new Label(container, SWT.NONE); - lblFromDisk.setText("From Brick:"); - lblFromDisk.setLayoutData(labelLayoutData); - Label lblToDisk = new Label(container, SWT.NONE); - lblToDisk.setText("To Brick:"); - lblToDisk.setLayoutData(labelLayoutData); - - Text txtFilterFrom = guiHelper.createFilterText(container); - Text txtFilterTo = guiHelper.createFilterText(container); - - GlusterDataModelManager glusterDataModelManager = GlusterDataModelManager.getInstance(); - List fromBricks = volume.getBricks(); - List toDevices = glusterDataModelManager.getReadyDevicesOfAllServersExcluding(glusterDataModelManager - .getDevicesOfVolume(volume)); - - tableViewerFrom = createTableViewer(container, getBrickLabelProvider(volume.getName()), fromBricks, - txtFilterFrom); - - if(fromBrick != null) { - setFromDisk(tableViewerFrom, fromBrick); - } - tableViewerTo = createTableViewer(container, getDiskLabelProvider(volume.getName()), toDevices, txtFilterTo); - tableViewerTo.setSelection(new StructuredSelection(fromBrick)); - - // Auto commit selection field - Composite autoCommitContainer = new Composite(container, SWT.NONE); - GridData data = new GridData(); - data.horizontalSpan = 2; - autoCommitContainer.setLayoutData(data); - autoCompleteCheckbox = new Button(autoCommitContainer, SWT.CHECK); - autoCompleteCheckbox.setSelection(true); - Label lblAutoComplete = new Label(autoCommitContainer, SWT.NONE); - lblAutoComplete.setText("Auto commit on migration complete"); - autoCommitContainer.setLayout( container.getLayout()); - } - - private void setFromDisk(TableViewer tableViewer, Brick brickToSelect) { - Table table = tableViewer.getTable(); - for (int i = 0; i < table.getItemCount(); i++) { - TableItem item = table.getItem(i); - if (item.getData() == brickToSelect) { - table.select(i); - return; - } - } - } - - private void refreshButtonStatus() { - if(tableViewerFrom.getSelection().isEmpty() || tableViewerTo.getSelection().isEmpty()) { - setPageComplete(false); - } else { - setPageComplete(true); - } - } - - private TableViewer createTableViewer(Composite container, ITableLabelProvider diskLabelProvider, - List bricks, Text txtFilterText) { - Composite tableViewerComposite = createTableViewerComposite(container); - - TableViewer tableViewer = new TableViewer(tableViewerComposite, SWT.SINGLE); - tableViewer.setContentProvider(new ArrayContentProvider()); - tableViewer.setLabelProvider(diskLabelProvider); - - setupDiskTable(tableViewerComposite, tableViewer.getTable()); - guiHelper.createFilter(tableViewer, txtFilterText, false); - - tableViewer.setInput(bricks.toArray()); - - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - - @Override - public void selectionChanged(SelectionChangedEvent event) { - refreshButtonStatus(); - setPageDescription(getSourceBrickDir(), getTargetBrickDir()); - } - }); - return tableViewer; - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickWizard.java deleted file mode 100644 index 589b065f..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/MigrateBrickWizard.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.net.URI; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.wizard.Wizard; - -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.model.Volume; - -public class MigrateBrickWizard extends Wizard { - private Volume volume; - private Brick brick; - private MigrateBrickPage1 page; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private Cluster cluster = modelManager.getModel().getCluster(); - - public MigrateBrickWizard(Volume volume, Brick brick) { - setWindowTitle("Gluster Management Console - Migrate Brick [" + volume.getName() + "]"); - this.volume = volume; - this.brick = brick; - setHelpAvailable(false); // TODO: Introduce wizard help - } - - @Override - public void addPages() { - page = new MigrateBrickPage1(volume, brick); - addPage(page); - } - - @Override - public boolean performFinish() { - - String sourceDir = page.getSourceBrickDir(); - String targetDir = page.getTargetBrickDir(); - Boolean autoCommit = page.getAutoCommitSelection(); - VolumesClient volumesClient = new VolumesClient(); - String dialogTitle = "Brick migration"; - - try { - String reference = volume.getName() + "-" + sourceDir + "-" + targetDir; - TaskInfo existingTaskInfo = GlusterDataModelManager.getInstance().getTaskByReference(reference); - if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS - && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { - MessageDialog.openInformation(getShell(), dialogTitle, "Volume brick [" + reference - + "] migration is already in progress! Try later."); - return true; - } - - URI uri = volumesClient.startMigration(volume.getName(), sourceDir, targetDir, autoCommit); - - // To get the object - TasksClient taskClient = new TasksClient(); - TaskInfo taskInfo = taskClient.getTaskInfo(uri); - if (taskInfo != null) { - // cluster.addTaskInfo(taskInfo); - String volumeName = taskInfo.getReference().split("#")[0]; - modelManager.addTask(taskInfo); - modelManager.refreshVolumeData(cluster.getVolume(volumeName)); - - // If auto commit selected and migration operation complete immediately, - if (taskInfo.getStatus().getCode() == TaskStatus.STATUS_CODE_SUCCESS) { - Volume oldVolume = cluster.getVolume(volumeName); - Volume newVolume = (new VolumesClient()).getVolume(volumeName); - - modelManager.volumeChanged(oldVolume, newVolume); - - MessageDialog.openInformation(getShell(), dialogTitle, "Brick migration completed successfully"); - return true; - } - } - MessageDialog.openInformation(getShell(), dialogTitle, "Brick migration started successfully"); - GUIHelper.getInstance().showTaskView(); - - } catch (Exception e) { - MessageDialog.openError(getShell(), dialogTitle, "Brick Migration failed! [" + e.getMessage() + "]"); - } - return true; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/SelectDisksDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/SelectDisksDialog.java deleted file mode 100644 index 42c5e782..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/SelectDisksDialog.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.dialogs; - -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Device; - -public class SelectDisksDialog extends Dialog { - - private BricksSelectionPage disksPage; - private List allDevices; - private List selectedDevices; - private String volumeName; - - /** - * Create the dialog. - * - * @param parentShell - */ - public SelectDisksDialog(Shell parentShell, List allDevices, List selectedDevices, String volumeName) { - super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); - this.allDevices = allDevices; - this.selectedDevices = selectedDevices; - this.volumeName = volumeName; - } - - /** - * Create contents of the dialog. - * - * @param parent - */ - @Override - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - GridLayout containerLayout = new GridLayout(2, false); - container.setLayout(containerLayout); - GridData containerLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - container.setLayoutData(containerLayoutData); - - getShell().setText("Create Volume - Select Bricks"); - - disksPage = new BricksSelectionPage(container, SWT.NONE, allDevices, selectedDevices, volumeName); - return container; - } - - /** - * Create contents of the button bar. - * - * @param parent - */ - @Override - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - /** - * Return the initial size of the dialog. - */ - @Override - protected Point getInitialSize() { - return new Point(1024, 600); - } - - - @Override - protected void okPressed() { - if (this.getSelectedDevices().size() == 0) { - MessageDialog.openError(getShell(), "Select Brick(s)", "Please select atlease one brick"); - } else { - super.okPressed(); - } - } - - public List getSelectedDevices() { - return disksPage.getChosenDevices(); - } - - public Set getSelectedBricks(String volumeName) { - return disksPage.getChosenBricks(volumeName); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ServerAdditionDialog.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ServerAdditionDialog.java deleted file mode 100644 index 9781f348..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/ServerAdditionDialog.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * ServerAdditionDialog.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.dialogs; - -import java.net.URI; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.gluster.storage.management.client.GlusterServersClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.GlusterServer; - -public class ServerAdditionDialog extends Dialog { - public static final int RETURN_CODE_ERROR = 2; - private Text serverName; - private Button addButton; - - private GUIHelper guiHelper = GUIHelper.getInstance(); - private ControlDecoration errDecoration; - - private Composite composite; - - public ServerAdditionDialog(Shell shell) { - super(shell); - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - newShell.setText("Gluster Management Console - Add Server"); - addEscapeListener(newShell); - } - - private void addEscapeListener(Shell shell) { - shell.addTraverseListener(new TraverseListener() { - - @Override - public void keyTraversed(TraverseEvent e) { - if (e.keyCode == SWT.ESC) { - cancelPressed(); - } - } - }); - } - - /** - * Overriding to make sure that the dialog is centered in screen - */ - @Override - protected void initializeBounds() { - super.initializeBounds(); - - guiHelper.centerShellInScreen(getShell()); - } - - private void configureDialogLayout(Composite composite) { - GridLayout layout = (GridLayout) composite.getLayout(); - layout.numColumns = 2; - layout.marginLeft = 20; - layout.marginRight = 20; - layout.marginTop = 20; - layout.horizontalSpacing = 20; - layout.verticalSpacing = 20; - } - - // ------------------------------------------ - - private void createLabel(Composite composite, String label) { - Label passwordLabel = new Label(composite, SWT.NONE); - passwordLabel.setText(label); - passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); - } - - private Text createServerNameText(Composite composite) { - Text field = new Text(composite, SWT.BORDER ); - GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); - layoutData.widthHint = convertWidthInCharsToPixels(32); - field.setLayoutData(layoutData); - return field; - } - - @Override - protected Control createDialogArea(Composite parent) { - composite = (Composite) super.createDialogArea(parent); - configureDialogLayout(composite); - - createLabel(composite, "Server Name:"); - serverName = createServerNameText(composite); - errDecoration = guiHelper.createErrorDecoration(serverName); - - createListeners(); - - return composite; - } - - private void createListeners() { - ModifyListener listener = new ModifyListener() { - - @Override - public void modifyText(ModifyEvent e) { - updateButtonStatus(); - } - }; - - serverName.addModifyListener(listener); - } - - private void updateButtonStatus() { - addButton.setEnabled(true); - errDecoration.hide(); - - if(!serverExists(serverName.getText())) { - addButton.setEnabled(false); - errDecoration.setDescriptionText("Server name already exists."); - errDecoration.show(); - } - - if(serverName.getText().isEmpty()) { - addButton.setEnabled(false); - errDecoration.setDescriptionText("Please enter server name!"); - errDecoration.show(); - } - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - addButton = createButton(parent, IDialogConstants.OK_ID, "&Add Server", true); - addButton.setEnabled(false); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - } - - public Boolean serverExists(String serverName) { - List servers = GlusterDataModelManager.getInstance().getModel().getCluster().getServers(); - for (GlusterServer server : servers) { - if (server.getName().equalsIgnoreCase(serverName)) { - return false; - } - } - return true; - } - - protected void okPressed() { - GlusterServersClient serversClient = new GlusterServersClient(); - GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - try { - String serverNameText = serverName.getText(); - URI newServerURI = serversClient.addServer(serverNameText); - - modelManager.addGlusterServer(serversClient.getGlusterServer(newServerURI)); - - MessageDialog - .openInformation(getShell(), "Add Server", "Server " + serverNameText + " added successfully!"); - } catch (Exception e) { - MessageDialog.openError(getShell(), "Server addition Failed", e.getMessage()); - setReturnCode(RETURN_CODE_ERROR); - } - this.close(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/jobs/DataSyncJob.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/jobs/DataSyncJob.java deleted file mode 100644 index 907d7b84..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/jobs/DataSyncJob.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.jobs; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.swt.widgets.Display; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.model.GlusterDataModel; - -/** - * - */ -public class DataSyncJob extends Job { - private static final GlusterLogger logger = GlusterLogger.getInstance(); - - public DataSyncJob(String name) { - super(name); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - protected IStatus run(final IProgressMonitor monitor) { - final GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - // fetch the latest model - final GlusterDataModel model = modelManager.fetchModel(monitor); - if(model == null) { - return Status.CANCEL_STATUS; - } - - monitor.beginTask("Notify views", 1); - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - modelManager.updateModel(model); - } - }); - monitor.worked(1); - monitor.done(); - - return Status.OK_STATUS; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/AlertsPreferencePage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/AlertsPreferencePage.java deleted file mode 100644 index be8513fc..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/AlertsPreferencePage.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.gluster.storage.management.console.preferences; - -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.gluster.storage.management.console.Activator; - -public class AlertsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public AlertsPreferencePage() { - super(GRID); - setPreferenceStore(Activator.getDefault().getPreferenceStore()); - setDescription("Gluster Management Console - Alerts"); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - @Override - protected void createFieldEditors() { - addField(new IntegerFieldEditor(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD, - "&Server CPU usage threshold:", getFieldEditorParent())); - - addField(new IntegerFieldEditor(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD, - "&Server memory usage threshold (%):", getFieldEditorParent())); - - addField(new IntegerFieldEditor(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD, - "&Disk space usage threshold (%):", getFieldEditorParent())); - } - - @Override - public void init(IWorkbench workbench) { - // TODO Auto-generated method stub - - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/ChartsPreferencePage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/ChartsPreferencePage.java deleted file mode 100644 index 8eeb84ab..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/ChartsPreferencePage.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.preferences; - -import org.eclipse.jface.preference.ComboFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.gluster.storage.management.console.Activator; - -/** - * - */ -public class ChartsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public ChartsPreferencePage() { - super(GRID); - setPreferenceStore(Activator.getDefault().getPreferenceStore()); - setDescription("Gluster Management Console"); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - @Override - public void init(IWorkbench workbench) { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() - */ - @Override - protected void createFieldEditors() { - String[][] entryNamesAndValues = new String[][] { - { "1 day", "1d" }, { "1 week", "1w" }, { "1 month", "1m" }, { "1 year", "1y" } }; - addField(new ComboFieldEditor(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD, "Aggregated CPU Usage chart period", entryNamesAndValues, - getFieldEditorParent())); - addField(new ComboFieldEditor(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD, "Aggregated Network Usage chart period", entryNamesAndValues, - getFieldEditorParent())); - addField(new ComboFieldEditor(PreferenceConstants.P_CPU_CHART_PERIOD, "CPU Usage chart period", entryNamesAndValues, - getFieldEditorParent())); - addField(new ComboFieldEditor(PreferenceConstants.P_MEM_CHART_PERIOD, "Memory Usage chart period", entryNamesAndValues, - getFieldEditorParent())); - addField(new ComboFieldEditor(PreferenceConstants.P_NETWORK_CHART_PERIOD, "Network Usage chart period", entryNamesAndValues, - getFieldEditorParent())); - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/GlusterPreferencePage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/GlusterPreferencePage.java deleted file mode 100644 index 2fc8de0e..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/GlusterPreferencePage.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.preferences; - -import java.util.List; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.ComboFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.gluster.storage.management.client.ClustersClient; -import com.gluster.storage.management.console.Activator; - -/** - * This class represents a preference page that - * is contributed to the Preferences dialog. By - * subclassing FieldEditorPreferencePage, we - * can use the field support built into JFace that allows - * us to create a page that is small and knows how to - * save, restore and apply itself. - *

    - * This page is used to modify preferences only. They - * are stored in the preference store that belongs to - * the main plug-in class. That way, preferences can - * be accessed directly via the preference store. - */ -public class GlusterPreferencePage - extends FieldEditorPreferencePage - implements IWorkbenchPreferencePage { - - private List clusterNames; - - public GlusterPreferencePage() { - super(GRID); - setPreferenceStore(Activator.getDefault().getPreferenceStore()); - setDescription("Gluster Management Console"); - } - - /** - * Creates the field editors. Field editors are abstractions of - * the common GUI blocks needed to manipulate various types - * of preferences. Each field editor knows how to save and - * restore itself. - */ - public void createFieldEditors() { - addField( - new BooleanFieldEditor( - PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, - "&Show Cluster Selection Dialog on Login:", - getFieldEditorParent())); - - String[][] clusterNamesArr = new String[clusterNames.size()][2]; - for(int i = 0; i < clusterNames.size(); i++) { - String clusterName = clusterNames.get(i); - clusterNamesArr[i][0] = clusterName; - clusterNamesArr[i][1] = clusterName; - } - - addField(new ComboFieldEditor(PreferenceConstants.P_DEFAULT_CLUSTER_NAME, "Default &Cluster to manage:", - clusterNamesArr, getFieldEditorParent())); - addField(new IntegerFieldEditor(PreferenceConstants.P_DATA_SYNC_INTERVAL, "&Refresh Interval (sec):", - getFieldEditorParent())); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) - */ - public void init(IWorkbench workbench) { - clusterNames = new ClustersClient().getClusterNames(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceConstants.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceConstants.java deleted file mode 100644 index 650ae1a9..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.preferences; - -/** - * Constant definitions for plug-in preferences - */ -public class PreferenceConstants { - - public static final String P_SHOW_CLUSTER_SELECTION_DIALOG = "show.cluster.selection.dialog"; - public static final String P_DEFAULT_CLUSTER_NAME = "default.cluster.name"; - public static final String P_DATA_SYNC_INTERVAL = "data.sync.interval"; - - public static final String P_SERVER_CPU_CRITICAL_THRESHOLD = "server.cpu.threshold"; - public static final String P_SERVER_MEMORY_USAGE_THRESHOLD = "server.memory.threshold"; - public static final String P_DISK_SPACE_USAGE_THRESHOLD = "disk.space.threshold"; // in percentage - - public static final String P_CPU_CHART_PERIOD = "cpu.chart.period"; - public static final String P_MEM_CHART_PERIOD = "memory.chart.period"; - public static final String P_NETWORK_CHART_PERIOD = "network.chart.period"; - public static final String P_DEFAULT_NETWORK_INTERFACE_PFX = "default.network.interface."; - public static final String P_CPU_AGGREGATED_CHART_PERIOD = "cpu.aggregated.chart.period"; - public static final String P_NETWORK_AGGREGATED_CHART_PERIOD = "network.aggregated.chart.period"; -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceInitializer.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceInitializer.java deleted file mode 100644 index 72e62447..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/preferences/PreferenceInitializer.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.preferences; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; - -import com.gluster.storage.management.console.Activator; - -/** - * Class used to initialize default preference values. - */ -public class PreferenceInitializer extends AbstractPreferenceInitializer { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() - */ - public void initializeDefaultPreferences() { - IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - - store.setDefault(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, true); - - // default data sync interval = 5 minutes - store.setDefault(PreferenceConstants.P_DATA_SYNC_INTERVAL, 300); - - // Default CPU utilisation threshold - store.setDefault(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD, 80); - - // Default Memory threshold - store.setDefault(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD, 80); - - // Default disk free space threshold - store.setDefault(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD, 80); - - // Default period for server statistics charts - store.setDefault(PreferenceConstants.P_CPU_CHART_PERIOD, "1d"); - store.setDefault(PreferenceConstants.P_MEM_CHART_PERIOD, "1d"); - store.setDefault(PreferenceConstants.P_NETWORK_CHART_PERIOD, "1d"); - store.setDefault(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD, "1d"); - store.setDefault(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD, "1d"); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/GlusterToolbarManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/GlusterToolbarManager.java deleted file mode 100644 index ebd1db07..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/GlusterToolbarManager.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.toolbar; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; - -import com.gluster.storage.management.console.actions.ActionConstants; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.Volume; - -public class GlusterToolbarManager implements ToolbarManager { - private enum ENTITY_TYPE { - CLUSTER, VOLUMES, VOLUME, GLUSTER_SERVERS, GLUSTER_SERVER, DISCOVERED_SERVERS, DISCOVERED_SERVER, TASK - }; - - private IWorkbenchWindow window; - private final Map, ENTITY_TYPE> entityTypeMap = createEntityTypeMap(); - private final Map actionSetMap = createActionSetMap(); - - private Map, ENTITY_TYPE> createEntityTypeMap() { - Map, ENTITY_TYPE> entityTypeMap = new HashMap, GlusterToolbarManager.ENTITY_TYPE>(); - entityTypeMap.put(Cluster.class, ENTITY_TYPE.CLUSTER); - entityTypeMap.put(Volume.class, ENTITY_TYPE.VOLUME); - entityTypeMap.put(Server.class, ENTITY_TYPE.DISCOVERED_SERVER); - entityTypeMap.put(GlusterServer.class, ENTITY_TYPE.GLUSTER_SERVER); - entityTypeMap.put(TaskInfo.class, ENTITY_TYPE.TASK); - - return entityTypeMap; - } - - private Map createActionSetMap() { - Map actionSetMap = new HashMap(); - actionSetMap.put(ENTITY_TYPE.CLUSTER, ActionConstants.ACTION_SET_CLUSTER); - actionSetMap.put(ENTITY_TYPE.VOLUMES, ActionConstants.ACTION_SET_VOLUMES); - actionSetMap.put(ENTITY_TYPE.VOLUME, ActionConstants.ACTION_SET_VOLUME); - actionSetMap.put(ENTITY_TYPE.GLUSTER_SERVERS, ActionConstants.ACTION_SET_GLUSTER_SERVERS); - actionSetMap.put(ENTITY_TYPE.GLUSTER_SERVER, ActionConstants.ACTION_SET_GLUSTER_SERVER); - actionSetMap.put(ENTITY_TYPE.DISCOVERED_SERVERS, ActionConstants.ACTION_SET_DISCOVERED_SERVERS); - actionSetMap.put(ENTITY_TYPE.DISCOVERED_SERVER, ActionConstants.ACTION_SET_DISCOVERED_SERVER); - actionSetMap.put(ENTITY_TYPE.TASK, ActionConstants.ACTION_SET_TASK); - - return actionSetMap; - } - - public GlusterToolbarManager(IWorkbenchWindow window) { - this.window = window; - } - - @SuppressWarnings("rawtypes") - private ENTITY_TYPE getEntityType(Entity entity) { - if (entity instanceof EntityGroup) { - EntityGroup entityGroup = (EntityGroup) entity; - if (entityGroup.getEntityType() == Volume.class) { - return ENTITY_TYPE.VOLUMES; - } else if (entityGroup.getEntityType() == GlusterServer.class) { - return ENTITY_TYPE.GLUSTER_SERVERS; - } else { - return ENTITY_TYPE.DISCOVERED_SERVERS; - } - } - - return entityTypeMap.get(entity.getClass()); - } - - @Override - public void updateToolbar(Entity entity) { - ENTITY_TYPE entityType = getEntityType(entity); - IWorkbenchPage page = window.getActivePage(); - - for (ENTITY_TYPE targetEntityType : actionSetMap.keySet()) { - String actionSetId = actionSetMap.get(targetEntityType); - if (entityType == targetEntityType) { - // show only the action set mapped to given entity - page.showActionSet(actionSetId); - } else { - page.hideActionSet(actionSetId); - } - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/ToolbarManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/ToolbarManager.java deleted file mode 100644 index 8dc14ffd..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/toolbar/ToolbarManager.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.toolbar; - -import com.gluster.storage.management.core.model.Entity; - -/** - * Whenever the current selection/action demands changes to the toolbar, the toolbar manager is used to update the - * toolbar. - */ -public interface ToolbarManager { - /** - * Updates the toolbar for given entity. This typically means that user is working with the given entity, and hence - * the toolbar actions related to that entity should be made visible, and other un-related actions should be hidden. - * - * @param entity - */ - public void updateToolbar(Entity entity); -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartUtil.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartUtil.java deleted file mode 100644 index 57121f5b..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartUtil.java +++ /dev/null @@ -1,339 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.utils; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.birt.chart.util.CDateTime; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; - -import com.gluster.storage.management.console.Activator; -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.NetworkInterface; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.ServerStatsRow; -import com.ibm.icu.util.Calendar; - -/** - * - */ -public class ChartUtil { - private static final ChartUtil instance = new ChartUtil(); - private static final int CHART_WIDTH = 350; - private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - - private ChartUtil() { - } - - public static ChartUtil getInstance() { - return instance; - } - - /** - * @param toolkit - * @param section - * @param stats - * @param dataColumnIndex - * @param unit - * @param timestampFormat - * @param listener - * @param maxValue - * @return The composite containing the various links related to the created chart - */ - public Composite createAreaChart(FormToolkit toolkit, Composite section, ServerStats stats, int dataColumnIndex, - String unit, String timestampFormat, ChartPeriodLinkListener listener, double maxValue, int linkColumnCount) { - if (stats == null) { - toolkit.createLabel(section, "Server statistics not available. Try after some time!"); - return null; - } - - List timestamps = new ArrayList(); - List data = new ArrayList(); - - extractChartData(stats, timestamps, data, dataColumnIndex); - - if (timestamps.size() == 0) { - toolkit.createLabel(section, "Server statistics not available!" + CoreConstants.NEWLINE - + "Check if all services are running properly " + CoreConstants.NEWLINE - + "on the cluster servers, or try after some time!"); - return null; - } - - createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit, - timestampFormat, maxValue); - - // Calendar[] timestamps = new Calendar[] { new CDateTime(1000l*1310468100), new CDateTime(1000l*1310468400), - // new CDateTime(1000l*1310468700), - // new CDateTime(1000l*1310469000), new CDateTime(1000l*1310469300), new CDateTime(1000l*1310469600), new - // CDateTime(1000l*1310469900), - // new CDateTime(1000l*1310470200), new CDateTime(1000l*1310470500), new CDateTime(1000l*1310470800), new - // CDateTime(1000l*1310471100), - // new CDateTime(1000l*1310471400), new CDateTime(1000l*1310471700), new CDateTime(1000l*1310472000), new - // CDateTime(1000l*1310472300), - // new CDateTime(1000l*1310472600), new CDateTime(1000l*1310472900), new CDateTime(1000l*1310473200), new - // CDateTime(1000l*1310473500), - // new CDateTime(1000l*1310473800) }; - // - // Double[] values = new Double[] { 10d, 11.23d, 17.92d, 18.69d, 78.62d, 89.11d, 92.43d, 89.31d, 57.39d, 18.46d, - // 10.44d, 16.28d, 13.51d, 17.53d, 12.21, 20d, 21.43d, 16.45d, 14.86d, 15.27d }; - // createLineChart(section, timestamps, values, "%"); - Composite chartLinksComposite = createChartLinks(toolkit, section, linkColumnCount, listener); - - if (linkColumnCount == 5) { - createNetworkInterfaceCombo(section, chartLinksComposite, toolkit, - (NetworkChartPeriodLinkListener) listener); - } - return chartLinksComposite; - } - - private ChartViewerComposite createAreaChart(Composite section, Calendar timestamps[], Double values[], - String unit, String timestampFormat, double maxValue) { - ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, - unit, timestampFormat, maxValue); - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = CHART_WIDTH; - data.heightHint = 250; - data.verticalAlignment = SWT.CENTER; - chartViewerComposite.setLayoutData(data); - return chartViewerComposite; - } - - private void extractChartData(ServerStats stats, List timestamps, List data, int dataColumnIndex) { - for (ServerStatsRow row : stats.getRows()) { - Double cpuUsage = row.getUsageData().get(dataColumnIndex); - if (!cpuUsage.isNaN()) { - timestamps.add(new CDateTime(row.getTimestamp() * 1000)); - data.add(cpuUsage); - } - } - } - - private Composite createChartLinks(FormToolkit toolkit, Composite section, int columnCount, - ChartPeriodLinkListener listener) { - GridLayout layout = new org.eclipse.swt.layout.GridLayout(columnCount, false); - layout.marginBottom = 0; - layout.marginTop = 0; - layout.marginLeft = (CHART_WIDTH - (50 * columnCount)) / 2; - Composite graphComposite = toolkit.createComposite(section, SWT.NONE); - graphComposite.setLayout(layout); - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = CHART_WIDTH; - graphComposite.setLayoutData(data); - - createStatsLink(toolkit, listener, graphComposite, "1 day", GlusterConstants.STATS_PERIOD_1DAY); - createStatsLink(toolkit, listener, graphComposite, "1 week", GlusterConstants.STATS_PERIOD_1WEEK); - createStatsLink(toolkit, listener, graphComposite, "1 month", GlusterConstants.STATS_PERIOD_1MONTH); - createStatsLink(toolkit, listener, graphComposite, "1 year", GlusterConstants.STATS_PERIOD_1YEAR); - - return graphComposite; - } - - private void createStatsLink(FormToolkit toolkit, ChartPeriodLinkListener listener, Composite parent, String label, - String statsPeriod) { - Hyperlink link1 = toolkit.createHyperlink(parent, label, SWT.NONE); - link1.addHyperlinkListener(listener.getInstance(statsPeriod)); - if (listener.getStatsPeriod().equals(statsPeriod)) { - link1.setEnabled(false); - } - } - - public abstract class ChartPeriodLinkListener extends HyperlinkAdapter { - protected String statsPeriod; - protected String unit; - protected int columnCount; - protected double maxValue; - protected FormToolkit toolkit; - protected String serverName; - protected int dataColumnIndex; - - public String getStatsPeriod() { - return this.statsPeriod; - } - - public ChartPeriodLinkListener(String serverName, String statsPeriod, String unit, double maxValue, - int columnCount, int dataColumnIndex, FormToolkit toolkit) { - this.serverName = serverName; - this.statsPeriod = statsPeriod; - this.unit = unit; - this.columnCount = columnCount; - this.maxValue = maxValue; - this.dataColumnIndex = dataColumnIndex; - this.toolkit = toolkit; - } - - public ChartPeriodLinkListener(String serverName, String statsPeriod, FormToolkit toolkit) { - this.statsPeriod = statsPeriod; - this.serverName = serverName; - this.toolkit = toolkit; - } - - @Override - public void linkActivated(HyperlinkEvent e) { - super.linkActivated(e); - Composite section = ((Hyperlink) e.getSource()).getParent().getParent(); - updatePreference(serverName); - } - - public abstract ChartPeriodLinkListener getInstance(String statsPeriod); - - protected abstract void updatePreference(String serverName); - } - - public class CpuChartPeriodLinkListener extends ChartPeriodLinkListener { - public CpuChartPeriodLinkListener(String serverName, String statsPeriod, FormToolkit toolkit) { - super(serverName, statsPeriod, toolkit); - } - - private CpuChartPeriodLinkListener(String serverName, String statsPeriod, String unit, double maxValue, - int columnCount, int dataColumnIndex, FormToolkit toolkit) { - super(serverName, statsPeriod, unit, maxValue, columnCount, dataColumnIndex, toolkit); - } - - @Override - protected void updatePreference(String serverName) { - ServerStats stats; - if (serverName == null) { - preferenceStore.setValue(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD, statsPeriod); - } else { - preferenceStore.setValue(PreferenceConstants.P_CPU_CHART_PERIOD, statsPeriod); - } - } - - @Override - public ChartPeriodLinkListener getInstance(String statsPeriod) { - return new CpuChartPeriodLinkListener(serverName, statsPeriod, "%", 100, 4, dataColumnIndex, toolkit); - } - } - - public class MemoryChartPeriodLinkListener extends ChartPeriodLinkListener { - public MemoryChartPeriodLinkListener(String serverName, String statsPeriod, FormToolkit toolkit) { - super(serverName, statsPeriod, toolkit); - } - - private MemoryChartPeriodLinkListener(String serverName, String statsPeriod, String unit, double maxValue, - int columnCount, int dataColumnIndex, FormToolkit toolkit) { - super(serverName, statsPeriod, unit, maxValue, columnCount, dataColumnIndex, toolkit); - } - - @Override - protected void updatePreference(String serverName) { - preferenceStore.setValue(PreferenceConstants.P_MEM_CHART_PERIOD, statsPeriod); - } - - @Override - public ChartPeriodLinkListener getInstance(String statsPeriod) { - return new MemoryChartPeriodLinkListener(serverName, statsPeriod, "%", 100, 4, dataColumnIndex, toolkit); - } - } - - public class NetworkChartPeriodLinkListener extends ChartPeriodLinkListener { - private GlusterServer server; - - public NetworkChartPeriodLinkListener(GlusterServer server, String statsPeriod, FormToolkit toolkit) { - super(server == null ? null : server.getName(), statsPeriod, toolkit); - this.setServer(server); - } - - private NetworkChartPeriodLinkListener(GlusterServer server, String statsPeriod, String unit, double maxValue, - int columnCount, int dataColumnIndex, FormToolkit toolkit) { - super(server == null ? null : server.getName(), statsPeriod, unit, maxValue, columnCount, dataColumnIndex, - toolkit); - this.setServer(server); - } - - @Override - protected void updatePreference(String serverName) { - if (serverName == null) { - preferenceStore.setValue(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD, statsPeriod); - } else { - preferenceStore.setValue(PreferenceConstants.P_NETWORK_CHART_PERIOD, statsPeriod); - } - } - - @Override - public ChartPeriodLinkListener getInstance(String statsPeriod) { - // if serverName is null, it means we are showing aggregated stats - so the "network interface" combo will - // not be shown in the "links" composite. - int columnCount = (serverName == null ? 4 : 5); - return new NetworkChartPeriodLinkListener(server, statsPeriod, "KiB/s", -1d, columnCount, dataColumnIndex, - toolkit); - } - - public void setServer(GlusterServer server) { - this.server = server; - } - - public GlusterServer getServer() { - return server; - } - } - - public void createNetworkInterfaceCombo(final Composite section, final Composite graphComposite, - final FormToolkit toolkit, final NetworkChartPeriodLinkListener networkChartPeriodLinkListener) { - final GlusterServer server = networkChartPeriodLinkListener.getServer(); - final CCombo interfaceCombo = new CCombo(graphComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER | SWT.FLAT); - final List niList = server.getNetworkInterfaces(); - final String[] interfaces = new String[niList.size()]; - - for (int i = 0; i < interfaces.length; i++) { - interfaces[i] = niList.get(i).getName(); - } - interfaceCombo.setItems(interfaces); - interfaceCombo.select(0); - interfaceCombo.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - preferenceStore.setValue(PreferenceConstants.P_DEFAULT_NETWORK_INTERFACE_PFX + server.getName(), interfaces[interfaceCombo.getSelectionIndex()]); - } - }); - } - - public void refreshChartSection(FormToolkit toolkit, Composite section, ServerStats stats, String statsPeriod, - String unit, double maxValue, int columnCount, ChartPeriodLinkListener linkListener, int dataColumnIndex) { - GUIHelper.getInstance().clearSection(section); - createAreaChart(toolkit, section, stats, dataColumnIndex, unit, getTimestampFormatForPeriod(statsPeriod), - linkListener, maxValue, columnCount); - section.layout(); - } - - public String getTimestampFormatForPeriod(String statsPeriod) { - if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1DAY)) { - return "HH:mm"; - } else if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1WEEK)) { - return "dd-MMM HH:mm"; - } else { - return "dd-MMM"; - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartViewerComposite.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartViewerComposite.java deleted file mode 100644 index 9e67ed29..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ChartViewerComposite.java +++ /dev/null @@ -1,475 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.utils; - -import java.util.Arrays; -import java.util.Collections; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.device.IUpdateNotifier; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.Chart; -import org.eclipse.birt.chart.model.ChartWithoutAxes; -import org.eclipse.birt.chart.model.attribute.Anchor; -import org.eclipse.birt.chart.model.attribute.AxisType; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.ChartDimension; -import org.eclipse.birt.chart.model.attribute.LineAttributes; -import org.eclipse.birt.chart.model.attribute.LineStyle; -import org.eclipse.birt.chart.model.attribute.Position; -import org.eclipse.birt.chart.model.attribute.Text; -import org.eclipse.birt.chart.model.attribute.TickStyle; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; -import org.eclipse.birt.chart.model.attribute.impl.JavaDateFormatSpecifierImpl; -import org.eclipse.birt.chart.model.attribute.impl.LineAttributesImpl; -import org.eclipse.birt.chart.model.attribute.impl.NumberFormatSpecifierImpl; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.DateTimeDataElement; -import org.eclipse.birt.chart.model.data.DateTimeDataSet; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; -import org.eclipse.birt.chart.model.data.impl.DateTimeDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.DateTimeDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; -import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; -import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; -import org.eclipse.birt.chart.model.layout.Legend; -import org.eclipse.birt.chart.model.layout.Plot; -import org.eclipse.birt.chart.model.type.AreaSeries; -import org.eclipse.birt.chart.model.type.PieSeries; -import org.eclipse.birt.chart.model.type.impl.AreaSeriesImpl; -import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.core.runtime.Platform; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; - -import com.ibm.icu.util.Calendar; - -/** - * - */ -public final class ChartViewerComposite extends Composite implements PaintListener, IUpdateNotifier { - - public enum CHART_TYPE { - PIE, LINE - }; - - private IDeviceRenderer deviceReader = null; - private Chart chart = null; - private GeneratedChartState generatedChartState = null; - private boolean needsGeneration = true; - - private static Logger logger = Logger.getLogger(ChartViewerComposite.class.getName()); - - /** - * @param parent - * Parent composite of this pie chart viewer composite - * @param style - * SWT style to be used - * @param categories - * Categories of the pie chart - * @param values - * Values of each category in the pie chart Constructs a pie - * chart viewer composite for given categories and values - */ - public ChartViewerComposite(Composite parent, int style, String[] categories, Double[] values) { - super(parent, style); - init(); - - chart = createPieChart(categories, values); - addPaintListener(this); - } - - /** - * @param parent - * Parent composite of this pie chart viewer composite - * @param style - * SWT style to be used - * @param categories - * Categories of the pie chart - * @param values - * Values of each category in the pie chart Constructs a pie - * chart viewer composite for given categories and values - * @param maxValue - */ - public ChartViewerComposite(Composite parent, int style, Calendar[] categories, Double[] values, String unit, String timestampFormat, double maxValue) { - super(parent, style); - init(); - - createSingleAreaChart(categories, values, unit, timestampFormat, maxValue); - addPaintListener(this); - } - - public void init() { - try { - PlatformConfig config = new PlatformConfig(); - config.setBIRTHome(Platform.getInstallLocation().getURL().getPath()); - // Get the connection with SWT device to render the graphics. - deviceReader = ChartEngine.instance(config).getRenderer("dv.SWT");//$NON-NLS-1$ - } catch (ChartException ex) { - logger.log(Level.SEVERE, "Could not create Chart Renderer for SWT", ex); - } - - addControlListener(new ControlListener() { - - public void controlMoved(ControlEvent e) { - needsGeneration = true; - } - - public void controlResized(ControlEvent e) { - needsGeneration = true; - } - }); - } - - private void createSingleAreaChart(Calendar[] timestamps, Double[] values, String unit, String timestampFormat, double maxValue) { - createAreaChart(timestamps, new Double[][] {values}, unit, timestampFormat, maxValue); - } - - /** - * Creates a line chart model as a reference implementation - * @param maxValue - * - * @return An instance of the simulated runtime chart model (containing - * filled datasets) - */ - private final void createAreaChart(Calendar[] timestamps, Double[][] values, final String unit, final String timestampFormat, double maxValue) { - chart = ChartWithAxesImpl.create(); - // Plot - chart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); - Plot p = chart.getPlot(); - p.getClientArea().setBackground(ColorDefinitionImpl.WHITE()); - p.setBackground(ColorDefinitionImpl.WHITE()); - - // Title - chart.getTitle().getLabel().getCaption().setValue("Line Chart");//$NON-NLS-1$ - chart.getTitle().setVisible(false); - chart.getTitle().getLabel().setVisible(true); - chart.getTitle().getInsets().set(0, 10, 0, 0); - chart.getTitle().setAnchor(Anchor.SOUTH_LITERAL); - - // Legend - Legend lg = chart.getLegend(); - lg.setVisible(false); - LineAttributes lia = lg.getOutline( ); - lia.setStyle( LineStyle.SOLID_LITERAL ); - lg.getText( ).getFont( ).setSize( 10 ); - //lg.getInsets( ).set( 10, 5, 0, 0 ); - lg.getInsets( ).set( 0, 0, 0, 0 ); - lg.getOutline( ).setVisible( false ); - lg.setAnchor( Anchor.NORTH_LITERAL ); - - updateDataSet(timestamps, values, unit, timestampFormat, maxValue); - } - - private void updateDataSet(Calendar[] timestamps, Double[][] values, final String unit, final String timestampFormat, double maxValue) { - Axis xAxisPrimary = setupXAxis(timestamps, timestampFormat); - - if(maxValue <= 0) { - maxValue = getMaxValue(values); - } - Axis yAxisPrimary = setupYAxis(unit, xAxisPrimary, maxValue); - configureXSeries(timestamps, xAxisPrimary); - configureYSeries(values, yAxisPrimary); - } - - private double getMaxValue(Double[][] values) { - double maxValue = -1; - for(Double[] seriesValues : values) { - double seriesMaxVal = Collections.max(Arrays.asList(seriesValues)); - if(seriesMaxVal > maxValue) { - maxValue = Math.round(seriesMaxVal) + 5 - (Math.round(seriesMaxVal) % 5); - } - } - return maxValue; - } - - private void configureYSeries(Double[][] values, Axis yAxisPrimary) { - SeriesDefinition sdY = SeriesDefinitionImpl.create(); - sdY.getSeriesPalette().shift(-3); - yAxisPrimary.getSeriesDefinitions().add(sdY); - - for (int i = 0; i < values.length; i++) { - // Y-Sereis - AreaSeries ls = (AreaSeries) AreaSeriesImpl.create(); - // LineSeries ls = (LineSeries) LineSeriesImpl.create(); - - NumberDataSet orthoValues = NumberDataSetImpl.create(values[i]); - ls.setDataSet(orthoValues); - ls.getLineAttributes().setColor(ColorDefinitionImpl.create(50, 50, 255)); -// for (int j = 0; j < ls.getMarkers().size(); j++) { -// ( (Marker) ls.getMarkers( ).get( j ) ).setType( MarkerType.CIRCLE_LITERAL); -// ((Marker) ls.getMarkers().get(j)).setVisible(true); -// } - ls.setTranslucent(true); - // don't show values on each point on the line chart - ls.getLabel().setVisible(false); - sdY.getSeries().add(ls); - } - } - - private void configureXSeries(Calendar[] timestamps, Axis xAxisPrimary) { - // Data Set - DateTimeDataSet categoryValues = DateTimeDataSetImpl.create(timestamps); - - // X-Series - Series seCategory = SeriesImpl.create(); - seCategory.setDataSet(categoryValues); - SeriesDefinition sdX = SeriesDefinitionImpl.create(); - - xAxisPrimary.getSeriesDefinitions().add(sdX); - sdX.getSeries().add(seCategory); - } - - private Axis setupYAxis(final String unit, Axis xAxisPrimary, double maxValue) { - Axis yAxisPrimary = ((ChartWithAxesImpl)chart).getPrimaryOrthogonalAxis(xAxisPrimary); - if(maxValue > 0) { - yAxisPrimary.getScale().setMax(NumberDataElementImpl.create(maxValue)); - yAxisPrimary.getScale().setStep(maxValue / 5); - } - yAxisPrimary.getScale().setMin(NumberDataElementImpl.create(0)); - yAxisPrimary.setGapWidth(0); - yAxisPrimary.getScale().setMajorGridsStepNumber(1); - yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); - yAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1)); - yAxisPrimary.getLabel().setVisible(true); - yAxisPrimary.getLabel().getCaption().getFont().setSize(8); - yAxisPrimary.setFormatSpecifier(new NumberFormatSpecifierImpl() { - @Override - public String getSuffix() { - return " " + unit; - } - }); - return yAxisPrimary; - } - - private Axis setupXAxis(Calendar[] timestamps, final String timestampFormat) { - Axis xAxisPrimary = ((ChartWithAxesImpl)chart).getPrimaryBaseAxes()[0]; - xAxisPrimary.setType(AxisType.TEXT_LITERAL); - DateTimeDataElement dtde = DateTimeDataElementImpl.create(timestamps[timestamps.length-1]); - DateTimeDataElement dtde1 = DateTimeDataElementImpl.create(timestamps[0]); - xAxisPrimary.getScale().setMax(dtde); - xAxisPrimary.getScale().setStep((dtde.getValue() - dtde1.getValue())/ 10); - xAxisPrimary.getScale().setMajorGridsStepNumber(timestamps.length > 10 ? timestamps.length / 10 : 1); - //xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.ABOVE_LITERAL); - xAxisPrimary.getMajorGrid().getTickAttributes().setVisible(false); - xAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1)); - xAxisPrimary.getTitle().setVisible(false); - xAxisPrimary.getTitle().getInsets().set(1, 1, 1, 1); - xAxisPrimary.getLabel().getInsets().set(1, 1, 1, 1); - //xAxisPrimary.getLabel().getCaption().setFont(createChartFont()); - xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setSize(8); - //commenting to check whether this is causing the problem on windows - //xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 75 ); - xAxisPrimary.setFormatSpecifier( JavaDateFormatSpecifierImpl.create( timestampFormat ) ); - return xAxisPrimary; - } - - /** - * @param categories - * Categories of the pie chart - * @param values - * Values of each category in the pie chart - * @return The chart object created for given categories and values - */ - public static final Chart createPieChart(String[] categories, Double[] values) { - ChartWithoutAxes pieChart = ChartWithoutAxesImpl.create(); - - // script hook to NOT show the label if value is zero - pieChart.setScript("function beforeDrawDataPointLabel( dph, label, icsc ){ if (dph.getOrthogonalValue() == 0){ label.setVisible(false); } } "); - - // Plot - pieChart.setSeriesThickness(10); - pieChart.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL); - pieChart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); - Plot p = pieChart.getPlot(); - - p.getClientArea().setBackground(null); - p.getClientArea().getOutline().setVisible(false); - p.getOutline().setVisible(false); - - // Legend - Legend lg = pieChart.getLegend(); - lg.setMaxPercent(0.7); - lg.getText().getFont().setSize(9); - lg.setBackground(null); - lg.getOutline().setVisible(false); - lg.setVisible(true); - - // Title - pieChart.getTitle().getLabel().getCaption().setValue("Pie Chart");//$NON-NLS-1$ - pieChart.getTitle().getOutline().setVisible(false); - pieChart.getTitle().setVisible(false); - - TextDataSet categoryValues = TextDataSetImpl.create(categories); - NumberDataSet seriesOneValues = NumberDataSetImpl.create(values); - - // Base Series - Series seCategory = SeriesImpl.create(); - seCategory.setDataSet(categoryValues); - - SeriesDefinition sd = SeriesDefinitionImpl.create(); - pieChart.getSeriesDefinitions().add(sd); - sd.setSeriesPalette(new GlusterChartPalette()); - sd.getSeriesPalette().shift(0); - sd.getSeries().add(seCategory); - - // Orthogonal Series - PieSeries sePie = (PieSeries) PieSeriesImpl.create(); - sePie.setRatio(0.60); - sePie.setDataSet(seriesOneValues); - sePie.setSeriesIdentifier("Chart");//$NON-NLS-1$ - sePie.getTitle().setVisible(false); // no title - sePie.getLabel().setVisible(true); // show label (values) - sePie.setExplosion(0); // no gap between the pie slices - sePie.setLabelPosition(Position.INSIDE_LITERAL); - Text labelCaption = sePie.getLabel().getCaption(); - labelCaption.setColor(ColorDefinitionImpl.CYAN()); - labelCaption.getFont().setSize(8); - labelCaption.getFont().setBold(true); - - SeriesDefinition seriesDefinition = SeriesDefinitionImpl.create(); - seriesDefinition.getQuery().setDefinition("query.definition");//$NON-NLS-1$ - sd.getSeriesDefinitions().add(seriesDefinition); - seriesDefinition.getSeries().add(sePie); - - return pieChart; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events - * .PaintEvent) - */ - public final void paintControl(PaintEvent e) { - Rectangle d = ((Composite) e.getSource()).getBounds(); - Image imgChart = new Image(this.getDisplay(), d); - GC gcImage = new GC(imgChart); - deviceReader.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gcImage); - deviceReader.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this); - - Bounds bo = BoundsImpl.create(0, 0, d.width, d.height); - bo.scale(71d / deviceReader.getDisplayServer().getDpiResolution()); - - Generator gr = Generator.instance(); - if (needsGeneration) { - needsGeneration = false; - try { - generatedChartState = gr.build(deviceReader.getDisplayServer(), chart, bo, null, null, null); - } catch (ChartException ce) { - ce.printStackTrace(); - } - } - - try { - gr.render(deviceReader, generatedChartState); - GC gc = e.gc; - gc.drawImage(imgChart, d.x, d.y); - } catch (ChartException gex) { - logger.log(Level.SEVERE, "Exception while rendering pie chart [" + gex.getMessage() + "]", gex); - } - } - -// public void chartRefresh(Calendar[] timestamps, Double[][] values, String unit, String timestampFormat) -// { -// if ( !isDisposed( ) ) -// { -// final Generator gr = Generator.instance( ); -// updateDataSet( timestamps, values, unit, timestampFormat); -// -// // Refresh -// try -// { -// gr.refresh( generatedChartState ); -// } -// catch ( ChartException ex ) -// { -// // TODO: log the exception -// ex.printStackTrace( ); -// } -// redraw( ); -// } -// } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#getDesignTimeModel() - */ - public Chart getDesignTimeModel() { - return chart; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#getRunTimeModel() - */ - public Chart getRunTimeModel() { - return generatedChartState.getChartModel(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#peerInstance() - */ - public Object peerInstance() { - return this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#regenerateChart() - */ - public void regenerateChart() { - redraw(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#repaintChart() - */ - public void repaintChart() { - redraw(); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/EntityViewerFilter.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/EntityViewerFilter.java deleted file mode 100644 index 60161324..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/EntityViewerFilter.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.utils; - -import java.util.Map.Entry; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -import com.gluster.storage.management.core.model.Filterable; -import com.gluster.storage.management.core.utils.StringUtil; - -public class EntityViewerFilter extends ViewerFilter { - - private String filterString; - private boolean caseSensitive = false; - - public EntityViewerFilter(String filterString, boolean caseSensitive) { - this.filterString = filterString; - this.caseSensitive = caseSensitive; - } - - public boolean isCaseSensitive() { - return caseSensitive; - } - - public void setCaseSensitive(boolean caseSensitive) { - this.caseSensitive = caseSensitive; - } - - public String getFilterString() { - return filterString; - } - - public void setFilterString(String filterString) { - this.filterString = filterString; - } - - @SuppressWarnings("unchecked") - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (filterString == null || filterString.isEmpty()) { - // No filter string. select everything - return true; - } - - if (element instanceof Filterable) { - return ((Filterable) element).filter(filterString, caseSensitive); - } - - if(element instanceof Entry) { - Entry entry = (Entry)element; - return StringUtil.filterString(entry.getKey() + entry.getValue(), filterString, caseSensitive); - } - - if(element instanceof String) { - return StringUtil.filterString((String)element, filterString, caseSensitive); - } - - return false; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java deleted file mode 100644 index b8f8d83e..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java +++ /dev/null @@ -1,481 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.utils; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.jface.fieldassist.FieldDecorationRegistry; -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ColumnLayoutData; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.events.ExpansionAdapter; -import org.eclipse.ui.forms.events.ExpansionEvent; -import org.eclipse.ui.forms.widgets.ColumnLayout; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.progress.IProgressConstants; - -import com.gluster.storage.management.console.Application; -import com.gluster.storage.management.console.ConsoleConstants; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.views.NavigationView; -import com.gluster.storage.management.console.views.TasksView; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.utils.JavaUtil; - -public class GUIHelper { - private static final GUIHelper instance = new GUIHelper(); - private static final ImageUtil imageUtil = new ImageUtil(); - private static final GlusterLogger logger = GlusterLogger.getInstance(); - - private GUIHelper() { - - } - - public static GUIHelper getInstance() { - return instance; - } - - public ScrolledForm setupForm(Composite parent, FormToolkit toolkit, final String formName) { - return setupForm(toolkit, formName, toolkit.createScrolledForm(parent)); - } - - public ScrolledForm setupForm(FormToolkit toolkit, final String formName, ScrolledForm form) { - form.setText(formName); - toolkit.decorateFormHeading(form.getForm()); - - ColumnLayout layout = new ColumnLayout(); - - // layout.topMargin = 0; - // layout.bottomMargin = 5; - // layout.leftMargin = 10; - // layout.rightMargin = 10; - // layout.horizontalSpacing = 10; - // layout.verticalSpacing = 10; - // layout.maxNumColumns = 4; - // layout.minNumColumns = 1; - - form.getBody().setLayout(layout); - return form; - } - - public Composite createSection(final ScrolledForm form, FormToolkit toolkit, String title, String desc, - int numColumns, boolean collapsible) { - int style = Section.TITLE_BAR | Section.EXPANDED; - if (desc != null && !desc.isEmpty()) { - style |= Section.DESCRIPTION; - } - if (collapsible) { - style |= Section.TWISTIE; - } - - Section section = toolkit.createSection(form.getBody(), style); - section.setText(title); - section.setDescription(desc); - - // toolkit.createCompositeSeparator(section); - Composite client = toolkit.createComposite(section); - GridLayout layout = new GridLayout(); - layout.marginWidth = layout.marginHeight = 0; - layout.numColumns = numColumns; - layout.verticalSpacing = 10; - layout.marginBottom = 15; - layout.marginTop = 10; - - client.setLayout(layout); - section.setClient(client); - - section.addExpansionListener(new ExpansionAdapter() { - public void expansionStateChanged(ExpansionEvent e) { - form.reflow(false); - } - }); - return client; - } - - public Composite createTab(TabFolder tabFolder, String title, String imageKey) { - TabItem item = new TabItem(tabFolder, SWT.NONE); - item.setText(title); - item.setImage(getImage(imageKey)); - - Composite composite = new Composite(tabFolder, SWT.NONE); - composite.setLayout(new FillLayout()); - - item.setControl(composite); - - return composite; - } - - public ImageDescriptor getImageDescriptor(String imagePath) { - return imageUtil.getImageDescriptor(imagePath); - } - - public Image getImage(String imagePath) { - return imageUtil.getImage(imagePath); - } - - public Action createPullDownMenu(String menuName, String iconPath, final MenuManager menuManager) { - Action action = new Action(menuName, IAction.AS_DROP_DOWN_MENU) { - public void run() { - } - }; - action.setMenuCreator(new IMenuCreator() { - - @Override - public Menu getMenu(Menu menu) { - return null; - } - - @Override - public Menu getMenu(Control control) { - return menuManager.createContextMenu(control); - } - - @Override - public void dispose() { - } - }); - action.setImageDescriptor(getImageDescriptor(iconPath)); - return action; - } - - public TableColumnLayout createTableColumnLayout(Table table, String[] columns) { - TableColumnLayout tableColumnLayout = new TableColumnLayout(); - ColumnLayoutData defaultColumnLayoutData = new ColumnWeightData(100); - - for (String columnName : columns) { - TableColumn column = new TableColumn(table, SWT.LEFT); - column.setText(columnName); - - tableColumnLayout.setColumnData(column, defaultColumnLayoutData); - } - - return tableColumnLayout; - } - - /** - * Creates a filter for given structured viewer that will filter the contents of the viewer based on the current - * text of the text field - * - * @param viewer - * Structured viewer for which the filter is to be created - * @param filterText - * The text field whose contents are to be used for filtering - * @param caseSensitive - * Flag indicating whether the filtering should be case sensitive - * @return The newly created filter - */ - public EntityViewerFilter createFilter(final StructuredViewer viewer, final Text filterText, boolean caseSensitive) { - final String initialFilterString = filterText.getText(); - - final EntityViewerFilter filter = new EntityViewerFilter(initialFilterString, caseSensitive); - // On every keystroke inside the text field, update the filter string - filterText.addKeyListener(new KeyAdapter() { - private String filterString = initialFilterString; - - @Override - public void keyReleased(KeyEvent e) { - String enteredString = filterText.getText(); - if (enteredString.equals(filterString)) { - // Filter string has not changed. don't do anything - return; - } - - // Update filter string - filterString = enteredString; - filter.setFilterString(filterString); - - // Refresh viewer with newly filtered content - viewer.refresh(true); - if(viewer instanceof TreeViewer) { - ((TreeViewer)viewer).expandAll(); - } - } - }); - - viewer.addFilter(filter); - return filter; - } - - public IViewPart getView(String viewId) { - IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .getViewReferences(); - for (IViewReference view : views) { - if (view.getId().equals(viewId)) { - return view.getView(false); - } - } - return null; - } - - public IWorkbenchPart getActiveView() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); - } - - public ControlDecoration createErrorDecoration(Control control) { - ControlDecoration passwordErrorDecoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP); - passwordErrorDecoration.setImage(FieldDecorationRegistry.getDefault() - .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); - return passwordErrorDecoration; - } - - public void centerShellInScreen(Shell shell) { - Rectangle monitorBounds = shell.getMonitor().getBounds(); - Rectangle myBounds = shell.getBounds(); - - int x = monitorBounds.x + (monitorBounds.width - myBounds.width) / 2; - int y = monitorBounds.y + (monitorBounds.height - myBounds.height) / 2; - shell.setLocation(x, y); - } - - public Text createFilterText(FormToolkit toolkit, Composite parent) { - final String tooltipMessage = "Start typing to filter table contents."; - final Text filterText = toolkit.createText(parent, "", SWT.FLAT); - - GridData data = new GridData(SWT.RIGHT, SWT.CENTER, false, false); - data.widthHint = 300; - filterText.setLayoutData(data); - - ControlDecoration searchDecoration = new ControlDecoration(filterText, SWT.LEFT); - searchDecoration.setImage(getImage(IImageKeys.SEARCH_22x22)); - searchDecoration.show(); - searchDecoration.setShowHover(true); - searchDecoration.setDescriptionText(tooltipMessage); - searchDecoration.setMarginWidth(5); - - filterText.setToolTipText(tooltipMessage); - return filterText; - } - - public Text createFilterText(Composite parent) { - final String tooltipMessage = "Start typing to filter table contents."; - final Text filterText = new Text(parent, SWT.FLAT); - - GridData data = new GridData(SWT.LEFT, SWT.CENTER, false, false); - data.widthHint = 300; - filterText.setLayoutData(data); - - ControlDecoration searchDecoration = new ControlDecoration(filterText, SWT.RIGHT); - searchDecoration.setImage(getImage(IImageKeys.SEARCH_22x22)); - searchDecoration.show(); - searchDecoration.setShowHover(true); - searchDecoration.setDescriptionText(tooltipMessage); - - filterText.setToolTipText(tooltipMessage); - return filterText; - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - public void setColumnProperties(Table table, int columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } - - /** - * Fetches the currently selected objects from the workbench site and returns the one of given type. If none of the - * selected objects are of given type, returns null - * - * @param site - * The workbench site - * @param expectedType - * Type of the selected object to look for - * @return The selected object of given type if found, else null - */ - public T getSelectedEntity(IWorkbenchSite site, Class expectedType) { - return getSelectedEntity(site.getWorkbenchWindow(), expectedType); - } - - @SuppressWarnings({ "unchecked" }) - public T getSelectedEntity(IWorkbenchWindow window, Class expectedType) { - ISelection selection = window.getSelectionService().getSelection(NavigationView.ID); - if (selection instanceof IStructuredSelection) { - Iterator iter = ((IStructuredSelection) selection).iterator(); - while (iter.hasNext()) { - Object selectedObj = iter.next(); - if (selectedObj.getClass() == expectedType) { - return (T)selectedObj; - } - } - } - return null; - } - - /** - * Fetches the currently selected objects from the workbench site and returns those of given type. If none of the - * selected objects are of given type, returns null - * - * @param site - * The workbench site - * @param expectedType - * Type of the selected objects to look for - * @return The selected objects of given type if found, else null - */ - public Set getSelectedEntities(IWorkbenchSite site, Class expectedType) { - return getSelectedEntities(site.getWorkbenchWindow(), expectedType); - } - - @SuppressWarnings("unchecked") - public Set getSelectedEntities(IWorkbenchWindow window, Class expectedType) { - Set selectedEntities = new HashSet(); - ISelection selection = window.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator iter = ((IStructuredSelection) selection).iterator(); - while (iter.hasNext()) { - Object selectedObj = iter.next(); - if (selectedObj.getClass() == expectedType) { - selectedEntities.add((T) selectedObj); - } - } - } - return selectedEntities; - } - - - public void configureCheckboxTableViewer(final CheckboxTableViewer tableViewer) { - tableViewer.addCheckStateListener(new ICheckStateListener() { - - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - tableViewer.setSelection(new StructuredSelection(tableViewer.getCheckedElements())); - } - }); - - tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - - @SuppressWarnings("unchecked") - @Override - public void selectionChanged(SelectionChangedEvent event) { - List checkedElements = Arrays.asList(tableViewer.getCheckedElements()); - List selectedElements = ((IStructuredSelection)event.getSelection()).toList(); - - if (JavaUtil.listsDiffer(checkedElements, selectedElements)) { - tableViewer.setSelection(new StructuredSelection(tableViewer.getCheckedElements())); - } - } - }); - } - - public void showView(String viewId) { - try { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewId); - } catch (PartInitException e) { - String errMsg = "Could not open view [" + viewId + "]"; - logger.error(errMsg, e); - throw new GlusterRuntimeException(errMsg, e); - } - } - - public void showTerminalView() { - showView(ConsoleConstants.TERMINAL_VIEW_ID); - } - - public void showProgressView() { - showView(IProgressConstants.PROGRESS_VIEW_ID); - } - - public void showTaskView() { - NavigationView navigationView = (NavigationView) getView(NavigationView.ID); - navigationView.selectEntity(GlusterDataModelManager.getInstance().getModel().getCluster()); - - showView(TasksView.ID); - } - - public void setStatusMessage(String message) { - clearStatusMessage(); - Application.getApplication().getStatusLineManager().setMessage(message); - Application.getApplication().getStatusLineManager().setMessage(message); - } - - public void clearStatusMessage() { - Application.getApplication().getStatusLineManager().setMessage(null); - } - - public String getDiskToolTip(Disk disk) { - return disk.getQualifiedName() + " - " + disk.getDescription(); - } - - public void clearSection(Composite section) { - if (section.isDisposed()) { - return; - } - for(Control control : section.getChildren()) { - if(! control.isDisposed()) { - control.dispose(); - } - } - section.layout(true); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterChartPalette.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterChartPalette.java deleted file mode 100644 index 3c5b0b62..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterChartPalette.java +++ /dev/null @@ -1,479 +0,0 @@ -/*********************************************************************** - * Copyright (c) 2004 Actuate Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Actuate Corporation - initial API and implementation - ***********************************************************************/ - -package com.gluster.storage.management.console.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.eclipse.birt.chart.engine.i18n.Messages; -import org.eclipse.birt.chart.log.ILogger; -import org.eclipse.birt.chart.log.Logger; -import org.eclipse.birt.chart.model.attribute.AttributeFactory; -import org.eclipse.birt.chart.model.attribute.AttributePackage; -import org.eclipse.birt.chart.model.attribute.ColorDefinition; -import org.eclipse.birt.chart.model.attribute.Fill; -import org.eclipse.birt.chart.model.attribute.Palette; -import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -import com.ibm.icu.util.ULocale; - -/** - * An implementation of the model object ' - * Palette'. - *

    - * The following features are implemented: - *

      - *
    • {@link org.eclipse.birt.chart.model.attribute.impl.GlusterChartPalette#getName Name}
    • - *
    • {@link org.eclipse.birt.chart.model.attribute.impl.GlusterChartPalette#getEntries Entries}
    • - *
    - *

    - * - * @generated - */ -public class GlusterChartPalette extends EObjectImpl implements Palette -{ - - /** - * The default value of the '{@link #getName() Name}' attribute. - * - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getName() Name}' attribute. - * - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * The cached value of the '{@link #getEntries() Entries}' containment reference list. - * - * @see #getEntries() - * @generated - * @ordered - */ - protected EList entries; - - private static ILogger logger = Logger.getLogger( "org.eclipse.birt.chart.engine/model.attribute.impl" ); //$NON-NLS-1$ - - private static List colorLib = new ArrayList( 32 ); - static - { - colorLib.add( ColorDefinitionImpl.create ( 0, 1, 252) ); - colorLib.add( ColorDefinitionImpl.create ( 255, 0, 255) ); - //colorLib.add( ColorDefinitionImpl.BLUE() ); - //colorLib.add( ColorDefinitionImpl.create( 232, 172, 57 ) ); - } - - /** - * - * @generated - */ - public GlusterChartPalette( ) - { - super( ); - } - - /** - * - * @generated - */ - @Override - protected EClass eStaticClass( ) - { - return AttributePackage.Literals.PALETTE; - } - - /** - * - * @generated - */ - public String getName( ) - { - return name; - } - - /** - * - * @generated - */ - public void setName( String newName ) - { - String oldName = name; - name = newName; - if ( eNotificationRequired( ) ) - eNotify( new ENotificationImpl( this, - Notification.SET, - AttributePackage.PALETTE__NAME, - oldName, - name ) ); - } - - /** - * - * @generated - */ - public EList getEntries( ) - { - if ( entries == null ) - { - entries = new EObjectContainmentEList( Fill.class, - this, - AttributePackage.PALETTE__ENTRIES ); - } - return entries; - } - - /** - * - * - * @generated - */ - @Override - public NotificationChain eInverseRemove( InternalEObject otherEnd, - int featureID, NotificationChain msgs ) - { - switch ( featureID ) - { - case AttributePackage.PALETTE__ENTRIES : - return ( (InternalEList) getEntries( ) ).basicRemove( otherEnd, - msgs ); - } - return super.eInverseRemove( otherEnd, featureID, msgs ); - } - - /** - * - * - * @generated - */ - @Override - public Object eGet( int featureID, boolean resolve, boolean coreType ) - { - switch ( featureID ) - { - case AttributePackage.PALETTE__NAME : - return getName( ); - case AttributePackage.PALETTE__ENTRIES : - return getEntries( ); - } - return super.eGet( featureID, resolve, coreType ); - } - - /** - * - * - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet( int featureID, Object newValue ) - { - switch ( featureID ) - { - case AttributePackage.PALETTE__NAME : - setName( (String) newValue ); - return; - case AttributePackage.PALETTE__ENTRIES : - getEntries( ).clear( ); - getEntries( ).addAll( (Collection) newValue ); - return; - } - super.eSet( featureID, newValue ); - } - - /** - * - * - * @generated - */ - @Override - public void eUnset( int featureID ) - { - switch ( featureID ) - { - case AttributePackage.PALETTE__NAME : - setName( NAME_EDEFAULT ); - return; - case AttributePackage.PALETTE__ENTRIES : - getEntries( ).clear( ); - return; - } - super.eUnset( featureID ); - } - - /** - * - * - * @generated - */ - @Override - public boolean eIsSet( int featureID ) - { - switch ( featureID ) - { - case AttributePackage.PALETTE__NAME : - return NAME_EDEFAULT == null ? name != null - : !NAME_EDEFAULT.equals( name ); - case AttributePackage.PALETTE__ENTRIES : - return entries != null && !entries.isEmpty( ); - } - return super.eIsSet( featureID ); - } - - /** - * - * @generated - */ - @Override - public String toString( ) - { - if ( eIsProxy( ) ) - return super.toString( ); - - StringBuffer result = new StringBuffer( super.toString( ) ); - result.append( " (name: " ); //$NON-NLS-1$ - result.append( name ); - result.append( ')' ); - return result.toString( ); - } - - /** - * A convenience method provided to create an empty or pre-initialized - * palette - * - * NOTE: Manually written - * - * @param bEmpty - */ - public static final Palette create( int iIndex, boolean bEmpty ) - { - final Palette p = AttributeFactory.eINSTANCE.createPalette( ); - - if ( !bEmpty ) - { - p.shift( iIndex ); - } - return p; - } - - /** - * A convenience method provided to create a palette with a single color - * entry - * - * NOTE: Manually written - * - * @param f - */ - public static final Palette create( Fill f ) - { - final Palette p = AttributeFactory.eINSTANCE.createPalette( ); - p.getEntries( ).add( f ); - return p; - } - - /** - * Shift the list content from tail to head. - * - * @param lst - * @param pos - */ - private static final void shiftList( final List lst, int pos ) - { - int size = lst.size( ); - - if ( pos < 1 ) - { - pos = 0; - } - - if ( pos >= size ) - { - pos = pos % size; - } - - if ( pos == 0 ) - { - return; - } - - Object[] array = lst.toArray( ); - - lst.clear( ); - - for ( int i = pos; i < array.length; i++ ) - { - lst.add( array[i] ); - } - - for ( int i = 0; i < pos; i++ ) - { - lst.add( array[i] ); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.model.attribute.Palette#update(int) - */ - public final void update( int iIndex ) - { - final EList el = getEntries( ); - el.clear( ); - if ( iIndex < 0 ) - { - // a rotation version of palette-0, rataion pos is the negatvie - // index. - ArrayList al = new ArrayList( ); - - al.add( ColorDefinitionImpl.create( 80, 166, 218 ) ); - al.add( ColorDefinitionImpl.create( 242, 88, 106 ) ); - al.add( ColorDefinitionImpl.create( 232, 172, 57 ) ); - al.add( ColorDefinitionImpl.create( 128, 255, 128 ) ); - al.add( ColorDefinitionImpl.create( 64, 128, 128 ) ); - al.add( ColorDefinitionImpl.create( 128, 128, 192 ) ); - al.add( ColorDefinitionImpl.create( 170, 85, 85 ) ); - al.add( ColorDefinitionImpl.create( 128, 128, 0 ) ); - - shiftList( al, -iIndex ); - - el.addAll( al ); - } - else if ( iIndex == 0 ) - { - el.add( ColorDefinitionImpl.create( 80, 166, 218 ) ); - el.add( ColorDefinitionImpl.create( 242, 88, 106 ) ); - el.add( ColorDefinitionImpl.create( 232, 172, 57 ) ); - el.add( ColorDefinitionImpl.create( 128, 255, 128 ) ); - el.add( ColorDefinitionImpl.create( 64, 128, 128 ) ); - el.add( ColorDefinitionImpl.create( 128, 128, 192 ) ); - el.add( ColorDefinitionImpl.create( 170, 85, 85 ) ); - el.add( ColorDefinitionImpl.create( 128, 128, 0 ) ); - } - else if ( iIndex == 1 ) - { - el.add( ColorDefinitionImpl.create( 225, 225, 255 ) ); - el.add( ColorDefinitionImpl.create( 223, 197, 41 ) ); - el.add( ColorDefinitionImpl.create( 249, 225, 191 ) ); - el.add( ColorDefinitionImpl.create( 255, 205, 225 ) ); - el.add( ColorDefinitionImpl.create( 225, 255, 225 ) ); - el.add( ColorDefinitionImpl.create( 255, 191, 255 ) ); - el.add( ColorDefinitionImpl.create( 185, 185, 221 ) ); - el.add( ColorDefinitionImpl.create( 40, 255, 148 ) ); - } - else - { - logger.log( ILogger.WARNING, - Messages.getString( "error.unknown.palette", //$NON-NLS-1$ - new Object[]{ - Integer.valueOf( iIndex ) - }, - ULocale.getDefault( ) ) ); - update( 0 ); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.model.attribute.Palette#update(org.eclipse.birt.chart.model.attribute.Fill) - */ - public final void update( Fill f ) - { - final EList el = getEntries( ); - el.clear( ); - el.add( f ); - } - - public void shift( int step ) - { - shift( step, colorLib.size( ) ); - } - - public void shift( int step, int size ) - { - if ( size <= 0 || size > colorLib.size( ) ) - { - size = colorLib.size( ); - } - - final EList el = getEntries( ); - el.clear( ); - - if ( step == 0 || Math.abs( step ) >= size ) - { - // Do nothing - step = 0; - } - else if ( step < 0 ) - { - // Move to the left side - step = -step; - } - else if ( step > 0 ) - { - // Move to the right side - step = size - step; - } - - for ( int i = step; i < size; i++ ) - { - el.add( ( (ColorDefinition) colorLib.get( i ) ).copyInstance( ) ); - } - for ( int i = 0; i < step; i++ ) - { - el.add( ( (ColorDefinition) colorLib.get( i ) ).copyInstance( ) ); - } - } - - /** - * A convenient method to get an instance copy. This is much faster than the - * ECoreUtil.copy(). - */ - public Palette copyInstance( ) - { - GlusterChartPalette dest = new GlusterChartPalette( ); - dest.set( this ); - return dest; - } - - protected void set( Palette src ) - { - if ( src.getEntries( ) != null ) - { - EList list = getEntries( ); - for ( Fill element : src.getEntries( ) ) - { - list.add( element.copyInstance( ) ); - } - } - name = src.getName( ); - } - -} // GlusterChartPalette diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterLogger.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterLogger.java deleted file mode 100644 index b633678a..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GlusterLogger.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.utils; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.Status; - -import com.gluster.storage.management.console.Activator; - -/** - * - */ -public class GlusterLogger { - private static final ILog log = Activator.getDefault().getLog(); - private static GlusterLogger instance = new GlusterLogger(); - - private GlusterLogger() { - } - - public static GlusterLogger getInstance() { - return instance; - } - - private void log(String message, int severity, Throwable t) { - log.log(new Status(severity, Activator.PLUGIN_ID, message, t)); - } - - public void error(String message) { - log(message, Status.ERROR, null); - } - - public void error(String message, Throwable t) { - log(message, Status.ERROR, t); - } - - public void warn(String message) { - log(message, Status.WARNING, null); - } - - public void warn(String message, Throwable t) { - log(message, Status.WARNING, t); - } - - public void info(String message) { - log(message, Status.INFO, null); - } - - public void info(String message, Throwable t) { - log(message, Status.INFO, t); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ImageUtil.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ImageUtil.java deleted file mode 100644 index d278704b..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/ImageUtil.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * ImageUtil.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.utils; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import com.gluster.storage.management.console.Application; -import com.gluster.storage.management.core.utils.LRUCache; - -/** - * - */ -public class ImageUtil { - private static final LRUCache imageCache = new LRUCache(20); - - public ImageDescriptor getImageDescriptor(String imagePath) { - return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, imagePath); - } - - public synchronized Image getImage(String imagePath) { - if(imageCache.containsKey(imagePath)) { - return imageCache.get(imagePath); - } - return createImage(imagePath); - } - - private Image createImage(String imagePath) { - Image image = getImageDescriptor(imagePath).createImage(); - imageCache.put(imagePath, image); - return image; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/TableViewerComparator.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/TableViewerComparator.java deleted file mode 100644 index 7e11cc6f..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/TableViewerComparator.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.utils; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; - -/** - * Comparator for sorting contents of a table viewer - */ -public class TableViewerComparator extends ViewerComparator { - private int column = -1; - private static final int ASCENDING = 0; - private static final int DESCENDING = 1; - private static final int NONE = -1; - private int direction = DESCENDING; - - public TableViewerComparator() { - this(NONE); - } - - public TableViewerComparator(int direction) { - this.direction = direction; - } - - public int getDirection() { - return direction == DESCENDING ? SWT.DOWN : (direction == ASCENDING ? SWT.UP : SWT.NONE); - } - - public void setColumn(int column) { - if (column == this.column) { - // Same column as last sort; toggle the direction - direction = 1 - direction; - } else { - // first column selection or new column; do an ascending sort - direction = ASCENDING; - this.column = column; - } - } - - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - if(direction == NONE) { - // no sorting - return 0; - } - - int result = super.compare(viewer, e1, e2); - // If descending order, flip the direction - if (direction == DESCENDING) { - result = -result; - } - - return result; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/validators/StringRequiredValidator.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/validators/StringRequiredValidator.java deleted file mode 100644 index cac65829..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/validators/StringRequiredValidator.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.validators; - -import org.eclipse.core.databinding.validation.IValidator; -import org.eclipse.core.databinding.validation.ValidationStatus; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.swt.widgets.Control; - -public class StringRequiredValidator implements IValidator { - protected final String errorText; - protected final ControlDecoration controlDecoration; - protected final Control linkedControl; - - public StringRequiredValidator(String errorText, ControlDecoration controlDecoration, Control linkedControl) { - super(); - this.errorText = errorText; - this.controlDecoration = controlDecoration; - this.linkedControl = linkedControl; - } - - public StringRequiredValidator(String errorText, ControlDecoration controlDecoration) { - this(errorText, controlDecoration, null); - } - - public IStatus validate(Object value) { - if (value instanceof String) { - if (((String) value).isEmpty()) { - controlDecoration.setDescriptionText(errorText); - controlDecoration.show(); - if (linkedControl != null) { - linkedControl.setEnabled(false); - } - return ValidationStatus.error(errorText); - } - } - if(linkedControl != null) { - linkedControl.setEnabled(true); - } - controlDecoration.hide(); - return Status.OK_STATUS; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterAdapterFactory.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterAdapterFactory.java deleted file mode 100644 index d904c8f3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterAdapterFactory.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import com.gluster.storage.management.console.Application; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterDataModel; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Volume; - -public class ClusterAdapterFactory implements IAdapterFactory { - private IWorkbenchAdapter entityAdapter = new IWorkbenchAdapter() { - - @Override - public Object getParent(Object o) { - return ((Entity) o).getParent(); - } - - @Override - public String getLabel(Object o) { - return ((Entity)o).getName(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public ImageDescriptor getImageDescriptor(Object object) { - String iconPath = null; - - if(object instanceof GlusterDataModel || object instanceof Cluster) { - iconPath = IImageKeys.CLUSTER_16x16; - } - - if(object instanceof EntityGroup) { - Class entityType = ((EntityGroup) object).getEntityType(); - if(entityType == Volume.class) { - iconPath = IImageKeys.VOLUMES_16x16; - } else { - iconPath = IImageKeys.SERVERS_16x16; - } - } - - if(object instanceof Volume) { - iconPath = IImageKeys.VOLUME_16x16; - } - - if(object instanceof Server || object instanceof GlusterServer) { - iconPath = IImageKeys.SERVER_16x16; - } - - return AbstractUIPlugin.imageDescriptorFromPlugin( - Application.PLUGIN_ID, iconPath); - } - - @Override - public Object[] getChildren(Object o) { - return ((Entity)o).getChildren().toArray(); - } - }; - - @SuppressWarnings("rawtypes") - @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType == IWorkbenchAdapter.class) { - if (adaptableObject instanceof Entity) { - return entityAdapter; - } - } - return null; - } - - @SuppressWarnings("rawtypes") - @Override - public Class[] getAdapterList() { - return new Class[] { IWorkbenchAdapter.class }; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java deleted file mode 100644 index 6be9f8d9..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ClusterSummaryView.java +++ /dev/null @@ -1,469 +0,0 @@ -/** - * DiscoveredServerView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import java.util.List; - -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ImageHyperlink; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.Activator; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.actions.ActionConstants; -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.console.utils.ChartUtil; -import com.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener; -import com.gluster.storage.management.console.utils.ChartViewerComposite; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.model.Alert; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterDataModel; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; - -/** - * - */ -public class ClusterSummaryView extends ViewPart { - public static final String ID = ClusterSummaryView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private Cluster cluster; - private Composite cpuChartSection; - private Composite networkChartSection; - private GlusterDataModel model = GlusterDataModelManager.getInstance().getModel(); - private ClusterListener clusterListener; - private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - private Composite alertsSection; - private Composite tasksSection; - private static final ChartUtil chartUtil = ChartUtil.getInstance(); - private IPropertyChangeListener propertyChangeListener; - private Label onlineServerCountLabel; - private Label offlineServerCountLabel; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - if (cluster == null) { - cluster = model.getCluster(); - } - setPartName("Summary"); - createSections(parent); - - createListeners(); - } - - private void createListeners() { - createClusterListener(); - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - - createPropertyChangeListener(); - preferenceStore.addPropertyChangeListener(propertyChangeListener ); - } - - private void createPropertyChangeListener() { - propertyChangeListener = new IPropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - String preferenceName = event.getProperty(); - GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - if(preferenceName.equals(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD)) { - modelManager.initializeAggregatedCpuStats(cluster); - String cpuStatsPeriod = (String)event.getNewValue(); - refreshChartSection(cpuChartSection, cluster.getAggregatedCpuStats(), cpuStatsPeriod, "%", 100, 4, - chartUtil.new CpuChartPeriodLinkListener(null, cpuStatsPeriod, toolkit), 2); - } else if(preferenceName.equals(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD)) { - modelManager.initializeAggregatedNetworkStats(cluster); - String networkStatsPeriod = (String)event.getNewValue(); - refreshChartSection(networkChartSection, cluster.getAggregatedNetworkStats(), networkStatsPeriod, "KiB/s", -1, - 4, chartUtil.new NetworkChartPeriodLinkListener(null, networkStatsPeriod, toolkit), 2); - } - } - }; - } - - private void createClusterListener() { - clusterListener = new DefaultClusterListener() { - @Override - public void aggregatedStatsChanged() { - super.aggregatedStatsChanged(); - refreshCharts(); - populateOnlineOfflineServerCount(); - } - - @Override - public void alertsGenerated() { - super.alertsGenerated(); - guiHelper.clearSection(alertsSection); - populateAlerts(); - } - - @Override - public void taskAdded(TaskInfo taskInfo) { - super.taskAdded(taskInfo); - updateTaskSection(); - } - - @Override - public void taskRemoved(TaskInfo taskInfo) { - super.taskRemoved(taskInfo); - updateTaskSection(); - } - - @Override - public void taskUpdated(TaskInfo taskInfo) { - super.taskUpdated(taskInfo); - updateTaskSection(); - } - - private void updateTaskSection() { - guiHelper.clearSection(tasksSection); - populateTasksSection(); - } - }; - } - - @Override - public void dispose() { - super.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - preferenceStore.removePropertyChangeListener(propertyChangeListener); - } - - private void refreshCharts() { - String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD); - String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD); - refreshChartSection(cpuChartSection, cluster.getAggregatedCpuStats(), cpuStatsPeriod, "%", 100, 4, - chartUtil.new CpuChartPeriodLinkListener(null, cpuStatsPeriod, toolkit), 2); - refreshChartSection(networkChartSection, cluster.getAggregatedNetworkStats(), networkStatsPeriod, "KiB/s", -1, - 4, chartUtil.new NetworkChartPeriodLinkListener(null, networkStatsPeriod, toolkit), 2); - } - - private int getServerCountByStatus(Cluster cluster, SERVER_STATUS status) { - int count = 0; - for (GlusterServer server : cluster.getServers()) { - if (server.getStatus() == status) { - count++; - } - } - return count; - } - - private void createServersSection() { - Composite section = guiHelper.createSection(form, toolkit, "Servers", null, 2, false); - toolkit.createLabel(section, "Online : "); - onlineServerCountLabel = toolkit.createLabel(section, ""); - - toolkit.createLabel(section, "Offline : "); - offlineServerCountLabel = toolkit.createLabel(section, ""); - populateOnlineOfflineServerCount(); - } - - private void populateOnlineOfflineServerCount() { - int onlineServerCount = getServerCountByStatus(cluster, SERVER_STATUS.ONLINE); - int offlineServerCount = getServerCountByStatus(cluster, SERVER_STATUS.OFFLINE); - onlineServerCountLabel.setText("" + onlineServerCount); - onlineServerCountLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN)); - offlineServerCountLabel.setText("" + offlineServerCount); - offlineServerCountLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - } - - - private void createDiskSpaceSection() { - Composite section = guiHelper.createSection(form, toolkit, "Disk Space", null, 3, false); - if (cluster.getServers().size() == 0) { - toolkit.createLabel(section, "This section will be populated after at least" + CoreConstants.NEWLINE - + "one server is added to the storage cloud."); - return; - } - - double totalDiskSpace = cluster.getTotalDiskSpace(); - double diskSpaceInUse = cluster.getDiskSpaceInUse(); - Double[] values = new Double[] { diskSpaceInUse / 1024, (totalDiskSpace - diskSpaceInUse) / 1024 }; - createDiskSpaceChart(section, values); - } - - private void createDiskSpaceChart(Composite section, Double[] values) { - String[] categories = new String[] { "Used Space (GB)", "Free Space (GB)" }; - ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, categories, values); - - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = 400; - data.heightHint = 180; - data.verticalAlignment = SWT.CENTER; - chartViewerComposite.setLayoutData(data); - } - - private void createAlertsSection() { - alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false); - populateAlerts(); - } - - private void populateAlerts() { - List alerts = cluster.getAlerts(); - for (Alert alert : alerts) { - addAlertLabel(alertsSection, alert); - } - alertsSection.layout(); - form.reflow(true); - } - - private void addAlertLabel(Composite section, Alert alert) { - CLabel lblAlert = new CLabel(section, SWT.FLAT); - GridData layoutData = new GridData(); - layoutData.widthHint = 400; - layoutData.horizontalIndent = 20; - lblAlert.setLayoutData(layoutData); - - Image alertImage = null; - switch (alert.getType()) { - case OFFLINE_VOLUME_BRICKS_ALERT: - alertImage = guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22); - break; - case DISK_USAGE_ALERT: - alertImage = guiHelper.getImage(IImageKeys.LOW_DISK_SPACE_22x22); - break; - case OFFLINE_SERVERS_ALERT: - alertImage = guiHelper.getImage(IImageKeys.SERVER_OFFLINE_22x22); - break; - case MEMORY_USAGE_ALERT: - alertImage = guiHelper.getImage(IImageKeys.MEMORY_USAGE_ALERT_22x22); - break; - case CPU_USAGE_ALERT: - alertImage = guiHelper.getImage(IImageKeys.SERVER_WARNING_22x22); - break; - case OFFLINE_VOLUME_ALERT: - alertImage = guiHelper.getImage(IImageKeys.VOLUME_OFFLINE_22x22); - break; - } - lblAlert.setText(alert.getMessage()); - ControlDecoration dec = new ControlDecoration(lblAlert, SWT.LEFT); - dec.setImage(alertImage); - lblAlert.redraw(); - } - - private void createActionsSection() { - Composite section = guiHelper.createSection(form, toolkit, "Actions", null, 1, false); - - ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(section, SWT.NONE); - imageHyperlink.setText("Create Volume"); - imageHyperlink.setImage(guiHelper.getImage(IImageKeys.CREATE_VOLUME_48x48)); - imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(HyperlinkEvent e) { - IHandlerService hs = (IHandlerService) getSite().getService(IHandlerService.class); - try { - hs.executeCommand(ActionConstants.COMMAND_CREATE_VOLUME, null); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - }); - - imageHyperlink = toolkit.createImageHyperlink(section, SWT.NONE); - imageHyperlink.setText("Add Server(s)"); - imageHyperlink.setImage(guiHelper.getImage(IImageKeys.ADD_SERVER_48x48)); - imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(HyperlinkEvent e) { - // Open the "discovered servers" view by selecting the corresponding entity in the navigation view - EntityGroup autoDiscoveredServersEntityGroup = GlusterDataModelManager.getInstance().getModel() - .getCluster().getEntityGroup(Server.class); - - NavigationView navigationView = (NavigationView) guiHelper.getView(NavigationView.ID); - navigationView.selectEntity(autoDiscoveredServersEntityGroup); - } - }); - } - - private void createSections(Composite parent) { - form = guiHelper.setupForm(parent, toolkit, "Cluster Summary"); - - if (cluster.getServers().size() > 0 - && (cluster.getAggregatedCpuStats().getRows() == null || cluster.getAggregatedNetworkStats().getRows() == null)) { - // cluster has servers, but stats are null. Happens when user logs in to a new cluster, ' - // and then adds the first server. - GlusterDataModelManager.getInstance().initializeAggregatedCpuStats(cluster); - GlusterDataModelManager.getInstance().initializeAggregatedNetworkStats(cluster); - } - - createServersSection(); - createDiskSpaceSection(); - createCPUUsageSection(); - createNetworkUsageSection(); - createActionsSection(); - createAlertsSection(); - createTasksSection(); - - parent.layout(); // IMP: lays out the form properly - } - - private Composite createAreaChartSection(ServerStats stats, String sectionTitle, int dataColumnIndex, String unit, String timestampFormat, ChartPeriodLinkListener listener, double maxValue, int chartLinkColumnCount) { - Composite section = guiHelper.createSection(form, toolkit, sectionTitle, null, 1, false); - if (cluster.getServers().size() == 0) { - toolkit.createLabel(section, "This section will be populated after at least" + CoreConstants.NEWLINE - + "one server is added to the storage cloud."); - return section; - } - - ChartUtil.getInstance().createAreaChart(toolkit, section, stats, dataColumnIndex, unit, timestampFormat, listener, maxValue, chartLinkColumnCount); - return section; - } - - private void createCPUUsageSection() { - IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD); - - // in case of CPU usage, there are three elements in usage data: user, system and total. we use total. - cpuChartSection = createAreaChartSection(cluster.getAggregatedCpuStats(), "CPU Usage (Aggregated)", 2, "%", - getTimestampFormatForPeriod(cpuStatsPeriod), chartUtil.new CpuChartPeriodLinkListener(null, - cpuStatsPeriod, toolkit), 100, 4); - } - - private String getTimestampFormatForPeriod(String statsPeriod) { - if(statsPeriod.equals(GlusterConstants.STATS_PERIOD_1DAY)) { - return "HH:mm"; - } else if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1WEEK)) { - return "dd-MMM HH:mm"; - } else { - return "dd-MMM"; - } - } - - private void createNetworkUsageSection() { - IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD); - - // in case of network usage, there are three elements in usage data: received, transmitted and total. we use total. - networkChartSection = createAreaChartSection(cluster.getAggregatedNetworkStats(), "Network Usage (Aggregated)", - 2, "KiB/s", getTimestampFormatForPeriod(networkStatsPeriod), - chartUtil.new NetworkChartPeriodLinkListener(null, networkStatsPeriod, toolkit), -1, 4); - } - - private void createTasksSection() { - tasksSection = guiHelper.createSection(form, toolkit, CoreConstants.RUNNING_TASKS, null, 1, false); - populateTasksSection(); - } - - private void populateTasksSection() { - for (TaskInfo taskInfo : cluster.getTaskInfoList()) { - if (taskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS) { - addTaskLabel(tasksSection, taskInfo); - } - } - tasksSection.layout(); - form.reflow(true); - } - - private void addTaskLabel(Composite section, TaskInfo taskInfo) { - //TODO: create link and open the task progress view - CLabel lblAlert = new CLabel(section, SWT.NONE); - - Image taskImage = null; - switch(taskInfo.getType()) { - case DISK_FORMAT: - taskImage = guiHelper.getImage(IImageKeys.DISK_INITIALIZING_22x22); - break; - case BRICK_MIGRATE: - taskImage = guiHelper.getImage(IImageKeys.BRICK_MIGRATE_22x22); - break; - case VOLUME_REBALANCE: - taskImage = guiHelper.getImage(IImageKeys.VOLUME_REBALANCE_22x22); - break; - } - - String description = taskInfo.getDescription(); - switch (taskInfo.getStatus().getCode()) { - case Status.STATUS_CODE_PAUSE: - description += " (paused)"; - break; - case Status.STATUS_CODE_COMMIT_PENDING: - description += " (commit pending)"; - break; - case Status.STATUS_CODE_FAILURE: - description += " (failed)"; - break; - } - lblAlert.setText(description); - lblAlert.setImage(taskImage); - lblAlert.redraw(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - if (form != null) { - form.setFocus(); - } - } - - private void refreshChartSection(Composite section, ServerStats stats, String statsPeriod, String unit, - double maxValue, int columnCount, ChartPeriodLinkListener linkListener, int dataColumnIndex) { - if(stats == null) { - return; - } - - for (Control control : section.getChildren()) { - if (!control.isDisposed()) { - control.dispose(); - } - } - chartUtil.createAreaChart(toolkit, section, stats, dataColumnIndex, unit, - getTimestampFormatForPeriod(statsPeriod), linkListener, maxValue, columnCount); - section.layout(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServerView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServerView.java deleted file mode 100644 index abc9ec2f..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServerView.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * DiscoveredServerView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.utils.NumberUtil; - -/** - * @author root - * - */ -public class DiscoveredServerView extends ViewPart { - public static final String ID = DiscoveredServerView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private Server server; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - if (server == null) { - server = guiHelper.getSelectedEntity(getSite(), Server.class); - } - createSections(parent); - } - - private void createServerSummarySection() { - Composite section = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); - - toolkit.createLabel(section, "Number of CPUs: ", SWT.NONE); - toolkit.createLabel(section, "" + server.getNumOfCPUs(), SWT.NONE); - - toolkit.createLabel(section, "Total Memory (GB): ", SWT.NONE); - toolkit.createLabel(section, "" + NumberUtil.formatNumber((server.getTotalMemory() / 1024)), SWT.NONE); - - toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); - toolkit.createLabel(section, "" + NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)), SWT.NONE); - } - - private void createSections(Composite parent) { - String serverName = server.getName(); - form = guiHelper.setupForm(parent, toolkit, "Discovered Server Summary [" + serverName + "]"); - createServerSummarySection(); - - parent.layout(); // IMP: lays out the form properly - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - if (form != null) { - form.setFocus(); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServersView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServersView.java deleted file mode 100644 index ab3cd556..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DiscoveredServersView.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * DiscoveredServersView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.ServersPage; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Server; - -/** - * - */ -public class DiscoveredServersView extends ViewPart implements IDoubleClickListener { - public static final String ID = DiscoveredServersView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private EntityGroup servers; - private ServersPage page; - - public DiscoveredServersView() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void createPartControl(Composite parent) { - if (servers == null) { - Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Server.class) { - servers = (EntityGroup)selectedObj; - } - } - - page = new ServersPage(parent, getSite(), servers); - page.addDoubleClickListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - page.setFocus(); - } - - @Override - public void doubleClick(DoubleClickEvent event) { - NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); - if (clusterView != null) { - clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DisksView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DisksView.java deleted file mode 100644 index 7ba1a88a..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/DisksView.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.gluster.storage.management.console.views; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.DisksPage; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterServer; - -public class DisksView extends ViewPart { - public static final String ID = DisksView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private EntityGroup servers; - private DisksPage page; - - @SuppressWarnings("unchecked") - @Override - public void createPartControl(Composite parent) { - if (servers == null) { - servers = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - } - - page = new DisksPage(parent, SWT.NONE, getSite(), getAllDisks(servers)); - //page.layout(); // IMP: lays out the form properly - } - - private List getAllDisks(EntityGroup servers) { - List disks = new ArrayList(); - for(GlusterServer server : servers.getEntities()) { - disks.addAll(server.getDisks()); - } - return disks; - } - - @Override - public void setFocus() { - page.setFocus(); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerDisksView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerDisksView.java deleted file mode 100644 index d3cd98e8..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerDisksView.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * GlusterServerDisksView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.ServerDisksPage; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; -import com.gluster.storage.management.core.model.GlusterServer; - -public class GlusterServerDisksView extends ViewPart { - public static final String ID = GlusterServerDisksView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private ClusterListener clusterListener; - private GlusterServer server; - private ServerDisksPage page; - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - if (server == null) { - server = guiHelper.getSelectedEntity(getSite(), GlusterServer.class); - } - page = new ServerDisksPage(parent, SWT.NONE, getSite(), server.getDisks()); - - final ViewPart thisView = this; - clusterListener = new DefaultClusterListener() { - @Override - public void serverChanged(GlusterServer server, Event event) { - super.serverChanged(server, event); - if(event.getEventType() == EVENT_TYPE.GLUSTER_SERVER_CHANGED) { - if(!server.isOnline()) { - getViewSite().getPage().hideView(thisView); - } - } - } - }; - - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - - parent.layout(); // IMP: lays out the form properly - } - - @Override - public void dispose() { - super.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - page.setFocus(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerLogsView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerLogsView.java deleted file mode 100644 index 33c85be2..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerLogsView.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * GlusterServerLogsView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.ServerLogsPage; -import com.gluster.storage.management.core.model.GlusterServer; - -public class GlusterServerLogsView extends ViewPart { - public static final String ID = GlusterServerLogsView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private GlusterServer server; - private ServerLogsPage page; - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - if (server == null) { - server = guiHelper.getSelectedEntity(getSite(), GlusterServer.class); - } - - page = new ServerLogsPage(parent, SWT.NONE, server); - - parent.layout(); // IMP: lays out the form properly - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - page.setFocus(); - } -} - diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java deleted file mode 100644 index 08344f84..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java +++ /dev/null @@ -1,544 +0,0 @@ -/** - * GlusterServerSummaryView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.birt.chart.util.CDateTime; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.ProgressBar; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.client.GlusterServersClient; -import com.gluster.storage.management.console.Activator; -import com.gluster.storage.management.console.ConsoleConstants; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.NetworkInterfaceTableLabelProvider; -import com.gluster.storage.management.console.preferences.PreferenceConstants; -import com.gluster.storage.management.console.toolbar.GlusterToolbarManager; -import com.gluster.storage.management.console.utils.ChartUtil; -import com.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener; -import com.gluster.storage.management.console.utils.ChartViewerComposite; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.ServerStatsRow; -import com.gluster.storage.management.core.utils.NumberUtil; -import com.ibm.icu.util.Calendar; -import com.richclientgui.toolbox.gauges.CoolGauge; - -public class GlusterServerSummaryView extends ViewPart { - public static final String ID = GlusterServerSummaryView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private GlusterServer server; - private ClusterListener clusterListener; - private static final int CHART_WIDTH = 350; - private static final int CHART_HEIGHT = 250; - private static final GlusterLogger logger = GlusterLogger.getInstance(); - private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); - - public enum NETWORK_INTERFACE_TABLE_COLUMN_INDICES { - INTERFACE, MODEL, SPEED, IP_ADDRESS, NETMASK, GATEWAY - }; - - private static final String[] NETWORK_INTERFACE_TABLE_COLUMN_NAMES = { "Interface", "Model", "Speed", "IP Address", - "Netmask", "Gateway" }; - private CoolGauge cpuGauge; - private IPropertyChangeListener propertyChangeListener; - private Composite cpuUsageSection; - private Composite networkUsageSection; - private Composite memoryUsageSection; - private static final ChartUtil chartUtil = ChartUtil.getInstance(); - private Composite serverSummarySection; - private Label numCpus; - private ProgressBar memoryUsageBar; - private ProgressBar diskUsageBar; - private CLabel lblServerStatus; - - @Override - public void createPartControl(Composite parent) { - if (server == null) { - server = guiHelper.getSelectedEntity(getSite(), GlusterServer.class); - } - setPartName("Summary"); - createSections(parent); - - createListeners(); - } - - private void createListeners() { - // Refresh the server details whenever the server has changed - createClusterListener(); - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - - createPropertyChangeListener(); - preferenceStore.addPropertyChangeListener(propertyChangeListener); - } - - private void createPropertyChangeListener() { - propertyChangeListener = new IPropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent event) { - String propertyName = event.getProperty(); - if(propertyName.equals(PreferenceConstants.P_CPU_CHART_PERIOD)) { - refreshCpuChart(); - } else if(propertyName.equals(PreferenceConstants.P_MEM_CHART_PERIOD)) { - refreshMemoryChart(); - } else if (propertyName.equals(PreferenceConstants.P_NETWORK_CHART_PERIOD) - || propertyName.equals(PreferenceConstants.P_DEFAULT_NETWORK_INTERFACE_PFX + server.getName())) { - refreshNetworkChart(); - } - } - }; - } - - private void createClusterListener() { - final GlusterToolbarManager toolbarManager = new GlusterToolbarManager(getSite().getWorkbenchWindow()); - final GlusterServer thisServer = server; - clusterListener = new DefaultClusterListener() { - - @Override - public void serverChanged(GlusterServer server, Event event) { - if (event.getEventType() == EVENT_TYPE.GLUSTER_SERVER_CHANGED && server == thisServer) { - updateServerDetails(); - toolbarManager.updateToolbar(server); - refreshCharts(); - } - } - }; - } - - private void refreshCharts() { - refreshCpuChart(); - refreshMemoryChart(); - refreshNetworkChart(); - } - - private void refreshNetworkChart() { - guiHelper.clearSection(networkUsageSection); - String statsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_CHART_PERIOD); - String networkInterface = preferenceStore.getString(PreferenceConstants.P_DEFAULT_NETWORK_INTERFACE_PFX + server.getName()); - if(networkInterface == null || networkInterface.isEmpty()) { - networkInterface = server.getNetworkInterfaces().get(0).getName(); - } - ServerStats stats = new GlusterServersClient().getNetworkStats(server.getName(), networkInterface, statsPeriod); - chartUtil.refreshChartSection(toolkit, networkUsageSection, stats, statsPeriod, "KiB/s", -1, 5, chartUtil.new NetworkChartPeriodLinkListener(server, statsPeriod, toolkit), 2); - } - - private void refreshMemoryChart() { - guiHelper.clearSection(memoryUsageSection); - String statsPeriod = preferenceStore.getString(PreferenceConstants.P_MEM_CHART_PERIOD); - ServerStats stats = new GlusterServersClient().getMemoryStats(server.getName(), statsPeriod); - chartUtil.refreshChartSection(toolkit, memoryUsageSection, stats, statsPeriod, "%", 100, 4, chartUtil.new MemoryChartPeriodLinkListener(server.getName(), statsPeriod, toolkit), 0); - } - - private void refreshCpuChart() { - guiHelper.clearSection(cpuUsageSection); - String statsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_CHART_PERIOD); - ServerStats stats = new GlusterServersClient().getCpuStats(server.getName(), statsPeriod); - chartUtil.refreshChartSection(toolkit, cpuUsageSection, stats, statsPeriod, "%", 100, 4, - chartUtil.new CpuChartPeriodLinkListener(server.getName(), statsPeriod, toolkit), 2); - } - - private void updateServerDetails() { - // TODO: Update the server details (cpu usage, memory usage) - populateServerSummarySection(server); - - } - - @Override - public void dispose() { - super.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - preferenceStore.removePropertyChangeListener(propertyChangeListener); - } - - private void createAreaChart(Composite section, Calendar timestamps[], Double values[], String unit) { - ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, unit, "HH:mm", 100); - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = CHART_WIDTH; - data.heightHint = CHART_HEIGHT; - chartViewerComposite.setLayoutData(data); - } - - private void extractChartData(ServerStats stats, List timestamps, List data, int dataColumnIndex) { - for(ServerStatsRow row : stats.getRows()) { - Double cpuUsage = row.getUsageData().get(dataColumnIndex); - if(!cpuUsage.isNaN()) { - timestamps.add(new CDateTime(row.getTimestamp() * 1000)); - data.add(cpuUsage); - } - } - } - - private void createAreaChartSection(ServerStats stats, String sectionTitle, int dataColumnIndex, String unit) { - List timestamps = new ArrayList(); - List data = new ArrayList(); - extractChartData(stats, timestamps, data, dataColumnIndex); - - if(timestamps.size() == 0) { - // Log a message saying no CPU stats available - return; - } - - Composite section = guiHelper.createSection(form, toolkit, sectionTitle, null, 1, false); - createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit); - -// Calendar[] timestamps = new Calendar[] { new CDateTime(1000l*1310468100), new CDateTime(1000l*1310468400), new CDateTime(1000l*1310468700), -// new CDateTime(1000l*1310469000), new CDateTime(1000l*1310469300), new CDateTime(1000l*1310469600), new CDateTime(1000l*1310469900), -// new CDateTime(1000l*1310470200), new CDateTime(1000l*1310470500), new CDateTime(1000l*1310470800), new CDateTime(1000l*1310471100), -// new CDateTime(1000l*1310471400), new CDateTime(1000l*1310471700), new CDateTime(1000l*1310472000), new CDateTime(1000l*1310472300), -// new CDateTime(1000l*1310472600), new CDateTime(1000l*1310472900), new CDateTime(1000l*1310473200), new CDateTime(1000l*1310473500), -// new CDateTime(1000l*1310473800) }; -// -// Double[] values = new Double[] { 10d, 11.23d, 17.92d, 18.69d, 78.62d, 89.11d, 92.43d, 89.31d, 57.39d, 18.46d, 10.44d, 16.28d, 13.51d, 17.53d, 12.21, 20d, 21.43d, 16.45d, 14.86d, 15.27d }; -// createLineChart(section, timestamps, values, "%"); - createChartLinks(section, 4); - } - - private void createMemoryUsageSection() { - String memStatsPeriod = preferenceStore.getString(PreferenceConstants.P_MEM_CHART_PERIOD); - memoryUsageSection = guiHelper.createSection(form, toolkit, "Memory Usage", null, 1, false); - - ServerStats stats; - try { - stats = new GlusterServersClient().getMemoryStats(server.getName(), memStatsPeriod); - } catch(Exception e) { - logger.error("Couldn't fetch memory usage statistics for server [" + server.getName() + "]", e); - toolkit.createLabel(memoryUsageSection, "Couldn't fetch memory usage statistics for server [" + server.getName() + "]! Error: [" + e.getMessage() + "]"); - return; - } - - // in case of memory usage, there are four elements in usage data: user, free, cache, buffer and total. we use "user". - ChartUtil chartUtil = ChartUtil.getInstance(); - chartUtil.createAreaChart(toolkit, memoryUsageSection, stats, 0, "%", chartUtil - .getTimestampFormatForPeriod(memStatsPeriod), - chartUtil.new MemoryChartPeriodLinkListener(server.getName(), memStatsPeriod, toolkit), 100, 4); - } - - private void createCPUUsageSection() { - String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_CHART_PERIOD); - cpuUsageSection = guiHelper.createSection(form, toolkit, "CPU Usage", null, 1, false); - - ServerStats stats; - try { - stats = new GlusterServersClient().getCpuStats(server.getName(), cpuStatsPeriod); - } catch(Exception e) { - logger.error("Couldn't fetch CPU usage statistics for server [" + server.getName() + "]", e); - toolkit.createLabel(cpuUsageSection, "Couldn't fetch CPU usage statistics for server [" + server.getName() + "]! Error: [" + e.getMessage() + "]"); - return; - } - - // in case of CPU usage, there are three elements in usage data: user, system and total. we use total. - chartUtil.createAreaChart(toolkit, cpuUsageSection, stats, 2, "%", chartUtil - .getTimestampFormatForPeriod(cpuStatsPeriod), - chartUtil.new CpuChartPeriodLinkListener(server.getName(), cpuStatsPeriod, toolkit), 100, 4); - } - - private void createNetworkUsageSection() { - final String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_CHART_PERIOD); - networkUsageSection = guiHelper.createSection(form, toolkit, "Network Usage", null, 1, false); - - String networkInterface = server.getNetworkInterfaces().get(0).getName(); - ServerStats stats; - try { - stats = new GlusterServersClient().getNetworkStats(server.getName(), networkInterface, networkStatsPeriod); - } catch(Exception e) { - logger.error("Couldn't fetch Network usage statistics for server [" + server.getName() + "] network interface [" + networkInterface + "]", e); - toolkit.createLabel(networkUsageSection, "Couldn't fetch CPU usage statistics for server [" + server.getName() + "]! Error: [" + e.getMessage() + "]"); - return; - } - - // in case of network usage, there are three elements in usage data: received, transmitted and total. we use total. - final ChartUtil chartUtil = ChartUtil.getInstance(); - final ChartPeriodLinkListener networkChartPeriodLinkListener = chartUtil.new NetworkChartPeriodLinkListener(server, networkStatsPeriod, toolkit); - chartUtil.createAreaChart(toolkit, networkUsageSection, stats, 2, "KiB/s", chartUtil - .getTimestampFormatForPeriod(networkStatsPeriod), - networkChartPeriodLinkListener , -1, 5); - } - - private Composite createChartLinks(Composite section, int columnCount) { - GridLayout layout = new org.eclipse.swt.layout.GridLayout(columnCount, false); - layout.marginBottom = 0; - layout.marginTop = 0; - layout.marginLeft = (CHART_WIDTH - (50*columnCount)) / 2; - Composite graphComposite = toolkit.createComposite(section, SWT.NONE); - graphComposite.setLayout(layout); - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = CHART_WIDTH; - graphComposite.setLayoutData(data); - - Label label1 = toolkit.createLabel(graphComposite, "1 day"); - Hyperlink link1 = toolkit.createHyperlink(graphComposite, "1 week", SWT.NONE); - Hyperlink link2 = toolkit.createHyperlink(graphComposite, "1 month", SWT.NONE); - Hyperlink link3 = toolkit.createHyperlink(graphComposite, "1 year", SWT.NONE); - - return graphComposite; - } - - private void createSections(Composite parent) { - String serverName = server.getName(); - form = guiHelper.setupForm(parent, toolkit, "Server Summary [" + serverName + "]"); - createServerSummarySection(server, toolkit, form); - - if (server.getStatus() == SERVER_STATUS.ONLINE) { - try { - new ProgressMonitorDialog(getSite().getShell()).run(false, false, new IRunnableWithProgress() { - - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask("Creating Server Summary View", 4); - monitor.setTaskName("Creating Memory Usage Section"); - createMemoryUsageSection(); - monitor.worked(1); - - monitor.setTaskName("Creating Network Usage Section"); - createNetworkUsageSection(); - monitor.worked(1); - - monitor.setTaskName("Creating CPU Usage Section"); - createCPUUsageSection(); - monitor.worked(1); - - monitor.setTaskName("Creating Network Interfaces Section"); - createNetworkInterfacesSection(server, toolkit, form); - monitor.worked(1); - monitor.done(); - } - }); - } catch (Exception e) { - String errMsg = "Exception while creating the Gluster Server Summary View : [" + e.getMessage() + "]"; - logger.error(errMsg, e); - MessageDialog.openError(getSite().getShell(), ConsoleConstants.CONSOLE_TITLE, errMsg); - } - } - - parent.layout(); // IMP: lays out the form properly - } - - private void createServerSummarySection(GlusterServer server, FormToolkit toolkit, final ScrolledForm form) { - serverSummarySection = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); - // toolkit.createLabel(section, "Preferred Network: ", SWT.NONE); - // toolkit.createLabel(section, server.getPreferredNetworkInterface().getName(), SWT.NONE); - - if (server.isOnline()) { - toolkit.createLabel(serverSummarySection, "Number of CPUs: ", SWT.NONE); - numCpus = toolkit.createLabel(serverSummarySection, "" + server.getNumOfCPUs(), SWT.NONE); - - toolkit.createLabel(serverSummarySection, "% CPU Usage (avg): ", SWT.NONE); - cpuGauge = new CoolGauge(serverSummarySection, guiHelper.getImage(IImageKeys.GAUGE_SMALL)); - - toolkit.createLabel(serverSummarySection, "Memory Usage: ", SWT.NONE); - memoryUsageBar = new ProgressBar(serverSummarySection, SWT.SMOOTH); - - // toolkit.createLabel(section, "Memory Usage: ", SWT.NONE); - // final CoolProgressBar bar = new CoolProgressBar(section,SWT.HORIZONTAL, - // guiHelper.getImage(IImageKeys.PROGRESS_BAR_LEFT), - // guiHelper.getImage(IImageKeys.PROGRESS_BAR_FILLED), - // guiHelper.getImage(IImageKeys.PROGRESS_BAR_EMPTY), - // guiHelper.getImage(IImageKeys.PROGRESS_BAR_RIGHT)); - // bar.updateProgress(server.getMemoryInUse() / server.getTotalMemory()); - - // toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); - // toolkit.createLabel(section, online ? "" + server.getTotalDiskSpace() : "NA", SWT.NONE); - // - // toolkit.createLabel(section, "Disk Space in Use (GB): ", SWT.NONE); - // toolkit.createLabel(section, online ? "" + server.getDiskSpaceInUse() : "NA", SWT.NONE); - - toolkit.createLabel(serverSummarySection, "Disk Usage: ", SWT.NONE); - diskUsageBar = new ProgressBar(serverSummarySection, SWT.SMOOTH); - } - - toolkit.createLabel(serverSummarySection, "Status: ", SWT.NONE); - lblServerStatus = new CLabel(serverSummarySection, SWT.NONE); - populateServerSummarySection(server); - } - - private void populateServerSummarySection(GlusterServer server) { - if (server.isOnline()) { - numCpus.setText("" + server.getNumOfCPUs()); - numCpus.redraw(); - - cpuGauge.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); - cpuGauge.setGaugeNeedleColour(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - cpuGauge.setGaugeNeedleWidth(2); - cpuGauge.setGaugeNeedlePivot(new Point(66, 65)); - - cpuGauge.setPoints(getPnts()); - cpuGauge.setLevel(server.getCpuUsage() / 100); - cpuGauge.setToolTipText(server.getCpuUsage() + "%"); - cpuGauge.redraw(); - - memoryUsageBar.setMinimum(0); - memoryUsageBar.setMaximum((int) Math.round(server.getTotalMemory())); - memoryUsageBar.setSelection((int) Math.round(server.getMemoryInUse())); - memoryUsageBar.setToolTipText("Total: " + NumberUtil.formatNumber((server.getTotalMemory() / 1024)) - + "GB, In Use: " + NumberUtil.formatNumber((server.getMemoryInUse() / 1024)) + "GB"); - - diskUsageBar.setMinimum(0); - diskUsageBar.setMaximum((int) Math.round(server.getTotalDiskSpace())); - diskUsageBar.setSelection((int) Math.round(server.getDiskSpaceInUse())); - diskUsageBar.setToolTipText("Total: " + NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)) - + "GB, In Use: " + NumberUtil.formatNumber((server.getDiskSpaceInUse() / 1024)) + "GB"); - - } - lblServerStatus.setText(server.getStatusStr()); - lblServerStatus.setImage(server.getStatus() == GlusterServer.SERVER_STATUS.ONLINE ? guiHelper - .getImage(IImageKeys.STATUS_ONLINE_16x16) : guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16)); - toolkit.adapt(lblServerStatus, true, true); - - serverSummarySection.layout(); - form.reflow(true); - } - - private List getPnts() { - final List pnts = new ArrayList(); - pnts.add(new Point(47, 98)); - pnts.add(new Point(34, 84)); - pnts.add(new Point(29, 65)); - pnts.add(new Point(33, 48)); - pnts.add(new Point(48, 33)); - pnts.add(new Point(66, 28)); - pnts.add(new Point(83, 32)); - pnts.add(new Point(98, 47)); - pnts.add(new Point(103, 65)); - pnts.add(new Point(98, 83)); - pnts.add(new Point(84, 98)); - return pnts; - } - - private Composite createNetworkInterfacesSection(GlusterServer server, FormToolkit toolkit, ScrolledForm form) { - final Composite section = guiHelper.createSection(form, toolkit, "Network Interfaces", null, 1, false); - createNetworkInterfacesTableViewer(createTableViewerComposite(section), server); - // Hyperlink changePreferredNetworkLink = toolkit.createHyperlink(section, "Change Preferred Network", - // SWT.NONE); - // changePreferredNetworkLink.addHyperlinkListener(new HyperlinkAdapter() { - // - // @Override - // public void linkActivated(HyperlinkEvent e) { - // new MessageDialog( - // section.getShell(), - // "Gluster Storage Platform", - // guiHelper.getImage(IImageKeys.SERVER), - // "This will show additional controls to help user choose a new network interface. TO BE IMPLEMENTED.", - // MessageDialog.INFORMATION, new String[] { "OK" }, 0).open(); - // } - // }); - return section; - } - - private TableViewer createNetworkInterfacesTableViewer(final Composite parent, GlusterServer server) { - TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); - // TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); - tableViewer.setLabelProvider(new NetworkInterfaceTableLabelProvider()); - tableViewer.setContentProvider(new ArrayContentProvider()); - - setupNetworkInterfaceTable(parent, tableViewer.getTable()); - tableViewer.setInput(server.getNetworkInterfaces().toArray()); - - return tableViewer; - } - - private void setupNetworkInterfaceTable(Composite parent, Table table) { - table.setHeaderVisible(true); - table.setLinesVisible(false); - - TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, - NETWORK_INTERFACE_TABLE_COLUMN_NAMES); - parent.setLayout(tableColumnLayout); - - setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.INTERFACE, SWT.CENTER, 70); - setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.MODEL, SWT.CENTER, 70); - setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.SPEED, SWT.CENTER, 70); - setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.IP_ADDRESS, SWT.CENTER, 100); - setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.NETMASK, SWT.CENTER, 70); - setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.GATEWAY, SWT.CENTER, 70); - } - - private Composite createTableViewerComposite(Composite parent) { - Composite tableViewerComposite = new Composite(parent, SWT.NO); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false); - tableLayoutData.widthHint = 400; - tableLayoutData.minimumWidth = 400; - // tableLayoutData.grabExcessHorizontalSpace = true; - tableViewerComposite.setLayoutData(tableLayoutData); - return tableViewerComposite; - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - public void setColumnProperties(Table table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES columnIndex, int alignment, - int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } - - @Override - public void setFocus() { - form.setFocus(); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersSummaryView.java deleted file mode 100644 index afca5ad5..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersSummaryView.java +++ /dev/null @@ -1,290 +0,0 @@ -/** - * GlusterServersSummaryView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.ChartViewerComposite; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Alert; -import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; - -/** - * - */ -public class GlusterServersSummaryView extends ViewPart { - public static final String ID = GlusterServersSummaryView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private ClusterListener clusterListener; - private EntityGroup servers; - private Composite alertsSection; - private Composite serversAvailabilitySection; - private Composite tasksSection; - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @SuppressWarnings("unchecked") - @Override - public void createPartControl(Composite parent) { - if (servers == null) { - servers = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - } - setPartName("Summary"); - createSections(parent); - - clusterListener = new DefaultClusterListener() { - @Override - public void serverAdded(GlusterServer server) { - super.serverAdded(server); - updateServerAvailabilitySection(); - } - - @Override - public void serverRemoved(GlusterServer server) { - super.serverRemoved(server); - updateServerAvailabilitySection(); - } - - @Override - public void serverChanged(GlusterServer server, Event event) { - super.serverChanged(server, event); - updateServerAvailabilitySection(); - } - - private void updateServerAvailabilitySection() { - guiHelper.clearSection(serversAvailabilitySection); - populateAvailabilitySection(); - } - - @Override - public void alertsGenerated() { - super.alertsGenerated(); - guiHelper.clearSection(alertsSection); - populateAlertSection(); - } - - @Override - public void taskAdded(TaskInfo taskInfo) { - super.taskAdded(taskInfo); - updateTasksSection(); - } - - @Override - public void taskRemoved(TaskInfo taskInfo) { - super.taskRemoved(taskInfo); - updateTasksSection(); - } - - @Override - public void taskUpdated(TaskInfo taskInfo) { - super.taskUpdated(taskInfo); - updateTasksSection(); - } - - private void updateTasksSection() { - guiHelper.clearSection(tasksSection); - populateTasksSection(); - } - }; - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - } - - @Override - public void dispose() { - super.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } - - /** - * @param parent - */ - private void createSections(Composite parent) { - form = guiHelper.setupForm(parent, toolkit, "Servers - Summary"); - - createSummarySection(); - createRunningTasksSection(); - createAlertsSection(); - - parent.layout(); // IMP: lays out the form properly - } - - private void createSummarySection() { - serversAvailabilitySection = guiHelper.createSection(form, toolkit, "Availability", null, 2, false); - populateAvailabilitySection(); - } - - private void populateAvailabilitySection() { - if (servers.getEntities().size() == 0) { - toolkit.createLabel(serversAvailabilitySection, "This section will be populated after at least" - + CoreConstants.NEWLINE + "one server is added to the storage cloud."); - return; - } - - Double[] values = new Double[] { Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.ONLINE)), - Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.OFFLINE)) }; - createStatusChart(serversAvailabilitySection, values); - } - - private int getServerCountByStatus(EntityGroup servers, SERVER_STATUS status) { - int count = 0; - for (GlusterServer server : servers.getEntities()) { - if (server.getStatus() == status) { - count++; - } - } - return count; - } - - private void createStatusChart(Composite section, Double[] values) { - String[] categories = new String[] { "Online", "Offline" }; - ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, categories, values); - - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = 300; - data.heightHint = 150; - chartViewerComposite.setLayoutData(data); - } - - private void createAlertsSection() { - alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false); - populateAlertSection(); - } - - private void populateAlertSection() { - List alerts = GlusterDataModelManager.getInstance().getModel().getCluster().getAlerts(); - - for (Alert alert : alerts) { - if (alert.getType() == ALERT_TYPES.DISK_USAGE_ALERT || alert.getType() != ALERT_TYPES.OFFLINE_SERVERS_ALERT - || alert.getType() == ALERT_TYPES.MEMORY_USAGE_ALERT - || alert.getType() == ALERT_TYPES.CPU_USAGE_ALERT) { - addAlertLabel(alertsSection, alert); - } - } - alertsSection.pack(true); - form.reflow(true); - } - - private void addAlertLabel(Composite section, Alert alert) { - CLabel lblAlert = new CLabel(section, SWT.FLAT); - Image alertImage = null; - switch (alert.getType()) { - case DISK_USAGE_ALERT: - alertImage = guiHelper.getImage(IImageKeys.LOW_DISK_SPACE_22x22); - break; - case OFFLINE_SERVERS_ALERT: - alertImage = guiHelper.getImage(IImageKeys.SERVER_OFFLINE_22x22); - break; - case MEMORY_USAGE_ALERT: - alertImage = guiHelper.getImage(IImageKeys.MEMORY_USAGE_ALERT_22x22); - break; - case CPU_USAGE_ALERT: - alertImage = guiHelper.getImage(IImageKeys.SERVER_WARNING_22x22); - break; - } - lblAlert.setImage(alertImage); - lblAlert.setText(alert.getMessage()); - lblAlert.redraw(); - } - - private void createRunningTasksSection() { - tasksSection = guiHelper.createSection(form, toolkit, CoreConstants.RUNNING_TASKS, null, 1, false); - populateTasksSection(); - } - - private void populateTasksSection() { - for (TaskInfo taskInfo : GlusterDataModelManager.getInstance().getModel().getCluster().getTaskInfoList()) { - // Exclude volume related tasks - if (taskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS - && taskInfo.getType() != TASK_TYPE.VOLUME_REBALANCE - && taskInfo.getType() != TASK_TYPE.BRICK_MIGRATE) { - addTaskLabel(tasksSection, taskInfo); - } - } - tasksSection.layout(); - form.reflow(true); - } - - private void addTaskLabel(Composite section, TaskInfo taskInfo) { - CLabel lblTask = new CLabel(section, SWT.NONE); - Image taskImage = null; - switch(taskInfo.getType()) { - case DISK_FORMAT: - taskImage = guiHelper.getImage(IImageKeys.DISK_INITIALIZING_22x22); - break; - case BRICK_MIGRATE: - taskImage = guiHelper.getImage(IImageKeys.BRICK_MIGRATE_22x22); - break; - case VOLUME_REBALANCE: - taskImage = guiHelper.getImage(IImageKeys.VOLUME_REBALANCE_22x22); - break; - } - - String description = taskInfo.getDescription(); - switch (taskInfo.getStatus().getCode()) { - case Status.STATUS_CODE_PAUSE: - description += " (paused)"; - break; - case Status.STATUS_CODE_COMMIT_PENDING: - description += " (commit pending)"; - break; - case Status.STATUS_CODE_FAILURE: - description += " (failed)"; - break; - } - - lblTask.setText(description); - lblTask.setImage(taskImage); - lblTask.redraw(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - form.setFocus(); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersView.java deleted file mode 100644 index 66017990..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServersView.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * GlusterServersView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.GlusterServersPage; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterServer; - -/** - * @author root - * - */ -public class GlusterServersView extends ViewPart implements IDoubleClickListener { - public static final String ID = GlusterServersView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private EntityGroup servers; - private GlusterServersPage page; - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @SuppressWarnings("unchecked") - @Override - public void createPartControl(Composite parent) { - if (servers == null) { - servers = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - } - - page = new GlusterServersPage(getSite(), parent, SWT.NONE, servers); - page.addDoubleClickListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - page.setFocus(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) - */ - @Override - public void doubleClick(DoubleClickEvent event) { - NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); - if (clusterView != null) { - clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java deleted file mode 100644 index 05c30626..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterViewsManager.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * GlusterViewsManager.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; - -import com.gluster.storage.management.console.ConsoleConstants; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Volume; - -/** - * @see ViewsManager - */ -public class GlusterViewsManager implements ViewsManager { - private IWorkbenchPage page; - - public GlusterViewsManager(IWorkbenchPage page) { - this.page = page; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.ViewsManager#updateViews(com.gluster.storage.management.core.model.Entity) - */ - @SuppressWarnings("rawtypes") - @Override - public void updateViews(Entity entity) { - closeAllViews(); - - try { - if (entity instanceof EntityGroup) { - showViewsForEntityGroup((EntityGroup)entity); - } else if (entity.getClass() == Server.class) { - showViewsForDiscoveredServer((Server)entity); - } else if (entity.getClass() == GlusterServer.class) { - showViewsForGlusterServer((GlusterServer)entity); - } else if (entity instanceof Volume) { - showViewsForVolume((Volume)entity); - } else if (entity instanceof Cluster) { - showViewsForCluster((Cluster)entity); - } - } catch (PartInitException e) { - e.printStackTrace(); - } - } - - private void closeAllViews() { - IViewReference[] viewReferences = page.getViewReferences(); - for (final IViewReference viewReference : viewReferences) { - if (!(viewReference.getId().equals(NavigationView.ID) || viewReference.getId().equals( - ConsoleConstants.TERMINAL_VIEW_ID))) { - page.hideView(viewReference); - } - } - } - - private void showViewsForCluster(Cluster cluster) throws PartInitException { - page.showView(ClusterSummaryView.ID); - page.showView(TasksView.ID, null, IWorkbenchPage.VIEW_CREATE); - } - - private void showViewsForVolume(Volume volume) throws PartInitException { - page.showView(VolumeSummaryView.ID); - page.showView(VolumeBricksView.ID, null, IWorkbenchPage.VIEW_CREATE); - page.showView(VolumeOptionsView.ID, null, IWorkbenchPage.VIEW_CREATE); - page.showView(VolumeLogsView.ID, null, IWorkbenchPage.VIEW_CREATE); - } - - private void showViewsForGlusterServer(GlusterServer server) throws PartInitException { - page.showView(GlusterServerSummaryView.ID); - if (server.getStatus() == GlusterServer.SERVER_STATUS.ONLINE) { - page.showView(GlusterServerDisksView.ID, null, IWorkbenchPage.VIEW_CREATE); - //page.showView(GlusterServerLogsView.ID, null, IWorkbenchPage.VIEW_CREATE); - } - } - - private void showViewsForDiscoveredServer(Server server) throws PartInitException { - page.showView(DiscoveredServerView.ID); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void showViewsForEntityGroup(EntityGroup entityGroup) throws PartInitException { - Class entityType = entityGroup.getEntityType(); - if (entityType == Server.class) { - showViewForServers(entityGroup); - } else if (entityType == Volume.class) { - showViewsForVolumes(entityGroup); - } else if (entityType == GlusterServer.class) { - showViewsForGlusterServers(entityGroup); - } - } - - private void showViewsForGlusterServers(EntityGroup server) throws PartInitException { - page.showView(GlusterServersSummaryView.ID); - page.showView(GlusterServersView.ID, null, IWorkbenchPage.VIEW_CREATE); - page.showView(DisksView.ID, null, IWorkbenchPage.VIEW_CREATE); - } - - private void showViewsForVolumes(EntityGroup volumes) throws PartInitException { - page.showView(VolumesSummaryView.ID); - page.showView(VolumesView.ID, null, IWorkbenchPage.VIEW_CREATE); - } - - private void showViewForServers(EntityGroup servers) throws PartInitException { - page.showView(DiscoveredServersView.ID); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java deleted file mode 100644 index d7448e76..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views; - -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import com.gluster.storage.management.console.Application; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Volume; - -public class NavigationTreeLabelDecorator implements ILightweightLabelDecorator { - - @Override - public void addListener(ILabelProviderListener listener) { - } - - @Override - public void dispose() { - } - - @Override - public boolean isLabelProperty(Object element, String property) { - return false; - } - - @Override - public void removeListener(ILabelProviderListener listener) { - } - - @SuppressWarnings("rawtypes") - @Override - public void decorate(Object element, IDecoration decoration) { - if (element instanceof Volume) { - Volume volume = (Volume) element; - if (volume.getStatus() == Volume.VOLUME_STATUS.OFFLINE) { - decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.OVERLAY_OFFLINE_8x8)); - } else { - decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.OVERLAY_ONLINE_8x8)); - } - } - - if (element instanceof GlusterServer) { - GlusterServer server = (GlusterServer) element; - if (server.getStatus() == GlusterServer.SERVER_STATUS.OFFLINE) { - decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.OVERLAY_OFFLINE_8x8)); - } else { - decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.OVERLAY_ONLINE_8x8)); - } - } - - if (element instanceof Server) { - decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.OVERLAY_STAR_8x8)); - } - - if(element instanceof EntityGroup && ((EntityGroup)element).getEntityType() == Server.class) { - decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, - IImageKeys.OVERLAY_STAR_8x8)); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationView.java deleted file mode 100644 index 21fc4c7a..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/NavigationView.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.model.BaseWorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.toolbar.GlusterToolbarManager; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.GlusterDataModel; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Volume; - -public class NavigationView extends ViewPart implements ISelectionListener { - public static final String ID = NavigationView.class.getName(); - private TreeViewer treeViewer; - private IAdapterFactory adapterFactory = new ClusterAdapterFactory(); - private GlusterToolbarManager toolbarManager; - private Entity entity; - private GlusterViewsManager viewsManager; - private DefaultClusterListener clusterListener; - - @Override - public void createPartControl(Composite parent) { - createNavigationTree(parent); - - // Create the views and toolbar managers - toolbarManager = new GlusterToolbarManager(getSite().getWorkbenchWindow()); - viewsManager = new GlusterViewsManager(getSite().getPage()); - - // listen to selection events to update views/toolbar accordingly - getSite().getPage().addSelectionListener(this); - } - - private void createNavigationTree(Composite parent) { - GlusterDataModel model = GlusterDataModelManager.getInstance().getModel(); - - Platform.getAdapterManager().registerAdapters(adapterFactory, Entity.class); - treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); - treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()); - treeViewer.setContentProvider(new BaseWorkbenchContentProvider()); - treeViewer.setInput(model); - treeViewer.expandAll(); - // select the first element by default - treeViewer.setSelection(new StructuredSelection(model.getChildren().get(0))); - - setupContextMenu(); - - // register as selection provider so that other views can listen to any selection events on the tree - getSite().setSelectionProvider(treeViewer); - - clusterListener = new DefaultClusterListener() { - public void modelChanged() { - treeViewer.refresh(true); - } - - @Override - public void volumeChanged(Volume volume, Event event) { - super.volumeChanged(volume, event); - treeViewer.update(volume, null); - if (volume == entity) { - // this makes sure that the toolbar buttons get updated according to new status - selectEntity(volume); - } - } - - @Override - public void volumeDeleted(Volume volume) { - super.volumeDeleted(volume); - if(volume == entity) { - // volume selected was deleted. select the root element in the tree. - selectEntity(GlusterDataModelManager.getInstance().getModel().getCluster()); - } - } - - @Override - public void serverRemoved(GlusterServer server) { - super.serverRemoved(server); - if(server == entity) { - // server selected was removed. select the root element in the tree. - selectEntity(GlusterDataModelManager.getInstance().getModel().getCluster()); - } - }; - }; - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - } - - private void setupContextMenu() { - MenuManager menuManager = new MenuManager("&Gluster", "gluster.context.menu"); - Menu contextMenu = menuManager.createContextMenu(treeViewer.getControl()); - treeViewer.getTree().setMenu(contextMenu); - getSite().registerContextMenu(menuManager, treeViewer); - } - - public void selectEntity(Entity entity) { - treeViewer.setSelection(new StructuredSelection(entity)); - treeViewer.reveal(entity); - setFocus(); // this ensures that the "selection changed" event gets fired - } - - @Override - public void setFocus() { - treeViewer.getControl().setFocus(); - } - - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (part instanceof NavigationView && selection instanceof TreeSelection) { - Entity selectedEntity = (Entity) ((TreeSelection) selection).getFirstElement(); - - if (selectedEntity != null && selectedEntity != entity) { - entity = selectedEntity; - - // update views and toolbar buttons visibility based on selected entity - viewsManager.updateViews(entity); - toolbarManager.updateToolbar(entity); - - // Opening of other views may cause navigation tree to lose focus; get it back. - setFocus(); - } - } - } - - @Override - public void dispose() { - super.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TasksView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TasksView.java deleted file mode 100644 index e408e64e..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/TasksView.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gluster.storage.management.console.views; - -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.views.pages.TasksPage; -import com.gluster.storage.management.core.model.TaskInfo; - -public class TasksView extends ViewPart { - - public static final String ID = TasksView.class.getName(); - private TasksPage page; - - - public TasksView() { - // TODO Auto-generated constructor stub - } - - @Override - public void createPartControl(Composite parent) { - page = new TasksPage(getSite(), parent, SWT.NONE, getAllTasks()); - page.layout(); // IMP: lays out the form properly - } - - - private List getAllTasks() { - return GlusterDataModelManager.getInstance().getModel().getCluster().getTaskInfoList(); - } - - @Override - public void setFocus() { - page.setFocus(); - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ViewsManager.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ViewsManager.java deleted file mode 100644 index 5b19ea98..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/ViewsManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * ViewsManager.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import com.gluster.storage.management.core.model.Entity; - -/** - * Whenever the current selection/action demands opening different set of views, the views manager is used to open - * appropriate views. - */ -public interface ViewsManager { - /** - * Updates the views for given entity. This typically means that user is working with the given entity, and hence - * the views related to that entity should be made visible, and other un-related views should be hidden. - * - * @param entity - * The entity for which views are to be updated - */ - public void updateViews(Entity entity); -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeBricksView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeBricksView.java deleted file mode 100644 index 33cd1f38..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeBricksView.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.BricksPage; -import com.gluster.storage.management.core.model.Volume; - -public class VolumeBricksView extends ViewPart { - public static final String ID = VolumeBricksView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private BricksPage page; - private Volume volume; - - @Override - public void createPartControl(Composite parent) { - if (volume == null) { - volume = guiHelper.getSelectedEntity(getSite(), Volume.class); - } - - createPage(parent); - } - - /** - * @param parent - */ - private void createPage(Composite parent) { - page = new BricksPage(parent, SWT.NONE, getSite(), volume.getBricks()); - parent.layout(); // IMP: lays out the form properly - } - - @Override - public void setFocus() { - page.setFocus(); - } -} - diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeLogsView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeLogsView.java deleted file mode 100644 index 74ef5616..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeLogsView.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.gluster.storage.management.console.views; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.VolumeLogsPage; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeLogMessage; -import com.gluster.storage.management.core.utils.DateUtil; - -public class VolumeLogsView extends ViewPart implements IDoubleClickListener { - VolumeLogsPage logsPage; - public static final String ID = VolumeLogsView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private Volume volume; - - @Override - public void createPartControl(Composite parent) { - if (volume == null) { - volume = guiHelper.getSelectedEntity(getSite(), Volume.class); - } - - createPage(parent); - } - - private void createPage(Composite parent) { - logsPage = new VolumeLogsPage(parent, SWT.NONE, volume); - logsPage.addDoubleClickListener(this); - - parent.layout(); // IMP: lays out the form properly - } - - @Override - public void setFocus() { - logsPage.setFocus(); - } - - @Override - public void doubleClick(DoubleClickEvent event) { - VolumeLogMessage volumeLogMessage = (VolumeLogMessage) ((StructuredSelection) event.getSelection()) - .getFirstElement(); - String message = DateUtil.formatDate(volumeLogMessage.getTimestamp()) + " " - + DateUtil.formatTime(volumeLogMessage.getTimestamp()) + " [" + volumeLogMessage.getSeverity() + "]" - + CoreConstants.NEWLINE + CoreConstants.NEWLINE + volumeLogMessage.getMessage(); - - new MessageDialog(getSite().getShell(), "Log message from " + volumeLogMessage.getBrick(), null, message, - MessageDialog.NONE, new String[] { "Close" }, 0).open(); - - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeOptionsView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeOptionsView.java deleted file mode 100644 index 7129df5d..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeOptionsView.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.VolumeOptionsPage; -import com.gluster.storage.management.core.model.Volume; - -public class VolumeOptionsView extends ViewPart { - public static final String ID = VolumeOptionsView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private VolumeOptionsPage page; - private Volume volume; - - @Override - public void createPartControl(Composite parent) { - if (volume == null) { - volume = guiHelper.getSelectedEntity(getSite(), Volume.class); - } - - createPage(parent); - } - - private void createPage(Composite parent) { - page = new VolumeOptionsPage(parent, SWT.NONE, volume); - parent.layout(); // IMP: lays out the form properly - } - - @Override - public void setFocus() { - page.setFocus(); - } -} - diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java deleted file mode 100644 index 78c7caf2..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeSummaryView.java +++ /dev/null @@ -1,859 +0,0 @@ -package com.gluster.storage.management.console.views; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.toolbar.GlusterToolbarManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.model.Alert; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Partition; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.utils.NumberUtil; -import com.gluster.storage.management.core.utils.StringUtil; -import com.gluster.storage.management.core.utils.ValidationUtil; - -public class VolumeSummaryView extends ViewPart { - public static final String ID = VolumeSummaryView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private Volume volume; - private Label volumeType; - private CLabel lblStatusValue; - private DefaultClusterListener volumeChangedListener; - private Hyperlink changeLink; - private Hyperlink cifsChangeLink; - private Text accessControlText; - private Text cifsUsersText; - private ControlDecoration errDecoration; - private ControlDecoration errCifsDecoration; - private Composite parent; - private static final String COURIER_FONT = "Courier"; - private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - private Cluster cluster = modelManager.getModel().getCluster(); - private Button nfsCheckBox; - private FormText glusterNfsMountText; - private String nfsMountInfo; - private Label nfsLabel; - private String nfs; - - private Label numberOfBricks; - private Label totalDiskSpace; - private Composite alertsSection; - private Button cifsCheckbox; - private Label cifsLabel; - private Composite cifsUpdateLinkComposite; - - @Override - public void createPartControl(Composite parent) { - if (volume == null) { - volume = guiHelper.getSelectedEntity(getSite(), Volume.class); - } - - this.parent = parent; - setPartName("Summary"); - createSections(); - - final GlusterToolbarManager toolbarManager = new GlusterToolbarManager(getSite().getWorkbenchWindow()); - // Refresh the navigation tree whenever there is a change to the data model - volumeChangedListener = new DefaultClusterListener() { - @Override - public void volumeChanged(Volume volume, Event event) { - updateVolumeStatusLabel(); - populateAccessControlText(); - changeNFSStatus(volume.isNfsEnabled()); - updateBrickChanges(volume); - toolbarManager.updateToolbar(volume); - cifsCheckbox.setSelection(volume.isCifsEnable()); - populateCifsUsersText(); - renderVolumeTypeField(); - } - - @Override - public void alertsGenerated() { - super.alertsGenerated(); - guiHelper.clearSection(alertsSection); - populateAlertSection(); - alertsSection.layout(); - } - }; - modelManager.addClusterListener(volumeChangedListener); - } - - @Override - public void dispose() { - super.dispose(); - modelManager.removeClusterListener(volumeChangedListener); - } - - private void createSections() { - form = guiHelper.setupForm(parent, toolkit, "Volume Properties [" + volume.getName() + "]"); - - createVolumePropertiesSection(); - createVolumeMountingInfoSection(); - createVolumeAlertsSection(); - - parent.layout(); // IMP: lays out the form properly - } - - private void createVolumeAlertsSection() { - alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false); - populateAlertSection(); - } - - private void populateAlertSection() { - List alerts = cluster.getAlerts(); - - for (int i = 0; i < alerts.size(); i++) { - if (alerts.get(i).getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT - && alerts.get(i).getReference().split(":")[0].trim().equals(volume.getName())) { - addAlertLabel(alertsSection, alerts.get(i)); - } - } - } - - private void addAlertLabel(Composite section, Alert alert) { - CLabel lblAlert = new CLabel(section, SWT.NONE); - lblAlert.setImage(guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22)); - lblAlert.setText(alert.getMessage()); - lblAlert.redraw(); - } - - private FormText setFormTextStyle(FormText formText, String fontName, int size, int style) { - Font font = new Font(Display.getCurrent(), new FontData(fontName, size, style)); - formText.setFont(font); - return formText; - } - - private void createVolumeMountingInfoSection() { - String glusterFs = "Gluster:"; - nfs = "NFS:"; - String onlineServers = getOnlineServers(10); // Limited to 10 servers - String firstOnlineServer = onlineServers.split(",")[0].trim(); - String glusterFsMountInfo = "mount -t glusterfs " + firstOnlineServer + ":/" + volume.getName() - + " "; - nfsMountInfo = "mount -t nfs " + firstOnlineServer + ":/" + volume.getName() + " "; - // TODO: if more than 10 servers... - String info = "Server can be any server name in the storage cloud eg. <" + onlineServers + ">"; - - Composite section = guiHelper.createSection(form, toolkit, "Mounting Information", null, 3, false); - - toolkit.createLabel(section, glusterFs, SWT.NORMAL); - FormText glusterfsMountText = setFormTextStyle(toolkit.createFormText(section, true), COURIER_FONT, 10, - SWT.NONE); - glusterfsMountText.setText(glusterFsMountInfo, false, false); - glusterfsMountText.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, - 2, 0)); // Label spanned two column - - nfsLabel = toolkit.createLabel(section, nfs, SWT.NONE); - GridData data = new GridData(); - data.horizontalAlignment = SWT.FILL; - nfsLabel.setLayoutData(data); - - glusterNfsMountText = setFormTextStyle(toolkit.createFormText(section, true), COURIER_FONT, 10, SWT.NONE); - glusterNfsMountText.setText(nfsMountInfo, false, false); - glusterNfsMountText.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, - false, 2, 0)); - - changeNFSStatus(nfsCheckBox.getSelection()); - - toolkit.createLabel(section, ""); - Label infoLabel = toolkit.createLabel(section, info, SWT.NONE); - infoLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, 2, 0)); - - // TODO: implement a logic to identify the corresponding glusterfs client download link - String message = "You can download GlusterFS client from"; - String glusterFSDownloadlinkText = "here."; - final String glusterFSDownloadlink = "http://download.gluster.com/pub/gluster/glusterfs/"; - - toolkit.createLabel(section, ""); - toolkit.createLabel(section, message); - Hyperlink link = toolkit.createHyperlink(section, glusterFSDownloadlinkText, SWT.NORMAL); - link.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - try { - System.out.println(e.getLabel() + " [" + e.getHref() + "]"); - PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() - .openURL(new URL(glusterFSDownloadlink)); - } catch (PartInitException e1) { - e1.printStackTrace(); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } - } - }); - } - - private String getOnlineServers(int maxServers) { - List OnlineServers = new ArrayList(); - for (GlusterServer server : cluster.getServers()) { - if (server.getStatus() == SERVER_STATUS.ONLINE) { - OnlineServers.add(server.getName()); - if (OnlineServers.size() >= maxServers) { - break; - } - } - } - return StringUtil.collectionToString(OnlineServers, ", ") + ((OnlineServers.size() > maxServers) ? "..." : ""); - } - - /** - * - */ - private void createVolumePropertiesSection() { - Composite section = guiHelper.createSection(form, toolkit, "Properties", null, 3, false); - - createVolumeTypeField(section); - - VOLUME_TYPE volumeType = volume.getVolumeType(); - if (volumeType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { - createReplicaCountField(section); - } - - if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - createStripeCountField(section); - } - - createNumOfBricksField(section); - createDiskSpaceField(section); - // createTransportTypeField(section); - createNASProtocolField(section); - createCifsField(section); - createAccessControlField(section); - createStatusField(section); - } - - private GridData createDefaultLayoutData() { - GridData layoutData = new GridData(); - layoutData.minimumWidth = 300; - layoutData.widthHint = 300; - return layoutData; - } - - private void createCifsField(Composite section) { - cifsLabel = toolkit.createLabel(section, "CIFS: ", SWT.NONE); - cifsUsersText = toolkit.createText(section, volume.getAccessControlList(), SWT.BORDER); - populateCifsUsersText(); - addKeyListenerForCifsUser(); - - cifsUpdateLinkComposite = toolkit.createComposite(section, SWT.NONE); - cifsUpdateLinkComposite.setLayout(new FillLayout()); - cifsUpdateLinkComposite.setVisible(volume.isCifsEnable()); - - createChangeLinkForCifs(cifsUpdateLinkComposite); - renderCifsUsers(cifsCheckbox.getSelection()); - errCifsDecoration = guiHelper.createErrorDecoration(cifsUsersText); - errCifsDecoration.hide(); - } - - private void createAccessControlField(Composite section) { - toolkit.createLabel(section, "Allow Access From: ", SWT.NONE); - accessControlText = toolkit.createText(section, volume.getAccessControlList(), SWT.BORDER); - - populateAccessControlText(); - addKeyListenerForAccessControl(); - accessControlText.setLayoutData(createDefaultLayoutData()); - accessControlText.setEnabled(false); - createChangeLinkForAccessControl(section); - - // error decoration used while validating the access control text - errDecoration = guiHelper.createErrorDecoration(accessControlText); - errDecoration.hide(); - createAccessControlInfoLabel(section); // info text - } - - private void createAccessControlInfoLabel(Composite section) { - toolkit.createLabel(section, "", SWT.NONE); - Label accessControlInfoLabel = toolkit.createLabel(section, "(Comma separated list of IP addresses/hostnames)"); - GridData data = new GridData(SWT.LEFT, SWT.CENTER, true, false); - data.horizontalSpan = 2; - accessControlInfoLabel.setLayoutData(data); - } - - private void createChangeLinkForAccessControl(Composite section) { - changeLink = toolkit.createHyperlink(section, "change", SWT.NONE); - changeLink.addHyperlinkListener(new HyperlinkAdapter() { - - private void finishEdit() { - saveAccessControlList(); - } - - private void startEdit() { - accessControlText.setEnabled(true); - accessControlText.setFocus(); - accessControlText.selectAll(); - changeLink.setText("update"); - } - - @Override - public void linkActivated(HyperlinkEvent e) { - if (accessControlText.isEnabled()) { - // we were already in edit mode. - finishEdit(); - } else { - // Get in to edit mode - startEdit(); - } - } - }); - } - - private void saveAccessControlList() { - final String newACL = accessControlText.getText(); - - guiHelper.setStatusMessage("Setting access control list to [" + newACL + "]..."); - parent.update(); - - if (newACL.equals(volume.getAccessControlList())) { - accessControlText.setEnabled(false); - changeLink.setText("change"); - } else if (ValidationUtil.isValidAccessControl(newACL)) { - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { - @Override - public void run() { - try { - new VolumesClient().setVolumeOption(volume.getName(), Volume.OPTION_AUTH_ALLOW, newACL); - accessControlText.setEnabled(false); - changeLink.setText("change"); - - modelManager.setAccessControlList(volume, newACL); - } catch (Exception e) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control", e.getMessage()); - } - } - }); - } else { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control", "Invalid IP / Host name "); - } - guiHelper.clearStatusMessage(); - parent.update(); - } - - private void createChangeLinkForCifs(Composite section) { - cifsChangeLink = toolkit.createHyperlink(section, "change", SWT.NONE); - cifsChangeLink.addHyperlinkListener(new HyperlinkAdapter() { - - private void finishEdit() { - saveCifsConfiguration(); - } - - private void startEdit() { - if (cifsCheckbox.getSelection()) { - enableCifsUsersControls(true); - cifsUsersText.selectAll(); - } - } - - @Override - public void linkActivated(HyperlinkEvent e) { - if (cifsUsersText.isEnabled()) { - // we were already in edit mode. - finishEdit(); - } else { - // Get in to edit mode - startEdit(); - } - } - }); - } - - private void saveCifsConfiguration() { - guiHelper.setStatusMessage("Setting Cifs Configuration..."); - parent.update(); - - // To check if no changes in the users list - if (!isvalidCifsUser()) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", - "Please enter cifs users name"); - enableCifsUsersControls(true); - validateCifsUsers(); - // } else if (cifsUsers.equals(configuredUsers)) { // Nothing to do. - // enableCifsUsersControls(false); - } else { - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { - @Override - public void run() { - VolumesClient vc = new VolumesClient(); - Volume newVolume = new Volume(); - Integer userAction = 1; - String cifsUsers = cifsUsersText.getText().trim(); - List servers = GlusterDataModelManager.getInstance().getOfflineServers(); - // One or more servers are offline, Show warning if cifs is enabled - if (servers != null && servers.size() > 0) { - userAction = new MessageDialog(parent.getShell(), "CIFS configuration", GUIHelper - .getInstance().getImage(IImageKeys.VOLUME_16x16), - "Performing CIFS updates when one or more servers are offline can trigger " - + "inconsistent behavior for CIFS accesses in the cluster." - + CoreConstants.NEWLINE + CoreConstants.NEWLINE - + "Are you sure you want to continue?", MessageDialog.QUESTION, new String[] { - "No", "Yes" }, -1).open(); - } - - // If no cifs users and removing cifs config, nothing to do - if (!(!cifsCheckbox.getSelection() && volume.getCifsUsers().toString().equals("[]") && (cifsUsers - .isEmpty() || cifsUsers.equals(""))) && userAction == 1) { - try { - vc.setCifsConfig(volume.getName(), cifsCheckbox.getSelection(), cifsUsers); - enableCifsUsersControls(false); - newVolume = vc.getVolume(volume.getName()); - modelManager.volumeChanged(volume, newVolume); - showCifsUsersControls(volume.isCifsEnable()); - } catch (Exception e) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", - e.getMessage()); - cifsCheckbox.setSelection(volume.isCifsEnable()); - enableCifsUsersControls(cifsCheckbox.getSelection()); - populateCifsUsersText(); - } - } else { - newVolume = vc.getVolume(volume.getName()); - modelManager.volumeChanged(volume, newVolume); - showCifsUsersControls(volume.isCifsEnable()); - } - } - }); - } - guiHelper.clearStatusMessage(); - parent.update(); - } - - private void saveNFSOption() { - guiHelper.setStatusMessage("Setting NFS option..."); - parent.update(); - - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { - @Override - public void run() { - try { - boolean enableNfs = nfsCheckBox.getSelection(); - new VolumesClient().setVolumeOption(volume.getName(), Volume.OPTION_NFS_DISABLE, - (enableNfs) ? GlusterConstants.OFF : GlusterConstants.ON); - modelManager.setNfsEnabled(volume, enableNfs); - } catch (Exception e) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "NFS Option", e.getMessage()); - } - } - }); - guiHelper.clearStatusMessage(); - parent.update(); - } - - private void addKeyListenerForAccessControl() { - accessControlText.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent key) { - switch (key.keyCode) { - case SWT.ESC: - // Reset to default - populateAccessControlText(); - changeLink.setText("change"); - accessControlText.setEnabled(false); - break; - case 13: - // User has pressed enter. Save the new value - saveAccessControlList(); - break; - } - - validateAccessControlList(); - } - }); - } - - private void populateAccessControlText() { - String accessControlList = volume.getAccessControlList(); - if (accessControlList == null) { - // if not set, show default value - accessControlList = modelManager.getVolumeOptionDefaultValue(Volume.OPTION_AUTH_ALLOW); - } - accessControlText.setText(accessControlList); - } - - private void addKeyListenerForCifsUser() { - cifsUsersText.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent key) { - switch (key.keyCode) { - case SWT.ESC: - // Reset to default - populateCifsUsersText(); - enableCifsUsersControls(false); - if (cifsUsersText.getText().trim().length() == 0) { // Disable CIFS as well - cifsCheckbox.setSelection(false); - } - form.reflow(true); - break; - case 13: - // User has pressed enter. Save the new value - saveCifsConfiguration(); - break; - } - validateCifsUsers(); - } - }); - } - - private void populateCifsUsersText() { - List userList = volume.getCifsUsers(); - if (volume.isCifsEnable() && userList != null) { - cifsUsersText.setText(StringUtil.collectionToString(userList, ",")); - } else { - cifsUsersText.setText(""); - } - } - - private void createNASProtocolField(final Composite section) { - toolkit.createLabel(section, "Access Protocols: ", SWT.NONE); - - Composite nasProtocolsComposite = toolkit.createComposite(section); - nasProtocolsComposite.setLayout(new FillLayout()); - - createCheckbox(nasProtocolsComposite, "Gluster", true, false); - - nfsCheckBox = createCheckbox(nasProtocolsComposite, "NFS", volume.isNfsEnabled(), true); - - nfsCheckBox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (!nfsCheckBox.getSelection()) { - Integer userAction = new MessageDialog(parent.getShell(), "NFS Re-export", GUIHelper.getInstance() - .getImage(IImageKeys.VOLUME_16x16), - "Are you sure you want to stop the NFS Re-export for volume [" + volume.getName() + "]?", - MessageDialog.QUESTION, new String[] { "No", "Yes" }, -1).open(); - if (userAction <= 0) { // user select cancel or pressed escape key - nfsCheckBox.setSelection(true); - return; - } - } - saveNFSOption(); - } - }); - - // CIFS checkbox - cifsCheckbox = createCheckbox(nasProtocolsComposite, "CIFS", volume.isCifsEnable(), true); - createCifsCheckboxListner(cifsCheckbox); - - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void createCifsCheckboxListner(final Button cifsCheckbox) { - cifsCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (cifsCheckbox.getSelection()) { - // need to enable cifs - // TODO: Open the text box (empty and enabled), - // the hyperlink next to the textbox should have label "update" - // when user clicks on that hyperlink, - // saveCifsConfiguration should be called - // Also, if user presses the "ESC" key, - // return to the previous state of checkbox and hide the textbox + hyperlink - showCifsUsersControls(true); - enableCifsUsersControls(true); - // saveCifsConfiguration(); - } else { - // need to disable cifs - // TODO: hide the textbox and the link AFTER disabling cifs - if ((volume.getCifsUsers() == null || volume.getCifsUsers().toString().equals("[]")) - && cifsUsersText.getText().trim().equals("")) { - showCifsUsersControls(false); - enableCifsUsersControls(false); - } else { - - Integer userAction = new MessageDialog(parent.getShell(), "CIFS Re-export", GUIHelper - .getInstance().getImage(IImageKeys.VOLUME_16x16), - "Are you sure you want to stop the CIFS re-export for volume [" + volume.getName() - + "]?", MessageDialog.QUESTION, new String[] { "No", "Yes" }, -1).open(); - if (userAction <= 0) { // user select cancel or pressed escape key - cifsCheckbox.setSelection(true); // back to previous state. - } else { - showCifsUsersControls(false); - enableCifsUsersControls(false); - saveCifsConfiguration(); - } - } - } - populateCifsUsersText(); - form.reflow(true); - } - }); - } - - private void renderCifsUsers(Boolean cifsSelection) { - if (cifsSelection) { - enableCifsUsersControls(false); - showCifsUsersControls(true); - } else { - showCifsUsersControls(false); - } - } - - private void showCifsUsersControls(Boolean visible) { - if (visible) { - GridData data = new GridData(); - data.heightHint = 20; - data.widthHint = 100; - cifsLabel.setLayoutData(data); - - GridData data1 = new GridData(); - data1.heightHint = 20; - data1.widthHint = 300; - - cifsUsersText.setLayoutData(data1); - - GridData data2 = new GridData(); - data2.heightHint = 25; - data2.widthHint = 75; - cifsUpdateLinkComposite.setLayoutData(data2); - } else { - GridData data = new GridData(); - data.heightHint = 0; - - cifsLabel.setLayoutData(data); - cifsUsersText.setLayoutData(data); - cifsUpdateLinkComposite.setLayoutData(data); - } - - cifsLabel.setVisible(visible); - cifsUsersText.setVisible(visible); - cifsUpdateLinkComposite.setVisible(visible); - form.reflow(true); - } - - private void enableCifsUsersControls(Boolean enable) { - cifsUsersText.setEnabled(enable); - cifsChangeLink.setText((enable) ? "update" : "change"); - if (enable) { - cifsUsersText.setFocus(); - validateCifsUsers(); - } else { - if (errCifsDecoration != null) { - errCifsDecoration.hide(); - } - } - } - - private Button createCheckbox(Composite parent, String label, boolean checked, boolean enabled) { - final Button checkBox = toolkit.createButton(parent, label, SWT.CHECK); - checkBox.setSelection(checked); - checkBox.setEnabled(enabled); - return checkBox; - } - - private void changeNFSStatus(Boolean isNFSExported) { - glusterNfsMountText.setVisible(isNFSExported); - nfsLabel.setVisible(isNFSExported); - nfsCheckBox.setSelection(isNFSExported); - } - - private void updateBrickChanges(Volume volume) { - numberOfBricks.setText("" + volume.getNumOfBricks()); - totalDiskSpace.setText("" + NumberUtil.formatNumber(getTotalDiskSpace() / 1024)); - } - - private double getDiskSize(String serverName, String deviceName) { - double diskSize = 0; - GlusterServer server = cluster.getServer(serverName); - if (server.getStatus() == SERVER_STATUS.ONLINE) { - for (Disk disk : server.getDisks()) { - if (disk.getName().equals(deviceName)) { - diskSize = disk.getSpace(); - break; - } - - if (disk.hasPartitions()) { - for (Partition partition : disk.getPartitions()) { - if (partition.getName().equals(deviceName)) { - diskSize = partition.getSpace(); - break; - } - } - } - } - } - return diskSize; - } - - private double getTotalDiskSpace() { - List diskSizes = getVolumeDiskSizes(); - VOLUME_TYPE volumeType = volume.getVolumeType(); - double diskSize = 0d; - if (volumeType == VOLUME_TYPE.DISTRIBUTE || volumeType == VOLUME_TYPE.STRIPE - || volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - for (Double size : diskSizes) { - diskSize += size; - } - } else { // Replicate or distributed replicate - int replicaCount = volume.getReplicaCount(); - if (replicaCount == 0) { - replicaCount = Volume.DEFAULT_REPLICA_COUNT; - } - int startIndex = 0; - for (int i = 0; i < (diskSizes.size() / replicaCount); i++) { - startIndex = i * replicaCount; - diskSize += Collections.min(diskSizes.subList(startIndex, startIndex + replicaCount)); - } - } - return diskSize; - } - - private List getVolumeDiskSizes() { - List diskSizes = new ArrayList(); - Device device; - for (Brick brick : volume.getBricks()) { - device = modelManager.getDeviceForBrickDir(brick); - diskSizes.add( (device == null) ? 0d : getDiskSize(brick.getServerName(), device.getName()) ); - } - return diskSizes; - } - - - - private void createDiskSpaceField(Composite section) { - Label diskSpaceLabel = toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); - diskSpaceLabel.setToolTipText("boldnormal"); - totalDiskSpace = toolkit.createLabel(section, - "" + NumberUtil.formatNumber(getTotalDiskSpace() / 1024), SWT.NONE); - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void createStatusField(Composite section) { - toolkit.createLabel(section, "Status: ", SWT.NONE); - - lblStatusValue = new CLabel(section, SWT.NONE); - updateVolumeStatusLabel(); - - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void updateVolumeStatusLabel() { - lblStatusValue.setText(volume.getStatusStr()); - lblStatusValue.setImage((volume.getStatus() == Volume.VOLUME_STATUS.ONLINE) ? guiHelper - .getImage(IImageKeys.STATUS_ONLINE_16x16) : guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16)); - GridData data = new GridData(); - data.horizontalAlignment = SWT.FILL; - lblStatusValue.setLayoutData(data); - lblStatusValue.redraw(); - } - - private void createTransportTypeField(Composite section) { - toolkit.createLabel(section, "Transport Type: ", SWT.NONE); - toolkit.createLabel(section, "" + volume.getTransportTypeStr(), SWT.NONE); - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void createNumOfBricksField(Composite section) { - toolkit.createLabel(section, "Number of Bricks: ", SWT.NONE); - numberOfBricks = toolkit.createLabel(section, "" + volume.getNumOfBricks(), SWT.NONE); - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void createStripeCountField(Composite section) { - toolkit.createLabel(section, "Stripe Count: ", SWT.NONE); - toolkit.createLabel(section, "" + volume.getStripeCount(), SWT.NONE); - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void createReplicaCountField(Composite section) { - toolkit.createLabel(section, "Replica Count: ", SWT.NONE); - toolkit.createLabel(section, "" + volume.getReplicaCount(), SWT.NONE); - toolkit.createLabel(section, "", SWT.NONE); // dummy - } - - private void createVolumeTypeField(Composite section) { - toolkit.createLabel(section, "Volume Type: ", SWT.NONE); - volumeType = toolkit.createLabel(section, volume.getVolumeTypeStr(), SWT.NONE); - toolkit.createLabel(section, "", SWT.NONE); - } - - private void renderVolumeTypeField() { - volumeType.setText(volume.getVolumeTypeStr()); - } - - @Override - public void setFocus() { - form.setFocus(); - } - - private void validateAccessControlList() { - errDecoration.hide(); - - if (accessControlText.getText().length() == 0) { - errDecoration.setDescriptionText("Access control list cannot be empty!"); - errDecoration.show(); - return; - } - - if (!ValidationUtil.isValidAccessControl(accessControlText.getText())) { - errDecoration.setDescriptionText("Invalid IP address/Host name [" - + ValidationUtil.getInvalidIpOrHostname(accessControlText.getText()) - + "]. Please enter a valid value!"); - errDecoration.show(); - } - } - - private void validateCifsUsers() { - errCifsDecoration.hide(); - if (cifsCheckbox.getSelection()) { - String cifsUserList = cifsUsersText.getText().trim(); - if (cifsUserList.length() == 0) { - errCifsDecoration.setDescriptionText("Please enter cifs user name"); - errCifsDecoration.show(); - } - } - } - - private boolean isvalidCifsUser() { - if (cifsCheckbox.getSelection()) { - String cifsUserList = cifsUsersText.getText().trim(); - return (cifsUserList.length() != 0); - } - validateCifsUsers(); - return true; - } - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeView.java deleted file mode 100644 index ced9335b..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumeView.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * DiscoveredServerView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.utils.NumberUtil; - -/** - * @author root - * - */ -public class VolumeView extends ViewPart { - public static final String ID = VolumeView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private Server server; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - if (server == null) { - server = guiHelper.getSelectedEntity(getSite(), Server.class); - } - createSections(parent, server, toolkit); - } - - private void createServerSummarySection(Server server, FormToolkit toolkit, final ScrolledForm form) { - Composite section = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); - - toolkit.createLabel(section, "Number of CPUs: ", SWT.NONE); - toolkit.createLabel(section, "" + server.getNumOfCPUs(), SWT.NONE); - - toolkit.createLabel(section, "Total Memory (GB): ", SWT.NONE); - toolkit.createLabel(section, "" + server.getTotalMemory(), SWT.NONE); - - toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); - toolkit.createLabel(section, "" + NumberUtil.formatNumber(server.getTotalDiskSpace()), SWT.NONE); - } - - private void createSections(Composite parent, Server server, FormToolkit toolkit) { - String serverName = server.getName(); - form = guiHelper.setupForm(parent, toolkit, "Discovered Server Summary [" + serverName + "]"); - createServerSummarySection(server, toolkit, form); - - parent.layout(); // IMP: lays out the form properly - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - if (form != null) { - form.setFocus(); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesSummaryView.java deleted file mode 100644 index cd937215..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesSummaryView.java +++ /dev/null @@ -1,301 +0,0 @@ -/** - * VolumesSummaryView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IImageKeys; -import com.gluster.storage.management.console.utils.ChartViewerComposite; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.Alert; -import com.gluster.storage.management.core.model.Cluster; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; - -/** - * - */ -public class VolumesSummaryView extends ViewPart { - public static final String ID = VolumesSummaryView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private ScrolledForm form; - private EntityGroup volumes; - private Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster(); - private ClusterListener clusterListener; - - private static final String ALERTS = "Alerts"; - private static final String VOLUMES_SUMMARY = "Volumes - Summary"; - private static final String AVAILABILITY = "Availability"; - private Composite alertsSection; - private Composite tasksSection; - private Composite summarySection; - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets - * .Composite) - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void createPartControl(Composite parent) { - if (volumes == null) { - Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Volume.class) { - volumes = (EntityGroup) selectedObj; - } - } - - setPartName("Summary"); - createSections(parent); - - clusterListener = new DefaultClusterListener() { - @Override - public void volumeCreated(Volume volume) { - super.volumeCreated(volume); - updateSummarySection(); - } - - @Override - public void volumeDeleted(Volume volume) { - super.volumeDeleted(volume); - updateSummarySection(); - } - - @Override - public void volumeChanged(Volume volume, Event event) { - super.volumeChanged(volume, event); - updateSummarySection(); - } - - private void updateAlertSection() { - guiHelper.clearSection(alertsSection); - populateAlertSection(); - } - - private void updateSummarySection() { - guiHelper.clearSection(summarySection); - populateSummarySection(); - summarySection.layout(); - form.reflow(true); - } - - @Override - public void alertsGenerated() { - super.alertsGenerated(); - guiHelper.clearSection(alertsSection); - populateAlertSection(); - } - - @Override - public void alertRemoved(Alert alert) { - super.alertRemoved(alert); - updateAlertSection(); - } - - @Override - public void alertCreated(Alert alert) { - super.alertCreated(alert); - updateAlertSection(); - } - - @Override - public void taskAdded(TaskInfo taskInfo) { - super.taskAdded(taskInfo); - updateTasksSection(); - } - - @Override - public void taskRemoved(TaskInfo taskInfo) { - super.taskRemoved(taskInfo); - updateTasksSection(); - } - - @Override - public void taskUpdated(TaskInfo taskInfo) { - super.taskUpdated(taskInfo); - updateTasksSection(); - } - - private void updateTasksSection() { - guiHelper.clearSection(tasksSection); - populateTasks(); - } - }; - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - } - - @Override - public void dispose() { - super.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } - - private void createSections(Composite parent) { - form = guiHelper.setupForm(parent, toolkit, VOLUMES_SUMMARY); - createSummarySection(); - createTasksSection(); - createAlertsSection(); - - parent.layout(); // IMP: lays out the form properly - } - - private void createAlertsSection() { - alertsSection = guiHelper.createSection(form, toolkit, ALERTS, null, 1, false); - populateAlertSection(); - } - - private void populateAlertSection() { - for (Alert alert : cluster.getAlerts()) { - if (alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT - || alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_ALERT) { - addAlertLabel(alertsSection, alert); - } - } - alertsSection.pack(true); - form.reflow(true); - } - - private void addAlertLabel(Composite section, Alert alert) { - CLabel lblAlert = new CLabel(section, SWT.NONE); - - Image alertImage = null; - switch (alert.getType()) { - case OFFLINE_VOLUME_BRICKS_ALERT: - alertImage = guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22); - break; - case OFFLINE_VOLUME_ALERT: - alertImage = guiHelper.getImage(IImageKeys.VOLUME_OFFLINE_22x22); - break; - } - lblAlert.setImage(alertImage); - lblAlert.setText(alert.getMessage()); - lblAlert.redraw(); - } - - private void createTasksSection() { - tasksSection = guiHelper.createSection(form, toolkit, CoreConstants.RUNNING_TASKS, null, 1, false); - populateTasks(); - } - - private void populateTasks() { - for (TaskInfo taskInfo : cluster.getTaskInfoList()) { - if ((taskInfo.getType() == TASK_TYPE.BRICK_MIGRATE || taskInfo.getType() == TASK_TYPE.VOLUME_REBALANCE) - && taskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS) - addTaskLabel(tasksSection, taskInfo); - } - tasksSection.pack(true); - form.reflow(true); - } - - private void addTaskLabel(Composite section, TaskInfo taskInfo) { - // Task related to Volumes context - if (taskInfo.getStatus().isPercentageSupported()) { - // TODO Progress bar or link to progress view - } - - CLabel lblTask = new CLabel(section, SWT.NONE); - String description = taskInfo.getDescription(); - switch (taskInfo.getStatus().getCode()) { - case Status.STATUS_CODE_PAUSE: - description += " (paused)"; - break; - case Status.STATUS_CODE_COMMIT_PENDING: - description += " (commit pending)"; - break; - case Status.STATUS_CODE_FAILURE: - description += " (failed)"; - break; - } - lblTask.setText(description); - lblTask.setImage((taskInfo.getType() == TASK_TYPE.BRICK_MIGRATE) ? guiHelper - .getImage(IImageKeys.BRICK_MIGRATE_32x32) : guiHelper.getImage(IImageKeys.VOLUME_REBALANCE_32x32)); - lblTask.redraw(); - } - - private void createSummarySection() { - summarySection = guiHelper.createSection(form, toolkit, AVAILABILITY, null, 2, false); - populateSummarySection(); - } - - private void populateSummarySection() { - if(volumes.getEntities().size() == 0) { - toolkit.createLabel(summarySection, - "This section will be populated after at least" + CoreConstants.NEWLINE +"one volume is created the storage cloud."); - return; - } - - Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.ONLINE)), - Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.OFFLINE)) }; - createStatusChart(toolkit, summarySection, values); - } - - private int getVolumeCountByStatus(EntityGroup volumes, VOLUME_STATUS status) { - int count = 0; - for (Volume volume : volumes.getEntities()) { - if (volume.getStatus() == status) { - count++; - } - } - return count; - } - - private void createStatusChart(FormToolkit toolkit, Composite section, Double[] values) { - String[] categories = new String[] { "Online", "Offline" }; - ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, categories, values); - - GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); - data.widthHint = 300; - data.heightHint = 150; - chartViewerComposite.setLayoutData(data); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - if (form != null) { - form.setFocus(); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesView.java deleted file mode 100644 index 4deeace2..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/VolumesView.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * DiscoveredServersView.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views; - -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.part.ViewPart; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.views.pages.VolumesPage; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Volume; - -/** - * - */ -public class VolumesView extends ViewPart implements IDoubleClickListener { - public static final String ID = VolumesView.class.getName(); - private static final GUIHelper guiHelper = GUIHelper.getInstance(); - private EntityGroup volumes; - private VolumesPage page; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void createPartControl(Composite parent) { - if (volumes == null) { - Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); - if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Volume.class) { - volumes = (EntityGroup)selectedObj; - } - } - - page = new VolumesPage(parent, getSite(), volumes); - page.addDoubleClickListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - page.setFocus(); - } - - @Override - public void doubleClick(DoubleClickEvent event) { - NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); - if (clusterView != null) { - clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); - } - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java deleted file mode 100644 index 43a7e61a..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractDisksPage.java +++ /dev/null @@ -1,335 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.TreeEditor; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.ImageHyperlink; - -import com.gluster.storage.management.client.GlusterServersClient; -import com.gluster.storage.management.client.TasksClient; -import com.gluster.storage.management.console.Application; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.IEntityListener; -import com.gluster.storage.management.console.dialogs.InitDiskDialog; -import com.gluster.storage.management.console.utils.GlusterLogger; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Device; -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Event.EVENT_TYPE; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; - -public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage implements IEntityListener { - protected List disks; - protected static final GlusterLogger logger = GlusterLogger.getInstance(); - - /** - * @return Index of the "status" column in the table. Return -1 if status column is not displayed - */ - protected abstract int getStatusColumnIndex(); - - public AbstractDisksPage(final Composite parent, int style, IWorkbenchSite site, List disks) { - super(site, parent, style, false, true, disks); - this.disks = disks; - - // creates hyperlinks for "uninitialized" disks - setupStatusCellEditor(); - // Listen for disk status change events - Application.getApplication().addEntityListener(this); - } - - protected ClusterListener createClusterListener() { - return new DefaultClusterListener() { - @Override - public void serverChanged(GlusterServer server, Event event) { - super.serverChanged(server, event); - EVENT_TYPE eventType = event.getEventType(); - switch (eventType) { - case DEVICES_REMOVED: - case DEVICES_ADDED: - case DEVICES_CHANGED: - case GLUSTER_SERVER_CHANGED: - treeViewer.refresh(true); - default: - break; - } - } - }; - } - - private void createInitializeLink(final TreeItem item, final int rowNum, final Device uninitializedDevice) { - final Tree tree = treeViewer.getTree(); - final TreeEditor editor = new TreeEditor(tree); - editor.grabHorizontal = true; - editor.horizontalAlignment = SWT.RIGHT; - - tree.addPaintListener(new PaintListener() { - private TreeItem myItem = item; - private int myRowNum = rowNum; - private ImageHyperlink myLink = null; - private TreeEditor myEditor = null; - - private void createLinkFor(Device uninitializedDevice, TreeItem item1, int rowNum1) { - myItem = item1; - myRowNum = rowNum1; - - myEditor = new TreeEditor(tree); - myEditor.grabHorizontal = true; - myEditor.horizontalAlignment = SWT.RIGHT; - - myLink = toolkit.createImageHyperlink(tree, SWT.NONE); - // link.setImage(guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED)); - myLink.setText("Initialize"); - myLink.addHyperlinkListener(new StatusLinkListener(myLink, myEditor, treeViewer, uninitializedDevice)); - - myEditor.setEditor(myLink, item1, getStatusColumnIndex()); - - myItem.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - myLink.dispose(); - myEditor.dispose(); - } - }); - } - - @Override - public void paintControl(PaintEvent e) { - int itemCount = tree.getItemCount(); - - // Find the table item corresponding to our disk - - Device device = null; - int rowNum1 = -1; - TreeItem item1 = null; - - mainloop: - for (int i = 0; i < itemCount; i++) { - item1 = tree.getItem(i); - - device = (Device) item1.getData(); - if (device != null && device == uninitializedDevice) { - // this is an uninitialized "disk" - rowNum1 = i; - break; - } - - int partitionCount = item1.getItemCount(); - for(int j = 0; j < partitionCount; j++) { - TreeItem partitionItem = item1.getItem(j); - // check each partition - Device partition = (Device)partitionItem.getData(); - if(partition != null && partition == uninitializedDevice) { - // this is an uninitialized "partition" - rowNum1 = i + j; - item1 = partitionItem; - device = partition; - // found the uninitialized device. break out. - break mainloop; - } - } - } - - if (rowNum1 == -1) { - // item disposed and disk not visible. nothing to do. - return; - } - - if (myEditor == null || myItem.isDisposed()) { - // item visible, and - // either editor never created, OR - // old item disposed. create the link for it - createLinkFor(device, item1, rowNum1); - } - - if (rowNum1 != myRowNum) { - // disk visible, but at a different row num. re-create the link - myLink.dispose(); - myEditor.dispose(); - createLinkFor(device, item1, rowNum1); - } - - myEditor.layout(); // IMPORTANT. Without this, the link location goes for a toss on maximize + restore - } - }); - } - - private void setupStatusCellEditor() { - final TreeViewer viewer = treeViewer; - final Tree tree = viewer.getTree(); - int rowNum = 0; - for (int i = 0; i < tree.getItemCount(); i++, rowNum++) { - final TreeItem item = tree.getItem(i); - if (item.isDisposed() || item.getData() == null) { - continue; - } - final Disk disk = (Disk) item.getData(); - if (disk.isUninitialized()) { - createInitializeLink(item, rowNum, disk); - } - - if (disk.hasPartitions()) { - for(int j = 0; j < disk.getPartitions().size(); j++, rowNum++) { - TreeItem partitionItem = item.getItem(j); - // check each partition - Device partition = (Device)partitionItem.getData(); - if (partition.isUninitialized()) { - createInitializeLink(partitionItem, rowNum, partition); - } - } - } - } - } - - private final class StatusLinkListener extends HyperlinkAdapter { - private final Device device; - private final TreeEditor myEditor; - private final ImageHyperlink myLink; - private final TreeViewer viewer; - - private StatusLinkListener(ImageHyperlink link, TreeEditor editor, TreeViewer viewer, Device device) { - this.device = device; - this.viewer = viewer; - this.myEditor = editor; - this.myLink = link; - } - - private void updateStatus(final DEVICE_STATUS status, final boolean disposeEditor) { - if (disposeEditor) { - myLink.dispose(); - myEditor.dispose(); - } - device.setStatus(status); - viewer.update(device, new String[] { "status" }); - Application.getApplication().entityChanged(device, new String[] { "status" }); - } - - @Override - public void linkActivated(HyperlinkEvent e) { - GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); - - // If the same task is already running return - String reference = device.getServerName() + ":" + device.getName(); - TaskInfo existingTaskInfo = modelManager.getTaskByReference(reference); - if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS - && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { - MessageDialog.openInformation(getShell(), "Initialize disk - Error", "Initializing disk [" + reference - + "] is already in progress! Try later."); - return; - } - - // To collect the available fsType - GlusterServersClient serversClient = new GlusterServersClient(); - List fsTypes = new ArrayList(); - try { - fsTypes = serversClient.getFSTypes(device.getServerName()); - } catch (GlusterRuntimeException e1) { - MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); - return; - } - - InitDiskDialog formatDialog = new InitDiskDialog(getShell(), device.getName(), fsTypes); - int userAction = formatDialog.open(); - if (userAction == Window.CANCEL) { - // formatDialog.cancelPressed(); - return; - } - - try { - - URI uri = serversClient.initializeDisk(device.getServerName(), device.getName(), formatDialog.getFSType(), formatDialog.getMountPoint()); - - TasksClient taskClient = new TasksClient(); - TaskInfo taskInfo = taskClient.getTaskInfo(uri); - - if (taskInfo != null) { - modelManager.addTask(taskInfo); - } - - if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_RUNNING) { - updateStatus(DEVICE_STATUS.INITIALIZING, true); - } else if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { - // If format completed (instantly), get the server details and update the server in the model - GlusterServer oldServer = modelManager.getModel().getCluster().getServer(device.getServerName()); - GlusterServer newServer = serversClient.getGlusterServer(device.getServerName()); - modelManager.glusterServerChanged(oldServer, newServer); - // updateStatus(DEVICE_STATUS.INITIALIZED, true); - // GlusterDataModelManager.getInstance().updateDeviceStatus(device.getServerName(), device.getName(), - // DEVICE_STATUS.INITIALIZED); - } else { - MessageDialog.openError(getShell(), "Initialize disk - Error", taskInfo.getStatus().getMessage()); - } - guiHelper.showTaskView(); - } catch (Exception e1) { - logger.error("Exception while initialize disk", e1); - MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); - } - } - } - - @Override - public void entityChanged(final Entity entity, final String[] paremeters) { - if (!(entity instanceof Device)) { - return; - } - final Device device = (Device) entity; - - Display.getDefault().syncExec(new Runnable() { - public void run() { - treeViewer.update(device, paremeters); - - if (device.isUninitialized()) { - Tree tree = treeViewer.getTree(); - - for (int rowNum = 0; rowNum < tree.getItemCount(); rowNum++) { - TreeItem item = tree.getItem(rowNum); - if (item.getData() == device) { - createInitializeLink(item, rowNum, device); - } - } - } - } - }); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java deleted file mode 100644 index 7414bbc3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.layout.TreeColumnLayout; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.forms.widgets.FormToolkit; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.Disk; - -public abstract class AbstractTableTreeViewerPage extends Composite implements ISelectionListener { - - protected final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - protected TreeViewer treeViewer; - protected GUIHelper guiHelper = GUIHelper.getInstance(); - protected Composite parent; - protected IWorkbenchSite site; - private ClusterListener clusterListener; - - private Text filterText; - - private void setupPageLayout() { - final GridLayout layout = new GridLayout(1, false); - layout.verticalSpacing = 10; - layout.marginTop = 10; - setLayout(layout); - } - - private Composite createTreeViewerComposite() { - Composite tableViewerComposite = new Composite(this, SWT.NO); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - GridData layoutData = new GridData(); - layoutData.horizontalSpan=5; - layoutData.grabExcessHorizontalSpace = true; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.verticalAlignment = SWT.FILL; - layoutData.grabExcessVerticalSpace = true; - tableViewerComposite.setLayoutData(layoutData); - - return tableViewerComposite; - } - - - public AbstractTableTreeViewerPage(IWorkbenchSite site, final Composite parent, int style, boolean useChechboxes, - boolean multiSelection, List allDisks) { - super(parent, style); - - setupPageLayout(); - //new FormToolkit(Display.getCurrent()).createButton(this, "test1", SWT.PUSH); - - this.parent = parent; - this.site = site; - - toolkit.adapt(this); - toolkit.paintBordersFor(this); - - GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); - parent.setLayoutData(data); - - filterText = guiHelper.createFilterText(toolkit, this); - - Composite tableViewerComposite = createTreeViewerComposite(); - createTreeViewer(allDisks, tableViewerComposite); - parent.layout(); // Important - this actually paints the table - - createListeners(parent); - } - - private void createListeners(final Composite parent) { - /** - * Ideally not required. However the table viewer is not getting laid out properly on performing - * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window - */ - addPaintListener(new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - parent.layout(); - } - }); - - clusterListener = createClusterListener(); - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - - addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - toolkit.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } - }); - } - - protected abstract ClusterListener createClusterListener(); - protected abstract IBaseLabelProvider getLabelProvider(); - protected abstract IContentProvider getContentProvider(); - - private void createTreeViewer(List allDisks, Composite tableViewerComposite) { - treeViewer = new TreeViewer(tableViewerComposite); - treeViewer.getTree().setHeaderVisible(true); - treeViewer.getTree().setLinesVisible(true); - - TreeColumnLayout ad = new TreeColumnLayout(); - tableViewerComposite.setLayout(ad); - - TreeColumn column = new TreeColumn(treeViewer.getTree(),SWT.NONE); - column.setWidth(100); - column.setText("Disk"); - ad.setColumnData(column, new ColumnWeightData(50, 100)); - - column = new TreeColumn(treeViewer.getTree(),SWT.NONE); - column.setWidth(100); - column.setText("Partition"); - ad.setColumnData(column,new ColumnWeightData(50, 100)); - - column = new TreeColumn(treeViewer.getTree(),SWT.NONE); - column.setWidth(100); - column.setText("Free Space (GB)"); - ad.setColumnData(column, new ColumnWeightData(50, 100)); - - column = new TreeColumn(treeViewer.getTree(),SWT.NONE); - column.setWidth(100); - column.setText("Total Space (GB)"); - ad.setColumnData(column,new ColumnWeightData(50, 100)); - - column = new TreeColumn(treeViewer.getTree(),SWT.NONE); - column.setWidth(100); - column.setText("Status"); - ad.setColumnData(column,new ColumnWeightData(50, 100)); - - treeViewer.setLabelProvider(getLabelProvider()); - treeViewer.setContentProvider(getContentProvider()); - treeViewer.setInput(allDisks); - - // Create a case insensitive filter for the table viewer using the filter text field - guiHelper.createFilter(treeViewer, filterText, false); - - treeViewer.expandAll(); - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java deleted file mode 100644 index c80740f3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java +++ /dev/null @@ -1,263 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Hyperlink; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.console.utils.TableViewerComparator; -import com.gluster.storage.management.core.model.ClusterListener; - -public abstract class AbstractTableViewerPage extends Composite implements ISelectionListener { - - private boolean useCheckboxes; - private boolean multiSelection; - - protected final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - protected TableViewer tableViewer; - protected GUIHelper guiHelper = GUIHelper.getInstance(); - protected Composite parent; - protected IWorkbenchSite site; - - private Hyperlink linkAll, linkNone; - private ClusterListener clusterListener; - - public AbstractTableViewerPage(IWorkbenchSite site, final Composite parent, int style, boolean useChechboxes, boolean multiSelection, Object model) { - super(parent, style); - this.parent = parent; - this.site = site; - - this.useCheckboxes = useChechboxes; - this.multiSelection = multiSelection; - - toolkit.adapt(this); - toolkit.paintBordersFor(this); - - setupPageLayout(); - - createCheckboxSelectionLinks(); - - Text filterText = guiHelper.createFilterText(toolkit, this); - - setupTableViewer(site, filterText); - tableViewer.setInput(model); - // register as selection provider so that other views can listen to any selection events on the tree - site.setSelectionProvider(tableViewer); - site.getPage().addSelectionListener(this); - - - parent.layout(); // Important - this actually paints the table - - createListeners(parent); - } - - public void createCheckboxSelectionLinks() { - if (useCheckboxes) { - // create the "select all/none" links - toolkit.createLabel(this, "Select"); - linkAll = toolkit.createHyperlink(this, "all", SWT.NONE); - linkAll.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { - ((CheckboxTableViewer) tableViewer).setAllChecked(true); - tableViewer.setSelection(new StructuredSelection(getAllEntities())); - } - }); - - toolkit.createLabel(this, " / "); - - linkNone = toolkit.createHyperlink(this, "none", SWT.NONE); - linkNone.addHyperlinkListener(new HyperlinkAdapter() { - @Override - public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { - ((CheckboxTableViewer) tableViewer).setAllChecked(false); - tableViewer.setSelection(StructuredSelection.EMPTY); - } - }); - } else { - // create dummy labels to maintain layout - toolkit.createLabel(this, ""); - toolkit.createLabel(this, ""); - toolkit.createLabel(this, ""); - toolkit.createLabel(this, ""); - } - } - - private void createListeners(final Composite parent) { - /** - * Ideally not required. However the table viewer is not getting laid out properly on performing - * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window - */ - addPaintListener(new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - parent.layout(); - } - }); - - clusterListener = createClusterListener(); - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - - addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - toolkit.dispose(); - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } - }); - } - - protected abstract ClusterListener createClusterListener(); - protected abstract String[] getColumnNames(); - protected abstract void setColumnProperties(Table table); - protected abstract IBaseLabelProvider getLabelProvider(); - protected abstract IContentProvider getContentProvider(); - protected abstract List getAllEntities(); - - public void addDoubleClickListener(IDoubleClickListener listener) { - tableViewer.addDoubleClickListener(listener); - } - - private void setupPageLayout() { - final GridLayout layout = new GridLayout(5, false); - layout.verticalSpacing = 10; - layout.marginTop = 10; - setLayout(layout); - } - - protected void setupTable(Composite parent, Table table) { - table.setHeaderVisible(true); - table.setLinesVisible(false); - - TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, getColumnNames()); - parent.setLayout(tableColumnLayout); - - setColumnProperties(table); - } - - private void createTableViewer(Composite parent) { - int style = SWT.FLAT | SWT.FULL_SELECTION; - style |= (multiSelection ? SWT.MULTI : SWT.SINGLE); - - if(useCheckboxes) { - tableViewer = CheckboxTableViewer.newCheckList(parent, style); - } else { - tableViewer = new TableViewer(parent, style); - } - - tableViewer.setLabelProvider(getLabelProvider()); - tableViewer.setContentProvider(getContentProvider()); - setupTable(parent, tableViewer.getTable()); - } - - private Composite createTableViewerComposite() { - Composite tableViewerComposite = new Composite(this, SWT.NO); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - GridData layoutData = new GridData(); - layoutData.horizontalSpan=5; - layoutData.grabExcessHorizontalSpace = true; - layoutData.horizontalAlignment = SWT.FILL; - layoutData.verticalAlignment = SWT.FILL; - layoutData.grabExcessVerticalSpace = true; - tableViewerComposite.setLayoutData(layoutData); - - return tableViewerComposite; - } - - private void setupTableViewer(IWorkbenchSite site, final Text filterText) { - Composite tableViewerComposite = createTableViewerComposite(); - createTableViewer(tableViewerComposite); - site.setSelectionProvider(tableViewer); - - if(useCheckboxes) { - // make sure that table selection is driven by checkbox selection - guiHelper.configureCheckboxTableViewer((CheckboxTableViewer)tableViewer); - } - - // Create a case insensitive filter for the table viewer using the filter text field - guiHelper.createFilter(tableViewer, filterText, false); - - tableViewer.setComparator(createViewerComparator()); - for (int columnIndex = 0; columnIndex < tableViewer.getTable().getColumnCount(); columnIndex++) { - TableColumn column = tableViewer.getTable().getColumn(columnIndex); - column.addSelectionListener(getColumnSelectionAdapter(column, columnIndex)); - } - } - - private SelectionAdapter getColumnSelectionAdapter(final TableColumn column, final int columnIndex) { - return new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - ViewerComparator viewerComparator = tableViewer.getComparator(); - if(viewerComparator instanceof TableViewerComparator) { - TableViewerComparator comparator = (TableViewerComparator)viewerComparator; - comparator.setColumn(columnIndex); - tableViewer.getTable().setSortDirection(comparator.getDirection()); - tableViewer.getTable().setSortColumn(column); - tableViewer.refresh(); - } - } - }; - } - - protected abstract ViewerComparator createViewerComparator(); - - /* (non-Javadoc) - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/BricksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/BricksPage.java deleted file mode 100644 index 674074c3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/BricksPage.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.BrickTableLabelProvider; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Volume; - -public class BricksPage extends AbstractTableViewerPage { - private List bricks; - - public enum BRICK_TABLE_COLUMN_INDICES { - SERVER, BRICK, FREE_SPACE, TOTAL_SPACE, STATUS - }; - - private static final String[] DISK_TABLE_COLUMN_NAMES = new String[] { "Server", "Brick Directory", "Free Space (GB)", - "Total Space (GB)", "Status" }; - - public BricksPage(Composite parent, int style, IWorkbenchSite site, final List bricks) { - super(site, parent, style, true, true, bricks); - this.bricks = bricks; - } - - @Override - protected ClusterListener createClusterListener() { - return new DefaultClusterListener() { - @SuppressWarnings("unchecked") - @Override - public void volumeChanged(Volume volume, Event event) { - switch (event.getEventType()) { - case BRICKS_ADDED: - tableViewer.add(((Collection) event.getEventData()).toArray()); - parent.update(); - break; - - case BRICKS_REMOVED: - tableViewer.remove(((Collection) event.getEventData()).toArray()); - parent.update(); - break; - - case BRICKS_CHANGED: - Object eventData = event.getEventData(); - Brick[] updatedBricks; - if(eventData instanceof Map) { - updatedBricks = ((Map) eventData).keySet().toArray(new Brick[0]); - } else { - updatedBricks = ((Collection)eventData).toArray(new Brick[0]); - } - tableViewer.update(updatedBricks, null); - parent.update(); - tableViewer.refresh(true); - default: - break; - } - } - }; - } - - @Override - protected String[] getColumnNames() { - return DISK_TABLE_COLUMN_NAMES; - } - - @Override - protected void setColumnProperties(Table table) { - guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.SERVER.ordinal(), SWT.CENTER, 100); - guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.BRICK.ordinal(), SWT.CENTER, 100); - guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal(), SWT.CENTER, 90); - guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal(), SWT.CENTER, 90); - } - - @Override - protected ITableLabelProvider getLabelProvider() { - return new BrickTableLabelProvider(); - } - - @Override - protected IContentProvider getContentProvider() { - return new ArrayContentProvider(); - } - - @Override - protected List getAllEntities() { - return bricks; - } - - @Override - protected ViewerComparator createViewerComparator() { - return null; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java deleted file mode 100644 index 79b54aa1..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Partition; - -public class DiskTreeContentProvider implements ITreeContentProvider { - - private List disks = new ArrayList(); - - public DiskTreeContentProvider(List disks) { - this.disks = disks; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) { - return ((List) inputElement).toArray(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object parentElement) { - if(parentElement instanceof Disk) { - return ((Disk)parentElement).getPartitions().toArray(); - } else { - return null; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object element) { - if (element == null) { - return null; - } - - if(element instanceof Partition) { - // find the disk of this partition and return - return getDiskForPartition((Partition)element); - } else { - return null; - } - } - - private Disk getDiskForPartition(Partition partition) { - for(Disk disk : disks) { - for(Partition diskPartition : disk.getPartitions()) { - if(partition.getName().equals(diskPartition.getName())) { - return disk; - } - } - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object element) { - return (element instanceof Disk && ((Disk)element).getPartitions().size() > 0); - } - - - -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DisksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DisksPage.java deleted file mode 100644 index 8501bef3..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/DisksPage.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.DeviceTableLabelProvider; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Entity; - -public class DisksPage extends AbstractDisksPage { - - public enum DISK_TABLE_COLUMN_INDICES { - DISK, PARTITION, FREE_SPACE, TOTAL_SPACE, STATUS - }; - - private static final String[] DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Partition", "Free Space (GB)", - "Total Space (GB)", "Status" }; - - public DisksPage(final Composite parent, int style, IWorkbenchSite site, List disks) { - super(parent, style, site, disks); - } - - private String getDiskTableColumnDesc(DISK_TABLE_COLUMN_INDICES idx) { - return DISK_TABLE_COLUMN_NAMES[idx.ordinal()]; - } - - @Override - protected DeviceTableLabelProvider getLabelProvider() { - return new DeviceTableLabelProvider(); - } - - - @Override - protected IContentProvider getContentProvider() { - return new DiskTreeContentProvider(disks); - } - - @Override - protected int getStatusColumnIndex() { - return DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(); - } - - @Override - public void entityChanged(Entity entity, String[] paremeters) { - // TODO Auto-generated method stub - - } - -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/GlusterServersPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/GlusterServersPage.java deleted file mode 100644 index 3ef05a2a..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/GlusterServersPage.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.EntityGroupContentProvider; -import com.gluster.storage.management.console.GlusterServerTableLabelProvider; -import com.gluster.storage.management.console.utils.TableViewerComparator; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.GlusterServer; - -public class GlusterServersPage extends AbstractTableViewerPage { - private List glusterServers; - - public enum GLUSTER_SERVER_TABLE_COLUMN_INDICES { - NAME, IP_ADDRESSES, NUM_OF_CPUS, TOTAL_MEMORY, TOTAL_FREE_SPACE, TOTAL_DISK_SPACE, STATUS // Removed PREFERRED_NETWORK - }; - - private static final String[] GLUSTER_SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", "IP Address(es)", - "Number" + CoreConstants.NEWLINE + "of CPUs", "Total" + CoreConstants.NEWLINE + "Memory (GB)", - "Free Space (GB)", "Total " + CoreConstants.NEWLINE + " Space (GB)", "Status" }; // Removed "Preferred\nNetwork", - - public GlusterServersPage(IWorkbenchSite site, final Composite parent, int style, final EntityGroup servers) { - super(site, parent, style, true, true, servers); - this.glusterServers = servers.getEntities(); - } - - @Override - protected ViewerComparator createViewerComparator() { - return new TableViewerComparator(); - } - - @Override - protected ClusterListener createClusterListener() { - return new DefaultClusterListener() { - - @Override - public void serverAdded(GlusterServer server) { - tableViewer.add(server); - parent.update(); - } - - @Override - public void serverRemoved(GlusterServer server) { - tableViewer.remove(server); - parent.update(); - } - - @Override - public void serverChanged(GlusterServer server, Event event) { - tableViewer.update(server, null); - parent.update(); - } - }; - } - - @Override - protected void setColumnProperties(Table table) { - setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME, SWT.CENTER, 100); - setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS, SWT.CENTER, 70); - // setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.PREFERRED_NETWORK, SWT.CENTER, 90); - setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS, SWT.CENTER, 90); - //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE, SWT.CENTER, 90); - setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY, SWT.CENTER, 90); - //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE, SWT.CENTER, 90); - setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_FREE_SPACE, SWT.CENTER, 90); - setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE, SWT.CENTER, 90); - //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE, SWT.CENTER, 90); - } - - @Override - protected IBaseLabelProvider getLabelProvider() { - return new GlusterServerTableLabelProvider(); - } - - @Override - protected IContentProvider getContentProvider() { - return new EntityGroupContentProvider(); - } - - @Override - protected String[] getColumnNames() { - return GLUSTER_SERVER_TABLE_COLUMN_NAMES; - } - - @Override - protected List getAllEntities() { - return glusterServers; - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - public void setColumnProperties(Table table, GLUSTER_SERVER_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java deleted file mode 100644 index ed6aea64..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * - */ -package com.gluster.storage.management.console.views.pages; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.ComboBoxCellEditor; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeOption; -import com.gluster.storage.management.core.model.VolumeOptionInfo; -import com.gluster.storage.management.core.model.VolumeOptions; - -/** - * Editing support for the "value" column in volume options table viewer. - */ -public class OptionKeyEditingSupport extends EditingSupport { - private CellEditor cellEditor; - private Volume volume; - private List defaults = GlusterDataModelManager.getInstance().getVolumeOptionsInfo(); - private String[] allowedKeys; - private ColumnViewer viewer; - - public OptionKeyEditingSupport(ColumnViewer viewer, Volume volume) { - super(viewer); - this.volume = volume; - this.viewer = viewer; - } - - /** - * @return array of option keys that are not already set on the volume - */ - private String[] getAllowedKeys() { - ArrayList keys = new ArrayList(); - VolumeOptions volumeOptions = volume.getOptions(); - for(VolumeOptionInfo optionInfo : defaults) { - String optionName = optionInfo.getName(); - if(!volumeOptions.containsKey(optionName) || volumeOptions.get(optionName).isEmpty()) { - // key not set => available for setting - // value not set => this is the row being edited - keys.add(optionName); - } - } - return keys.toArray(new String[0]); - } - - @Override - protected void setValue(final Object element, final Object value) { - VolumeOption oldEntry = (VolumeOption)element; - Integer newValue = (Integer)value; - String newKey = allowedKeys[newValue]; - - if (((VolumeOption)element).getKey().equals(newKey)) { - // selected value is same as old one. - return; - } - - // value has changed. set new value and refresh the viewer. - volume.getOptions().remove(oldEntry.getKey()); - volume.setOption(newKey, ""); - getViewer().refresh(); - } - - @Override - protected Object getValue(Object element) { - VolumeOption entryBeingAdded = getEntryBeingAdded(); - if(entryBeingAdded == null) { - return cellEditor.getValue(); - } - - if(entryBeingAdded.getKey().isEmpty()) { - // editing just about to start. set first element as default. - return 0; - } - - return getIndexOfEntry(entryBeingAdded); - } - - @Override - protected CellEditor getCellEditor(Object element) { - allowedKeys = getAllowedKeys(); - cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys, SWT.READ_ONLY); - return cellEditor; - } - - private int getIndexOfEntry(VolumeOption entryBeingAdded) { - for(int index = 0; index < allowedKeys.length; index++) { - if(allowedKeys[index].equals(entryBeingAdded.getKey())) { - return index; - } - } - return -1; - } - - protected VolumeOption getEntryBeingAdded() { - List options = volume.getOptions().getOptions(); - int size = options.size(); - String lastValue = options.get(size - 1).getValue(); - if(lastValue == null || lastValue.isEmpty()) { - // it's the LAST entry, and it's value is empty. - // means this is a new row being added in the table viewer. - return options.get(size - 1); - } - return null; - } - - @Override - protected boolean canEdit(Object element) { - VolumeOption entry = (VolumeOption)element; - return (entry.getKey().isEmpty() || entry.getValue().isEmpty()); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java deleted file mode 100644 index faf4fbe6..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * - */ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnViewer; -import org.eclipse.jface.viewers.EditingSupport; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeOption; -import com.gluster.storage.management.core.model.VolumeOptionInfo; - -/** - * Editing support for the "value" column in volume options table viewer. - */ -public class OptionValueEditingSupport extends EditingSupport { - private CellEditor cellEditor; - private Volume volume; - private List defaults = GlusterDataModelManager.getInstance().getVolumeOptionsInfo(); - private GUIHelper guiHelper = GUIHelper.getInstance(); - - public OptionValueEditingSupport(ColumnViewer viewer, Volume volume) { - super(viewer); - this.volume = volume; - this.cellEditor = new TextCellEditor((Composite) viewer.getControl()); - } - - @Override - protected void setValue(final Object element, final Object value) { - final VolumeOption entry = (VolumeOption)element; - final String optionKey = entry.getKey(); - final String optionValue = (String)value; - final String oldValue = entry.getValue(); - - // It is not allowed to change value to empty string - if(optionValue.isEmpty()) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option", - "Option value can't be empty! Please enter a valid value."); - cellEditor.setFocus(); - return; - } - - if (oldValue.equals(optionValue)) { - // value is same as that present in the model. return without doing anything. - return; - } - - // value has changed. set volume option at back-end and update model accordingly - guiHelper.setStatusMessage("Setting option [" + optionKey + " = " + optionValue + "]..."); - getViewer().getControl().update(); - - BusyIndicator.showWhile(Display.getDefault(), new Runnable() { - - @Override - public void run() { - VolumesClient client = new VolumesClient(); - try { - client.setVolumeOption(volume.getName(), optionKey, optionValue); - GlusterDataModelManager.getInstance().setVolumeOption(volume, optionKey, optionValue); - } catch(Exception e) { - MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option", e.getMessage()); - } - getViewer().update(entry, null); - } - }); - - guiHelper.clearStatusMessage(); - getViewer().getControl().update(); - } - - /** - * @param key Key whose default value is to be fetched - * @return Default value of the volume option with given key - */ - private String getDefaultValue(String key) { - for(VolumeOptionInfo optionInfo : defaults) { - if(optionInfo.getName().equals(key)) { - return optionInfo.getDefaultValue(); - } - } - return ""; - } - - @Override - protected Object getValue(Object element) { - VolumeOption entry = (VolumeOption) element; - return entry.getValue().isEmpty() ? getDefaultValue(entry.getKey()) : entry.getValue(); - } - - @Override - protected CellEditor getCellEditor(Object element) { - return cellEditor; - } - - @Override - protected boolean canEdit(Object element) { - return true; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerDisksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerDisksPage.java deleted file mode 100644 index a2982590..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerDisksPage.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.ServerDiskTableLabelProvider; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Entity; - -public class ServerDisksPage extends AbstractDisksPage { - - public ServerDisksPage(Composite parent, int style, IWorkbenchSite site, List disks) { - super(parent, style, site, disks); - } - - public enum SERVER_DISK_TABLE_COLUMN_INDICES { - DISK, PARTITION, FREE_SPACE, TOTAL_SPACE, STATUS - }; - - private static final String[] SERVER_DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Partition", "Free Space (GB)", - "Total Space (GB)", "Status" }; - - @Override - protected int getStatusColumnIndex() { - return SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(); - } - - @Override - protected ServerDiskTableLabelProvider getLabelProvider() { - // return new DeviceTableLabelProvider(); - return new ServerDiskTableLabelProvider(); - } - - - @Override - protected IContentProvider getContentProvider() { - return new DiskTreeContentProvider(disks); - } - - @Override - public void entityChanged(Entity entity, String[] paremeters) { - // TODO Auto-generated method stub - - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerLogsPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerLogsPage.java deleted file mode 100644 index 7b3f3946..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServerLogsPage.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ListViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.FormToolkit; - -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.model.GlusterServer; - -public class ServerLogsPage extends Composite { - - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private Text text; - private Table table; - - public enum LOG_TABLE_COLUMN_INDICES { - DATE, TIME, DISK, SEVERITY, MESSAGE - }; - - private static final String[] LOG_TABLE_COLUMN_NAMES = new String[] { "Date", "Time", "Disk", "Severity", "Message" }; - - /** - * Create the composite. - * - * @param parent - * @param style - */ - public ServerLogsPage(Composite parent, int style, GlusterServer server) { - super(parent, style); - addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - toolkit.dispose(); - } - }); - toolkit.adapt(this); - toolkit.paintBordersFor(this); - - setLayout(new GridLayout(1, false)); - GridData layoutData = new GridData(); - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = true; - setLayoutData(layoutData); - - Composite composite = toolkit.createComposite(this, SWT.NONE); - toolkit.paintBordersFor(composite); - - Label lblScanLast = toolkit.createLabel(composite, "Scan last", SWT.NONE); - lblScanLast.setBounds(0, 15, 80, 20); - - text = toolkit.createText(composite, "100", SWT.NONE); - text.setBounds(85, 15, 60, 20); - text.setTextLimit(4); - text.addVerifyListener(new VerifyListener() { - - @Override - public void verifyText(VerifyEvent event) { - // Assume we allow it - event.doit = true; - - String text = event.text; - char[] chars = text.toCharArray(); - - // Don't allow if text contains non-digit characters - for (int i = 0; i < chars.length; i++) { - if (!Character.isDigit(chars[i])) { - event.doit = false; - break; - } - } - - } - }); - - Label lblMessagesAndFilter = toolkit.createLabel(composite, " messages from ", SWT.CENTER); - lblMessagesAndFilter.setBounds(160, 15, 110, 20); - - Combo combo = new Combo(composite, SWT.CENTER); - combo.setBounds(295, 15, 100, 20); - combo.setItems(new String[] { "syslog", "dmesg" }); - toolkit.adapt(combo); - toolkit.paintBordersFor(combo); - combo.select(0); - - Button btngo = toolkit.createButton(composite, "&Go", SWT.NONE); - btngo.setBounds(410, 13, 50, 30); - - Label separator = toolkit.createLabel(composite, "", SWT.SEPARATOR | SWT.HORIZONTAL | SWT.FILL); - separator.setBounds(0, 50, 500, 2); - - Label lblFilterString = toolkit.createLabel(composite, "Filter String", SWT.LEFT); - lblFilterString.setBounds(0, 65, 100, 20); - - text = guiHelper.createFilterText(toolkit, composite); - text.setBounds(105, 65, 250, 20); - - Composite logContentsComposite = createLogContentsComposite(toolkit); - // Text logContentsText = toolkit.createText(logContentsComposite, "", SWT.MULTI | SWT.FLAT | SWT.BORDER); - // logContentsText.setEditable(false); - // populateDummyLogContent(logContentsText); - - ListViewer logViewer = new ListViewer(logContentsComposite, SWT.BORDER | SWT.V_SCROLL | SWT.NO); - logViewer.setContentProvider(new ArrayContentProvider()); - guiHelper.createFilter(logViewer, text, false); - logViewer.setInput(getDummyLogContents()); - - // TODO: Link the filter string with the contents text - } - - private Composite createLogContentsComposite(FormToolkit toolkit) { - Composite tableViewerComposite = toolkit.createComposite(this, SWT.NONE); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - layoutData.verticalIndent = 10; - tableViewerComposite.setLayoutData(layoutData); - return tableViewerComposite; - } - - private String[] getDummyLogContents() { - - String[] logMessages = { - "Jan 19 13:43:08 shireesh-laptop dhclient: last message repeated 6 times", - "Jan 19 13:44:08 shireesh-laptop dhclient: last message repeated 5 times", - "Jan 19 13:44:47 shireesh-laptop dhclient: last message repeated 2 times", - "Jan 19 13:44:47 shireesh-laptop dhclient: DHCPREQUEST of 192.168.1.174 on eth1 to 255.255.255.255 port 67", - "Jan 19 13:45:49 shireesh-laptop dhclient: last message repeated 6 times", - "Jan 19 13:46:59 shireesh-laptop dhclient: last message repeated 6 times", - "Jan 19 13:48:01 shireesh-laptop dhclient: last message repeated 4 times", - "Jan 19 13:49:02 shireesh-laptop dhclient: last message repeated 5 times", - "Jan 19 13:50:08 shireesh-laptop dhclient: last message repeated 4 times", - "Jan 19 13:51:08 shireesh-laptop dhclient: last message repeated 6 times", - "Jan 19 13:52:08 shireesh-laptop dhclient: last message repeated 4 times", - "Jan 19 13:53:08 shireesh-laptop dhclient: last message repeated 6 times", - "Jan 19 13:54:08 shireesh-laptop dhclient: last message repeated 5 times", - "Jan 19 13:55:08 shireesh-laptop dhclient: last message repeated 4 times", - "Jan 19 13:56:08 shireesh-laptop dhclient: last message repeated 4 times", - "Jan 19 13:57:08 shireesh-laptop dhclient: last message repeated 3 times", - "Jan 19 13:58:08 shireesh-laptop dhclient: last message repeated 6 times", - "Jan 19 13:59:08 shireesh-laptop dhclient: last message repeated 4 times", - "Jan 19 13:59:40 shireesh-laptop dhclient: last message repeated 3 times", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: DHCP: device eth1 state changed bound -> expire", - "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: DHCP: device eth1 state changed expire -> preinit", - "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPOFFER of 192.168.1.174 from 192.168.1.1", - "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPREQUEST of 192.168.1.174 on eth1 to 255.255.255.255 port 67", - "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPACK of 192.168.1.174 from 192.168.1.1", - "Jan 19 13:59:40 shireesh-laptop dhclient: bound to 192.168.1.174 -- renewal in 3205 seconds.", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: DHCP: device eth1 state changed preinit -> bound", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: address 192.168.1.174", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: prefix 24 (255.255.255.0)", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: gateway 192.168.1.1", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: nameserver '192.168.1.1'", - "Jan 19 13:59:40 shireesh-laptop NetworkManager: domain name 'in.gluster.com'", - "Jan 19 14:03:53 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", - "Jan 19 14:03:53 shireesh-laptop avahi-daemon[1098]: Received response from host 192.168.1.155 with invalid source port 37219 on interface 'eth0.0'", - "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", - "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", - "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Received response from host 192.168.1.155 with invalid source port 37219 on interface 'eth0.0'", - "Jan 19 14:05:09 shireesh-laptop avahi-daemon[1098]: last message repeated 8 times", - "Jan 19 14:12:48 shireesh-laptop NetworkManager: [1295426568.002642] periodic_update(): Roamed from BSSID E0:CB:4E:C0:0B:7F (glfs) to (none) ((none))", - "Jan 19 14:12:54 shireesh-laptop NetworkManager: [1295426574.002448] periodic_update(): Roamed from BSSID (none) ((none)) to E0:CB:4E:C0:0B:7F (glfs)", - "Jan 19 14:17:01 shireesh-laptop CRON[5321]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)" }; - - return logMessages; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServersPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServersPage.java deleted file mode 100644 index d97827c6..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/ServersPage.java +++ /dev/null @@ -1,138 +0,0 @@ - /******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.EntityGroupContentProvider; -import com.gluster.storage.management.console.ServerTableLabelProvider; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Server; - -public class ServersPage extends AbstractTableViewerPage { - private List servers; - - public enum SERVER_TABLE_COLUMN_INDICES { - NAME, IP_ADDRESSES, NUM_OF_DISKS, TOTAL_DISK_SPACE - }; - - private static final String[] SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", "IP Address(es)", "Number of Disks", "Total Disk Space (GB)" }; - - public ServersPage(final Composite parent, IWorkbenchSite site, EntityGroup serversGroup) { - super(site, parent, SWT.NONE, true, true, serversGroup); - this.servers = serversGroup.getEntities(); - } - - @Override - protected ClusterListener createClusterListener() { - return new DefaultClusterListener() { - @Override - public void discoveredServerRemoved(Server server) { - tableViewer.remove(server); - parent.update(); - } - - @Override - public void discoveredServerAdded(Server server) { - tableViewer.add(server); - parent.update(); - } - - @Override - public void discoveredServerChanged(Server server, Event event) { - tableViewer.update(server, null); - parent.update(); - } - }; - } - - public void setInput(EntityGroup servers) { - tableViewer.setInput(servers); - tableViewer.refresh(); - } - - @Override - protected void setColumnProperties(Table table) { - setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.NAME, SWT.CENTER, 70); - setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES, SWT.CENTER, 100); - setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.NUM_OF_DISKS, SWT.CENTER, 70); - setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE, SWT.CENTER, 70); - // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.NUM_OF_CPUS, SWT.CENTER, 90); - // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE, SWT.CENTER, 90); - // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.TOTAL_MEMORY, SWT.CENTER, 90); - // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE, SWT.CENTER, 90); - // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE, SWT.CENTER, 90); - } - - @Override - protected String[] getColumnNames() { - return SERVER_TABLE_COLUMN_NAMES; - } - - @Override - protected IBaseLabelProvider getLabelProvider() { - return new ServerTableLabelProvider(); - } - - @Override - protected IContentProvider getContentProvider() { - return new EntityGroupContentProvider(); - } - - @Override - protected List getAllEntities() { - return servers; - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - private void setColumnProperties(Table table, SERVER_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } - - @Override - protected ViewerComparator createViewerComparator() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/TasksPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/TasksPage.java deleted file mode 100644 index c166af0f..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/TasksPage.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * TasksPage.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.TasksTableLabelProvider; -import com.gluster.storage.management.console.toolbar.GlusterToolbarManager; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.TaskInfo; - -public class TasksPage extends AbstractTableViewerPage { - private List taskInfoList; - private TaskInfo selectedTask; - - public enum TASK_TABLE_COLUMN_INDICES { - TASK, STATUS - }; - - private static final String[] TASK_TABLE_COLUMN_NAMES = new String[] { "Task", "Status"}; - - - public TasksPage(IWorkbenchSite site, Composite parent, int style, List taskInfo) { - super(site, parent, style, false, false, taskInfo); - this.taskInfoList = taskInfo; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#createClusterListener() - */ - @Override - protected ClusterListener createClusterListener() { - return new DefaultClusterListener() { - @Override - public void taskAdded(TaskInfo taskInfo) { - tableViewer.add(taskInfo); - parent.update(); - } - - @Override - public void taskRemoved(TaskInfo taskInfo) { - tableViewer.remove(taskInfo); - parent.update(); - // hide the task related actionset as no task is selected - // site.getPage().hideActionSet(ActionConstants.ACTION_SET_TASK); - } - - @Override - public void taskUpdated(TaskInfo taskInfo) { - tableViewer.update(taskInfo, null); - parent.update(); - // fire selection event so that toolbar gets updated - // (the action class listens to selection and enables/disables automatically) - tableViewer.setSelection(new StructuredSelection(taskInfo)); - } - }; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getColumnNames() - */ - @Override - protected String[] getColumnNames() { - return TASK_TABLE_COLUMN_NAMES; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#setColumnProperties(org.eclipse.swt.widgets.Table) - */ - @Override - protected void setColumnProperties(Table table) { - guiHelper.setColumnProperties(table, TASK_TABLE_COLUMN_INDICES.TASK.ordinal(), SWT.LEFT, 50); - guiHelper.setColumnProperties(table, TASK_TABLE_COLUMN_INDICES.STATUS.ordinal(), SWT.LEFT, 50); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getLabelProvider() - */ - @Override - protected IBaseLabelProvider getLabelProvider() { - return new TasksTableLabelProvider(); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getContentProvider() - */ - @Override - protected IContentProvider getContentProvider() { - return new ArrayContentProvider(); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getAllEntities() - */ - @Override - protected List getAllEntities() { - return taskInfoList; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.console.views.pages.AbstractTableViewerPage#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (selection instanceof StructuredSelection) { - Entity selectedEntity = (Entity) ((StructuredSelection) selection).getFirstElement(); - if (selectedEntity != null && selectedEntity instanceof TaskInfo && selectedEntity != selectedTask) { - selectedTask = (TaskInfo)selectedEntity; - new GlusterToolbarManager(part.getSite().getWorkbenchWindow()).updateToolbar(selectedTask); - } - } - } - - @Override - protected ViewerComparator createViewerComparator() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeLogsPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeLogsPage.java deleted file mode 100644 index 162160f8..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeLogsPage.java +++ /dev/null @@ -1,431 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DateTime; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.FormToolkit; - -import com.gluster.storage.management.client.VolumesClient; -import com.gluster.storage.management.console.VolumeLogTableLabelProvider; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.constants.GlusterConstants.VOLUME_LOG_LEVELS; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeLogMessage; - -public class VolumeLogsPage extends Composite { - - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private final GUIHelper guiHelper = GUIHelper.getInstance(); - private Text filterText; - private Text lineCountText; - private Volume volume; - - public enum LOG_TABLE_COLUMN_INDICES { - DATE, TIME, BRICK, SEVERITY, MESSAGE - }; - - private static final String[] LOG_TABLE_COLUMN_NAMES = new String[] { "Date", "Time", "Brick", "Severity", "Message" }; - private TableViewer tableViewer; - private Combo bricksCombo; - private Combo severityCombo; - private DateTime fromDate; - private DateTime fromTime; - private DateTime toDate; - private DateTime toTime; - private Button fromCheckbox; - private Button toCheckbox; - - /** - * Create the volume logs page - * - * @param parent - * @param style - * @param volume - * Volume for which the logs page is to be created - */ - public VolumeLogsPage(Composite parent, int style, Volume volume) { - super(parent, style); - this.volume = volume; - - addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - toolkit.dispose(); - } - }); - toolkit.adapt(this); - toolkit.paintBordersFor(this); - - configureLayout(); - - Composite composite = toolkit.createComposite(this, SWT.NONE); - toolkit.paintBordersFor(composite); - - createLineCountLabel(composite); - createLineCountText(composite); - - createBricksLabel(composite); - createBricksCombo(composite); - - createSeverityLabel(composite); - createSeverityCombo(composite); - - createFromDateLabel(composite); - createFromDateField(composite); - createFromTimeField(composite); - createFromCheckbox(composite); - - createToDateLabel(composite); - createToDateField(composite); - createToTimeField(composite); - createToCheckbox(composite); - - createSearchButton(composite); - - createSeparator(composite); - - createFilterLabel(composite); - createFilterText(composite); - - createLogTableViewer(); - } - - private void createLogTableViewer() { - Composite tableViewerComposite = createTableViewerComposite(); - - tableViewer = new TableViewer(tableViewerComposite, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); - tableViewer.setLabelProvider(new VolumeLogTableLabelProvider()); - tableViewer.setContentProvider(new ArrayContentProvider()); - - setupLogsTable(tableViewerComposite, tableViewer.getTable()); - guiHelper.createFilter(tableViewer, filterText, false); - } - - private void createFilterText(Composite composite) { - filterText = guiHelper.createFilterText(toolkit, composite); - filterText.setBounds(90, 105, 250, 20); - } - - private void createFilterLabel(Composite composite) { - Label lblFilterString = toolkit.createLabel(composite, "Filter String", SWT.LEFT); - lblFilterString.setBounds(0, 105, 85, 20); - } - - private void createSeparator(Composite composite) { - Label separator = toolkit.createLabel(composite, "", SWT.SEPARATOR | SWT.HORIZONTAL | SWT.FILL); - separator.setBounds(0, 95, 680, 2); - } - - private void createSearchButton(Composite composite) { - Button btnGo = toolkit.createButton(composite, "&Fetch Logs", SWT.NONE); - btnGo.setBounds (615, 55, 75, 30); - btnGo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - VolumesClient client = new VolumesClient(); - - Date fromTimestamp = null; - Date toTimestamp = null; - - if (fromCheckbox.getSelection()) { - fromTimestamp = extractTimestamp(fromDate, fromTime); - } - - if (toCheckbox.getSelection()) { - toTimestamp = extractTimestamp(toDate, toTime); - } - - if (!validateTimeRange(fromTimestamp, toTimestamp)) { - return; - } - - try { - List logMessages = client.getLogs(volume.getName(), bricksCombo.getText(), - severityCombo.getText(), fromTimestamp, toTimestamp, - Integer.parseInt(lineCountText.getText())); - tableViewer.setInput(logMessages.toArray(new VolumeLogMessage[0])); - tableViewer.refresh(); - } catch (Exception ex) { - MessageDialog.openError(getShell(), "Volume Logs", - "Error while fetching volume logs: [" + ex.getMessage() + "]"); - } - } - }); - } - - protected boolean validateTimeRange(Date fromTimestamp, Date toTimestamp) { - if (fromTimestamp == null && toTimestamp == null) { - // no time range selected. nothing to validate. - return true; - } - - Calendar calendar = Calendar.getInstance(); - Date now = calendar.getTime(); - if (fromTimestamp != null && fromTimestamp.after(now)) { - MessageDialog.openError(getShell(), "Volume Logs", "From time can't be greater than current time!"); - return false; - } - - if (toTimestamp != null) { - if (toTimestamp.after(now)) { - MessageDialog.openError(getShell(), "Volume Logs", "To time can't be greater than current time!"); - return false; - } - - if (fromTimestamp.after(toTimestamp)) { - MessageDialog.openError(getShell(), "Volume Logs", "From time can't be greater than To time!"); - return false; - } - } - - return true; - } - - private void createToCheckbox(Composite composite) { - toCheckbox = toolkit.createButton(composite, null, SWT.CHECK); - toCheckbox.setBounds(320, 60, 15, 20); - toCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (toCheckbox.getSelection()) { - toDate.setEnabled(true); - toTime.setEnabled(true); - } else { - toDate.setEnabled(false); - toTime.setEnabled(false); - } - } - }); - } - - private void createToTimeField(Composite composite) { - toTime = new DateTime(composite, SWT.BORDER | SWT.TIME); - toTime.setBounds(490, 60, 120, 20); - toTime.setEnabled(false); - toolkit.adapt(toTime); - toolkit.paintBordersFor(toTime); - } - - private void createToDateField(Composite composite) { - toDate = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN); - toDate.setBounds(365, 60, 120, 20); - toDate.setEnabled(false); - toolkit.adapt(toDate); - toolkit.paintBordersFor(toDate); - } - - private void createToDateLabel(Composite composite) { - Label lblTo = toolkit.createLabel(composite, "To", SWT.NONE); - lblTo.setBounds(340, 60, 25, 20); - } - - private void createFromCheckbox(Composite composite) { - fromCheckbox = toolkit.createButton(composite, null, SWT.CHECK); - fromCheckbox.setBounds(0, 60, 15, 20); - fromCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fromCheckbox.getSelection()) { - fromDate.setEnabled(true); - fromTime.setEnabled(true); - } else { - fromDate.setEnabled(false); - fromTime.setEnabled(false); - } - } - }); - } - - private void createFromTimeField(Composite composite) { - fromTime = new DateTime(composite, SWT.BORDER | SWT.TIME); - fromTime.setBounds(190, 60, 120, 20); - fromTime.setEnabled(false); - toolkit.adapt(fromTime); - toolkit.paintBordersFor(fromTime); - } - - private void createFromDateField(Composite composite) { - fromDate = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN); - fromDate.setBounds(60, 60, 120, 20); - fromDate.setEnabled(false); - toolkit.adapt(fromDate); - toolkit.paintBordersFor(fromDate); - } - - private void createFromDateLabel(Composite composite) { - Label lblFrom = toolkit.createLabel(composite, "from", SWT.NONE); - lblFrom.setBounds(20, 60, 40, 20); - } - - private void createSeverityCombo(Composite composite) { - severityCombo = new Combo(composite, SWT.READ_ONLY); - severityCombo.setBounds(555, 15, 110, 20); - - severityCombo.setItems(GlusterConstants.VOLUME_LOG_LEVELS_ARR.toArray(new String[0])); - severityCombo.select(VOLUME_LOG_LEVELS.ERROR.ordinal()); - severityCombo.add(CoreConstants.ALL, 0); - - toolkit.adapt(severityCombo); - toolkit.paintBordersFor(severityCombo); - } - - private void createSeverityLabel(Composite composite) { - Label lblSeverity = toolkit.createLabel(composite, "Severity", SWT.NONE); - lblSeverity.setBounds(480, 15, 70, 20); - } - - private void createBricksCombo(Composite composite) { - bricksCombo = new Combo(composite, SWT.READ_ONLY); - bricksCombo.setBounds(365, 15, 100, 20); - bricksCombo.setItems( volume.getBrickDirectories().toArray(new String[0])); - bricksCombo.add(CoreConstants.ALL, 0); - toolkit.adapt(bricksCombo); - toolkit.paintBordersFor(bricksCombo); - bricksCombo.select(0); - } - - private void createBricksLabel(Composite composite) { - Label lblMessagesAndFilter = toolkit.createLabel(composite, "messages, and filter on bricks", SWT.NONE); - lblMessagesAndFilter.setBounds(160, 15, 200, 20); - } - - private void createLineCountText(Composite composite) { - lineCountText = toolkit.createText(composite, "100", SWT.NONE); - lineCountText.setBounds(85, 15, 60, 20); - lineCountText.setTextLimit(4); - lineCountText.addVerifyListener(new VerifyListener() { - - @Override - public void verifyText(VerifyEvent event) { - // Assume we allow it - event.doit = true; - - String text = event.text; - char[] chars = text.toCharArray(); - - // Don't allow if text contains non-digit characters - for (int i = 0; i < chars.length; i++) { - if (!Character.isDigit(chars[i])) { - event.doit = false; - break; - } - } - } - }); - } - - private void createLineCountLabel(Composite composite) { - Label lblScanLast = toolkit.createLabel(composite, "Scan last", SWT.NONE); - lblScanLast.setBounds(0, 15, 80, 20); - } - - private void configureLayout() { - setLayout(new GridLayout(1, false)); - GridData layoutData = new GridData(); - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = true; - // layoutData.verticalIndent = 10; - setLayoutData(layoutData); - } - - private Composite createTableViewerComposite() { - Composite tableViewerComposite = new Composite(this, SWT.NO); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - layoutData.verticalIndent = 10; - tableViewerComposite.setLayoutData(layoutData); - return tableViewerComposite; - } - - private void setupLogsTable(Composite parent, Table table) { - table.setHeaderVisible(true); - table.setLinesVisible(false); - - TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, LOG_TABLE_COLUMN_NAMES); - parent.setLayout(tableColumnLayout); - - setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.DATE, SWT.CENTER, 50); - setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.TIME, SWT.CENTER, 50); - setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.BRICK, SWT.CENTER, 50); - setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.SEVERITY, SWT.CENTER, 50); - setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.MESSAGE, SWT.LEFT, 100); - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - private void setColumnProperties(Table table, LOG_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } - - private Date extractTimestamp(DateTime date, DateTime time) { - Calendar calendar = Calendar.getInstance(); - calendar.setLenient(false); - calendar.set(Calendar.DAY_OF_MONTH, date.getDay()); - // in Calendar class, month starts with zero i.e. Jan = 0 - calendar.set(Calendar.MONTH, date.getMonth()); - calendar.set(Calendar.YEAR, date.getYear()); - calendar.set(Calendar.HOUR_OF_DAY, time.getHours()); - calendar.set(Calendar.MINUTE, time.getMinutes()); - calendar.set(Calendar.SECOND, time.getSeconds()); - return calendar.getTime(); - } - - public void addDoubleClickListener(IDoubleClickListener listener) { - tableViewer.addDoubleClickListener(listener); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeOptionsPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeOptionsPage.java deleted file mode 100644 index dd02a672..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumeOptionsPage.java +++ /dev/null @@ -1,360 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.apache.commons.lang.WordUtils; -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.ColumnLabelProvider; -import org.eclipse.jface.viewers.ColumnLayoutData; -import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.TableViewerColumn; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.FormToolkit; - -import com.gluster.storage.management.console.GlusterDataModelManager; -import com.gluster.storage.management.console.VolumeOptionsContentProvider; -import com.gluster.storage.management.console.VolumeOptionsTableLabelProvider; -import com.gluster.storage.management.console.utils.GUIHelper; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.VolumeOption; -import com.gluster.storage.management.core.model.VolumeOptionInfo; - -public class VolumeOptionsPage extends Composite { - - private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); - private TableViewer tableViewer; - private GUIHelper guiHelper = GUIHelper.getInstance(); - private Volume volume; - private DefaultClusterListener clusterListener; - private Text filterText; - private List defaultVolumeOptions = GlusterDataModelManager.getInstance() - .getVolumeOptionsInfo(); - - public enum OPTIONS_TABLE_COLUMN_INDICES { - OPTION_KEY, OPTION_VALUE - }; - - private static final String[] OPTIONS_TABLE_COLUMN_NAMES = new String[] { "Option Key", "Option Value" }; - private Button addTopButton; - private Button addBottomButton; - private TableViewerColumn keyColumn; - private OptionKeyEditingSupport keyEditingSupport; - - public VolumeOptionsPage(final Composite parent, int style, Volume volume) { - super(parent, style); - - this.volume = volume; - - toolkit.adapt(this); - toolkit.paintBordersFor(this); - - setupPageLayout(); - addTopButton = createAddButton(); - filterText = guiHelper.createFilterText(toolkit, this); - - setupOptionsTableViewer(filterText); - - addBottomButton = createAddButton(); - - if (defaultVolumeOptions.size() == volume.getOptions().size()) { - setAddButtonsEnabled(false); - } - - tableViewer.setInput(volume.getOptions()); - - parent.layout(); // Important - this actually paints the table - registerListeners(parent); - } - - private void setAddButtonsEnabled(boolean enable) { - addTopButton.setEnabled(enable); - addBottomButton.setEnabled(enable); - } - - private Button createAddButton() { - return toolkit.createButton(this, "&Add", SWT.FLAT); - } - - private void registerListeners(final Composite parent) { - /** - * Ideally not required. However the table viewer is not getting laid out properly on performing - * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window - */ - addPaintListener(new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - parent.layout(); - } - }); - - clusterListener = new DefaultClusterListener() { - @Override - public void volumeChanged(Volume volume, Event event) { - super.volumeChanged(volume, event); - - switch (event.getEventType()) { - case VOLUME_OPTIONS_RESET: - if (!tableViewer.getControl().isDisposed()) { - //While reseting the options, clear the filter text before refreshing the tree - filterText.setText(""); - tableViewer.refresh(); - setAddButtonsEnabled(true); - } - break; - - case VOLUME_OPTION_SET: - String key = (String)event.getEventData(); - if (isNewOption(volume, key)) { - // option has been set successfully by the user. re-enable the add button and search filter - // textbox - setAddButtonsEnabled(true); - filterText.setEnabled(true); - } - - if (defaultVolumeOptions.size() == volume.getOptions().size()) { - setAddButtonsEnabled(false); - } - - tableViewer.refresh(); - break; - case VOLUME_CHANGED: - tableViewer.refresh(); - if(volume.getOptions().size() == defaultVolumeOptions.size()) { - setAddButtonsEnabled(false); - } else { - setAddButtonsEnabled(true); - } - default: - break; - } - } - - private boolean isNewOption(Volume volume, String optionKey) { - if (filterText.getText().length() > 0) { - // user has been filtering the contents. adding new option is allowed only when contents are NOT - // filtered. Thus it's impossible that this is a newly added option - return false; - } - - // if this is the last option in the volume options, it must be the new option - return optionKey.equals(volume.getOptions().getOptions().get(volume.getOptions().size() - 1).getKey()); - } - }; - - SelectionListener addButtonSelectionListener = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - // add an empty option to be filled up by user - volume.setOption("", ""); - - tableViewer.refresh(); - tableViewer.setSelection(new StructuredSelection(getEntry(""))); - keyColumn.getViewer().editElement(getEntry(""), 0); // edit newly created entry - - // disable the add button AND search filter textbox till user fills up the new option - setAddButtonsEnabled(false); - filterText.setEnabled(false); - } - - private VolumeOption getEntry(String key) { - for (VolumeOption entry : volume.getOptions().getOptions()) { - if (entry.getKey().equals(key)) { - return entry; - } - } - return null; - } - }; - addTopButton.addSelectionListener(addButtonSelectionListener); - addBottomButton.addSelectionListener(addButtonSelectionListener); - - // Make sure that add button is enabled only when search filter textbox is empty - filterText.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - if (filterText.getText().length() > 0) { - setAddButtonsEnabled(false); - } else { - if (defaultVolumeOptions.size() == volume.getOptions().size()) { - setAddButtonsEnabled(false); - } else { - setAddButtonsEnabled(true); - } - } - } - }); - - GlusterDataModelManager.getInstance().addClusterListener(clusterListener); - - addDisposeListener(new DisposeListener() { - - @Override - public void widgetDisposed(DisposeEvent e) { - toolkit.dispose(); - - if (!(addTopButton.isEnabled() || addBottomButton.isEnabled())) { - // user has selected key, but not added value. Since this is not a valid entry, - // remove the last option (without value) from the volume - volume.getOptions().remove(keyEditingSupport.getEntryBeingAdded().getKey()); - } - - GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); - } - }); - } - - private void setupPageLayout() { - final GridLayout layout = new GridLayout(2, false); - layout.verticalSpacing = 10; - layout.marginTop = 10; - setLayout(layout); - } - - private void setupOptionsTable(Composite parent) { - Table table = tableViewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - - TableColumnLayout tableColumnLayout = createTableColumnLayout(); - parent.setLayout(tableColumnLayout); - - setColumnProperties(table, OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY, SWT.CENTER, 100); - setColumnProperties(table, OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE, SWT.CENTER, 100); - } - - private TableColumnLayout createTableColumnLayout() { - TableColumnLayout tableColumnLayout = new TableColumnLayout(); - ColumnLayoutData defaultColumnLayoutData = new ColumnWeightData(100); - - tableColumnLayout.setColumnData(createKeyColumn(), defaultColumnLayoutData); - tableColumnLayout.setColumnData(createValueColumn(), defaultColumnLayoutData); - - return tableColumnLayout; - } - - private TableColumn createValueColumn() { - TableViewerColumn valueColumn = new TableViewerColumn(tableViewer, SWT.NONE); - valueColumn.getColumn() - .setText(OPTIONS_TABLE_COLUMN_NAMES[OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal()]); - valueColumn.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - return ((VolumeOption) element).getValue(); - } - }); - - // User can edit value of a volume option - valueColumn.setEditingSupport(new OptionValueEditingSupport(valueColumn.getViewer(), volume)); - - return valueColumn.getColumn(); - } - - private TableColumn createKeyColumn() { - keyColumn = new TableViewerColumn(tableViewer, SWT.NONE); - keyColumn.getColumn().setText(OPTIONS_TABLE_COLUMN_NAMES[OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal()]); - keyColumn.setLabelProvider(new ColumnLabelProvider() { - @Override - public String getText(Object element) { - return ((VolumeOption) element).getKey(); - } - - @Override - public String getToolTipText(Object element) { - String key = ((VolumeOption) element).getKey(); - if (key.isEmpty()) { - return "Click to select a volume option key"; - } - - VolumeOptionInfo optionInfo = GlusterDataModelManager.getInstance().getVolumeOptionInfo(key); - // Wrap the description before adding to tooltip so that long descriptions are displayed properly - return WordUtils.wrap(optionInfo.getDescription(), 60) + CoreConstants.NEWLINE + "Default value: " - + optionInfo.getDefaultValue(); - } - }); - - // Editing support required when adding new key - keyEditingSupport = new OptionKeyEditingSupport(keyColumn.getViewer(), volume); - keyColumn.setEditingSupport(keyEditingSupport); - - return keyColumn.getColumn(); - } - - private void createOptionsTableViewer(Composite parent) { - tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.SINGLE); - tableViewer.setLabelProvider(new VolumeOptionsTableLabelProvider()); - tableViewer.setContentProvider(new VolumeOptionsContentProvider()); - tableViewer.getTable().setLinesVisible(true); - - setupOptionsTable(parent); - } - - private Composite createTableViewerComposite() { - Composite tableViewerComposite = new Composite(this, SWT.NO); - tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); - - GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); - layoutData.horizontalSpan = 2; - tableViewerComposite.setLayoutData(layoutData); - - return tableViewerComposite; - } - - private void setupOptionsTableViewer(final Text filterText) { - Composite tableViewerComposite = createTableViewerComposite(); - createOptionsTableViewer(tableViewerComposite); - ColumnViewerToolTipSupport.enableFor(tableViewer); - // Create a case insensitive filter for the table viewer using the filter text field - guiHelper.createFilter(tableViewer, filterText, false); - } - - private void setColumnProperties(Table table, OPTIONS_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } -} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumesPage.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumesPage.java deleted file mode 100644 index 484f91b0..00000000 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/pages/VolumesPage.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.console.views.pages; - -import java.util.List; - -import org.eclipse.jface.layout.TableColumnLayout; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IBaseLabelProvider; -import org.eclipse.jface.viewers.IContentProvider; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.IWorkbenchSite; - -import com.gluster.storage.management.console.EntityGroupContentProvider; -import com.gluster.storage.management.console.VolumeTableLabelProvider; -import com.gluster.storage.management.console.toolbar.GlusterToolbarManager; -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.model.ClusterListener; -import com.gluster.storage.management.core.model.DefaultClusterListener; -import com.gluster.storage.management.core.model.EntityGroup; -import com.gluster.storage.management.core.model.Event; -import com.gluster.storage.management.core.model.Volume; - -public class VolumesPage extends AbstractTableViewerPage { - private List volumes; - - final GlusterToolbarManager toolbarManager = new GlusterToolbarManager( site.getWorkbenchWindow()); - - public enum VOLUME_TABLE_COLUMN_INDICES { - NAME, VOLUME_TYPE, NUM_OF_BRICKS, TRANSPORT_TYPE, VOLUME_STATUS - }; - - private static final String[] VOLUME_TABLE_COLUMN_NAMES = new String[] { "Name", "Volume Type", - "Number of" + CoreConstants.NEWLINE + "Bricks", "Transport Type", "Status" }; - - public VolumesPage(final Composite parent, IWorkbenchSite site, EntityGroup volumes) { - super(site, parent, SWT.NONE, true, true, volumes); - this.volumes = volumes.getEntities(); - } - - @Override - protected String[] getColumnNames() { - return VOLUME_TABLE_COLUMN_NAMES; - } - - @Override - protected void setColumnProperties(Table table) { - setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS, SWT.CENTER, 50); - setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.NUM_OF_BRICKS, SWT.CENTER, 50); - setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.TRANSPORT_TYPE, SWT.CENTER, 70); - } - - @Override - protected IBaseLabelProvider getLabelProvider() { - return new VolumeTableLabelProvider(); - } - - @Override - protected IContentProvider getContentProvider() { - return new EntityGroupContentProvider(); - } - - @Override - protected ClusterListener createClusterListener() { - return new DefaultClusterListener() { - @Override - public void volumeCreated(Volume volume) { - tableViewer.add(volume); - parent.update(); - toolbarManager.updateToolbar(volume); - } - - @Override - public void volumeDeleted(Volume volume) { - tableViewer.remove(volume); - parent.update(); - toolbarManager.updateToolbar(volume); - } - - @Override - public void volumeChanged(Volume volume, Event event) { - tableViewer.update(volume, null); - parent.update(); - toolbarManager.updateToolbar(volume); - } - }; - } - - /** - * Sets properties for alignment and weight of given column of given table - * - * @param table - * @param columnIndex - * @param alignment - * @param weight - */ - public void setColumnProperties(Table table, VOLUME_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { - TableColumn column = table.getColumn(columnIndex.ordinal()); - column.setAlignment(alignment); - - TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); - tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); - } - - @Override - protected List getAllEntities() { - return volumes; - } - - @Override - protected ViewerComparator createViewerComparator() { - // TODO Auto-generated method stub - return null; - } -} diff --git a/src/com.gluster.storage.management.console/src/test.xml b/src/com.gluster.storage.management.console/src/test.xml deleted file mode 100644 index 12bbf745..00000000 --- a/src/com.gluster.storage.management.console/src/test.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/com.gluster.storage.management.core/.classpath b/src/com.gluster.storage.management.core/.classpath deleted file mode 100644 index b41cbcdb..00000000 --- a/src/com.gluster.storage.management.core/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/com.gluster.storage.management.core/.project b/src/com.gluster.storage.management.core/.project deleted file mode 100644 index c016cd3c..00000000 --- a/src/com.gluster.storage.management.core/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - com.gluster.storage.management.core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - com.instantiations.assist.eclipse.coverage.instrumentationBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - com.instantiations.assist.eclipse.coverage.codeCoverageNature - - diff --git a/src/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs b/src/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f22cedf1..00000000 --- a/src/com.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Dec 22 11:18:01 IST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/com.gluster.storage.management.core/META-INF/MANIFEST.MF b/src/com.gluster.storage.management.core/META-INF/MANIFEST.MF deleted file mode 100644 index 9ddbca69..00000000 --- a/src/com.gluster.storage.management.core/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Gluster Storage Platform Core -Bundle-SymbolicName: com.gluster.storage.management.core -Bundle-Version: 1.0.0 -Bundle-Vendor: GLUSTER -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Export-Package: com.gluster.storage.management.core.constants, - com.gluster.storage.management.core.exceptions, - com.gluster.storage.management.core.model, - com.gluster.storage.management.core.response, - com.gluster.storage.management.core.utils -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0" -Bundle-ClassPath: . -Import-Package: com.gluster.storage.management.core.exceptions diff --git a/src/com.gluster.storage.management.core/build.properties b/src/com.gluster.storage.management.core/build.properties deleted file mode 100644 index 89d32a46..00000000 --- a/src/com.gluster.storage.management.core/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - lib/ -src.includes = lib/,\ - src/ diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java deleted file mode 100644 index 81c7a601..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/AlertTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.gluster.storage.management.core.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.gluster.storage.management.core.model.Alert.ALERT_TYPES; - -/** - * The class AlertTest contains tests for the class {@link Alert}. - * - * @generatedBy CodePro at 10/17/11 3:32 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class AlertTest { - - /** - * Run the void copyFrom(Alert) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 3:32 PM - */ - @Test - public void testCopyFrom_1() - throws Exception { - Alert fixture = new Alert(ALERT_TYPES.DISK_USAGE_ALERT, "server1:sda", - Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [85% used] in disk [server1:sda]"); - Alert alert = new Alert(); - alert.copyFrom(fixture); - - assertEquals(fixture.getId(), alert.getId()); - assertEquals(fixture.getReference(), alert.getReference()); - assertEquals(fixture.getType(), alert.getType()); - assertEquals(fixture.getMessage(), alert.getMessage()); - assertNotNull(alert); - } - - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 10/17/11 3:32 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 10/17/11 3:32 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 10/17/11 3:32 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(AlertTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java deleted file mode 100644 index 329ee926..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/BrickTest.java +++ /dev/null @@ -1,304 +0,0 @@ -package com.gluster.storage.management.core.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; - -/** - * The class BrickTest contains tests for the class {@link Brick}. - * - * @generatedBy CodePro at 10/17/11 4:39 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class BrickTest { - /** - * Run the void copyFrom(Brick) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testCopyFrom_1() - throws Exception { - Brick fixture = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/songs"); - Brick newBrick = new Brick(); - newBrick.copyFrom(fixture); - - assertEquals(fixture.getServerName(), newBrick.getServerName()); - assertEquals(fixture.getBrickDirectory(), newBrick.getBrickDirectory()); - assertEquals(fixture.getStatus(), newBrick.getStatus()); - assertEquals(fixture.getQualifiedName(), newBrick.getQualifiedName()); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testEquals_1() - throws Exception { - Brick fixture = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/songs"); - Brick newBrick = new Brick(); - newBrick.copyFrom(fixture); - - boolean result = fixture.equals(newBrick); - assertTrue(result); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testEquals_2() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - Brick newBrick = new Brick(); - newBrick.copyFrom(fixture); - - boolean result = fixture.equals(newBrick); - assertTrue(result); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testEquals_3() - throws Exception { - Brick fixture = new Brick("", BRICK_STATUS.ONLINE, ""); - Brick newBrick = new Brick(); - newBrick.copyFrom(fixture); - - boolean result = fixture.equals(newBrick); - assertTrue(result); - } - - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testFilter_1() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String filterString = "Ser"; - boolean caseSensitive = true; - - boolean result = fixture.filter(filterString, caseSensitive); - assertTrue(result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testFilter_2() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String filterString = "ser"; - boolean caseSensitive = true; - - boolean result = fixture.filter(filterString, caseSensitive); - assertEquals(result, false); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testFilter_3() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String filterString = "Ser"; - boolean caseSensitive = false; - - boolean result = fixture.filter(filterString, caseSensitive); - assertTrue(result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testFilter_4() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.ONLINE, "/md1/test"); - - String filterString = "ser"; - boolean caseSensitive = false; - - boolean result = fixture.filter(filterString, caseSensitive); - assertTrue(result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testFilter_5() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String filterString = ""; - boolean caseSensitive = false; - - boolean result = fixture.filter(filterString, caseSensitive); - assertTrue(result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testFilter_6() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String filterString = ""; - boolean caseSensitive = true; - - boolean result = fixture.filter(filterString, caseSensitive); - assertTrue(result); - } - - - /** - * Run the String getQualifiedName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testGetQualifiedName_1() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String result = fixture.getQualifiedName(); - - assertNotNull(result); - assertEquals(result, "Server2:/md1/test"); - } - - /** - * Run the String getQualifiedName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testGetQualifiedName_2() - throws Exception { - Brick fixture = new Brick("", BRICK_STATUS.OFFLINE, ""); - - String result = fixture.getQualifiedName(); - - assertNotNull(result); - assertEquals(result, ":"); - } - - - /** - * Run the String toString() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Test - public void testToString_1() - throws Exception { - Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); - - String result = fixture.toString(); - - assertNotNull(result); - assertEquals(result, "Server2:/md1/test"); - } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 10/17/11 4:39 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(BrickTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java deleted file mode 100644 index c2e488b1..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/ClusterTest.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.gluster.storage.management.core.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Device.DEVICE_TYPE; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; - -/** - * The class ClusterTest contains tests for the class {@link Cluster}. - * - * @generatedBy CodePro at 10/18/11 2:53 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class ClusterTest { - private Cluster fixture; - - public List getDisks(Server server) { - List disks = new ArrayList(); - disks.add(new Disk(server, "sda", "", 12456.0, 0.0, DEVICE_STATUS.UNINITIALIZED)); - Disk disk = new Disk(server, "sdb1", "/export", 134342456.0, 120343.0, DEVICE_STATUS.INITIALIZED); - disk.setType(DEVICE_TYPE.DATA); - disks.add(disk); - disk = new Disk(server, "sdc2", "/export", 876534346.0, 56334.0, DEVICE_STATUS.INITIALIZED); - disk.setType(DEVICE_TYPE.DATA); - disks.add(disk); - return disks; - } - - public List getServers() { - List servers = new ArrayList(); - GlusterServer server1 = new GlusterServer("Server1", null, SERVER_STATUS.ONLINE, 2, 10, 8, 4); - server1.addDisks(getDisks(server1)); - servers.add(server1); - - GlusterServer server2 = new GlusterServer("Server2", null, SERVER_STATUS.ONLINE, 1, 90, 10, 9); - server2.addDisks(getDisks(server2)); - servers.add(server2); - - GlusterServer server3 = new GlusterServer("Server3", null, SERVER_STATUS.ONLINE, 4, 50, 6, 5); - server3.addDisks(getDisks(server3)); - servers.add(server3); - - GlusterServer server4 = new GlusterServer("Server4", null, SERVER_STATUS.ONLINE, 2, 40, 4, 3); - server4.addDisks(getDisks(server4)); - servers.add(server4); - - return servers; - } - - public List getBricks(String volumeName) { - List bricks = new ArrayList(); - Brick brick1 = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/"+volumeName); - bricks.add(brick1); - Brick brick2 = new Brick("Server2", BRICK_STATUS.ONLINE, "/sdb1/"+volumeName); - bricks.add(brick2); - Brick brick3 = new Brick("Server3", BRICK_STATUS.ONLINE, "/sdc1/"+volumeName); - bricks.add(brick3); - Brick brick4 = new Brick("Server4", BRICK_STATUS.OFFLINE, "/sda2/"+volumeName); - bricks.add(brick4); - return bricks; - } - - - public void populateVolumes(Cluster cluster) { - Volume volume1 = new Volume("Songs", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - volume1.addBricks(getBricks(volume1.getName())); - cluster.addVolume(volume1); - - Volume volume2 = new Volume("Movie", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - volume2.addBricks(getBricks(volume1.getName())); - cluster.addVolume(volume2); - - Volume volume3 = new Volume("graphics", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.INFINIBAND, - VOLUME_STATUS.ONLINE); - volume3.addBricks(getBricks(volume1.getName())); - cluster.addVolume(volume3); - - Volume volume4 = new Volume("cartoon", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - volume4.addBricks(getBricks(volume1.getName())); - cluster.addVolume(volume4); - return; - } - - /** - * Run the double getDiskSpaceInUse() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - @Test - public void testGetDiskSpaceInUse_1() - throws Exception { - double result = fixture.getDiskSpaceInUse(); - - assertEquals(706708.0, result, 0.1); - } - - /** - * Run the GlusterServer getServer(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - @Test - public void testGetServer_1() - throws Exception { - GlusterServer result = fixture.getServer("Server1"); - - assertNotNull(result); - assertEquals("Server1", result.getName()); - assertEquals(2, result.getNumOfCPUs()); - assertEquals(3, result.getNumOfDisks() ); - } - - /** - * Run the double getTotalDiskSpace() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - @Test - public void testGetTotalDiskSpace_1() - throws Exception { - double result = fixture.getTotalDiskSpace(); - assertEquals(4043557032.0, result, 0.1); // Including unformatted disks(!) - } - - /** - * Run the double getTotalDiskSpace() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - @Test - public void testGetVolume_1() - throws Exception { - populateVolumes(fixture); - Volume result = fixture.getVolume("Songs"); - assertNotNull(result); - assertTrue(result instanceof Volume); - } - - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - @Before - public void setUp() - throws Exception { - fixture = new Cluster(); - fixture.setServers(getServers()); - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 10/18/11 2:53 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(ClusterTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java deleted file mode 100644 index b6bd4142..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/DiskTest.java +++ /dev/null @@ -1,483 +0,0 @@ -package com.gluster.storage.management.core.model; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Collection; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Device.DEVICE_TYPE; - -/** - * The class DiskTest contains tests for the class {@link Disk}. - * - * @generatedBy CodePro at 10/19/11 6:26 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class DiskTest { - private Disk disk; - - /** - * Run the Disk() constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testDisk_1() - throws Exception { - - // add additional test code here - assertNotNull(disk); - assertEquals(new Double(5000.0), disk.getSpace()); - assertEquals("Hitachi HTS72323 ATA", disk.getDescription()); - assertEquals(true, disk.isReady()); - assertEquals(null, disk.getDiskInterface()); - assertEquals(null, disk.getRaidDisks()); - assertEquals(false, disk.hasPartitions()); - assertEquals(new Double(3000.0), disk.getSpaceInUse()); - assertEquals(DEVICE_TYPE.DATA, disk.getType()); - assertEquals(new Double(2000.0), disk.getFreeSpace()); - assertEquals(DEVICE_STATUS.INITIALIZED, disk.getStatus()); - assertEquals("Server1:sda1", disk.getQualifiedName()); - assertEquals(true, disk.isInitialized()); - assertEquals(false, disk.hasErrors()); - assertEquals("Server1", disk.getServerName()); - assertEquals("Available", disk.getStatusStr()); - assertEquals(false, disk.isUninitialized()); - assertEquals("/md0/sda1", disk.getMountPoint()); - assertEquals("ext4", disk.getFsType()); - assertEquals("3.2.3", disk.getFsVersion()); - assertEquals("sda1", disk.toString()); - assertEquals("sda1", disk.getName()); - assertTrue(disk.getParent() instanceof Server); - } - - /** - * Run the Disk(Server,String,String,Double,Double,DEVICE_STATUS) constructor test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testDisk_2() - throws Exception { - Server server = new Server(); - String name = ""; - String mountPoint = ""; - Double space = new Double(1.0); - Double spaceInUse = new Double(1.0); - Device.DEVICE_STATUS status = Device.DEVICE_STATUS.INITIALIZED; - - Disk newDisk = new Disk(server, name, mountPoint, space, spaceInUse, status); - - // add additional test code here - assertNotNull(newDisk); - assertEquals(new Double(1.0), newDisk.getSpace()); - assertEquals(null, newDisk.getDescription()); - assertEquals(false, newDisk.isReady()); - assertEquals(null, newDisk.getDiskInterface()); - assertEquals(null, newDisk.getRaidDisks()); - assertEquals(false, newDisk.hasPartitions()); - assertEquals(new Double(1.0), newDisk.getSpaceInUse()); - assertEquals(null, newDisk.getType()); - assertEquals(new Double(0.0), newDisk.getFreeSpace()); - assertEquals("null:", newDisk.getQualifiedName()); - assertEquals(true, newDisk.isInitialized()); - assertEquals(false, newDisk.hasErrors()); - assertEquals(null, newDisk.getServerName()); - assertEquals("Initialized", newDisk.getStatusStr()); - assertEquals(false, newDisk.isUninitialized()); - assertEquals("", newDisk.getMountPoint()); - assertEquals(null, newDisk.getFsType()); - assertEquals(null, newDisk.getFsVersion()); - assertEquals("", newDisk.toString()); - assertEquals("", newDisk.getName()); - } - - /** - * Run the void copyFrom(Disk) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testCopyFrom_1() - throws Exception { - Disk newDisk = new Disk(); - newDisk.copyFrom(disk); - - assertEquals(newDisk.getSpace(), disk.getSpace()); - assertEquals(newDisk.getDescription(), disk.getDescription()); - assertEquals(newDisk.isReady(), disk.isReady()); - assertEquals(newDisk.getDiskInterface(), disk.getDiskInterface()); - assertEquals(newDisk.getRaidDisks(), disk.getRaidDisks()); - assertEquals(newDisk.hasPartitions(), disk.hasPartitions()); - assertEquals(newDisk.getSpaceInUse(), disk.getSpaceInUse()); - assertEquals(newDisk.getType(), disk.getType()); - assertEquals(newDisk.getFreeSpace(), disk.getFreeSpace()); - assertEquals(newDisk.getStatus(), disk.getStatus()); - assertEquals(newDisk.getQualifiedName(), disk.getQualifiedName()); - assertEquals(newDisk.isInitialized(), disk.isInitialized()); - assertEquals(newDisk.hasErrors(), disk.hasErrors()); - assertEquals(newDisk.getServerName(), disk.getServerName()); - assertEquals(newDisk.getStatusStr(), disk.getStatusStr()); - assertEquals(newDisk.isUninitialized(), disk.isUninitialized()); - assertEquals(newDisk.getMountPoint(), disk.getMountPoint()); - assertEquals(newDisk.getFsType(), disk.getFsType()); - assertEquals(newDisk.getFsVersion(), disk.getFsVersion()); - assertEquals(newDisk.toString(), disk.toString()); - assertEquals(newDisk.getName(), disk.getName()); - assertEquals(newDisk.getParent(), disk.getParent()); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testEquals_1() - throws Exception { - - Disk newDisk = new Disk(); - newDisk.copyFrom(disk); - boolean result = newDisk.equals(disk); - - assertTrue(result); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testEquals_2() - throws Exception { - Server server = new Server(); - String name = ""; - String mountPoint = ""; - Double space = new Double(1.0); - Double spaceInUse = new Double(1.0); - Device.DEVICE_STATUS status = Device.DEVICE_STATUS.INITIALIZED; - Disk newDisk = new Disk(server, name, mountPoint, space, spaceInUse, status); - - boolean result = newDisk.equals(disk); - - assertTrue(!result); - } - - /** - * Run the boolean equals(Object) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testEquals_3() - throws Exception { - - Disk newDisk = new Disk(); - newDisk.copyFrom(disk); - boolean result = newDisk.equals(disk); - - assertTrue(result); - } - - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testFilter_1() - throws Exception { - String filterString = ""; - boolean caseSensitive = true; - boolean result = disk.filter(filterString, caseSensitive); - - assertTrue(result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testFilter_2() - throws Exception { - String filterString = "Serv"; - boolean caseSensitive = true; - boolean result = disk.filter(filterString, caseSensitive); - - assertTrue(result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testFilter_3() - throws Exception { - String filterString = "serv"; - boolean caseSensitive = true; - boolean result = disk.filter(filterString, caseSensitive); - assertTrue(!result); - } - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testFilter_4() - throws Exception { - String filterString = "hitachi"; - boolean caseSensitive = true; - - boolean result = disk.filter(filterString, caseSensitive); - assertTrue(!result); - } - - - - /** - * Run the boolean filter(String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testFilter_5() - throws Exception { - String filterString = "hitachi"; - boolean caseSensitive = false; - - boolean result = disk.filter(filterString, caseSensitive); - assertTrue(result); - } - - - /** - * Run the Double getSpace() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testGetSpace_1() - throws Exception { - Double result = disk.getSpace(); - assertNotNull(result); - assertTrue(result instanceof Double); - } - - - - /** - * Run the Double getSpaceInUse() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testGetSpaceInUse_1() - throws Exception { - Double result = disk.getSpaceInUse(); - assertNotNull(result); - assertTrue(result instanceof Double); - } - - - /** - * Run the boolean hasPartitions() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testHasPartitions_1() - throws Exception { - disk.setPartitions(new ArrayList()); - boolean result = disk.hasPartitions(); - assertTrue(!result); - } - - - - /** - * Run the boolean isReady() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testIsReady_1() - throws Exception { - boolean result = disk.isReady(); - System.out.println("Disk status is [" + result + "] on [" + disk.getName() +"] and Status is [" + disk.getStatusStr() +"]"); - assertTrue(result); - } - - /** - * Run the boolean isReady() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testIsReady_2() - throws Exception { - disk.setPartitions(new ArrayList()); - boolean result = disk.isReady(); - assertTrue(result); - } - - /** - * Run the boolean isReady() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testIsReady_3() - throws Exception { - disk.setStatus(DEVICE_STATUS.UNINITIALIZED); - boolean result = disk.isReady(); - assertTrue(!result); - } - - /** - * Run the boolean isReady() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testIsReady_4() - throws Exception { - disk.setStatus(DEVICE_STATUS.IO_ERROR); - boolean result = disk.isReady(); - - assertTrue(!result); - } - - /** - * Run the boolean isReady() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testIsReady_5() - throws Exception { - disk.setStatus(DEVICE_STATUS.INITIALIZING); - boolean result = disk.isReady(); - - assertTrue(!result); - } - - /** - * Run the boolean isReady() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Test - public void testIsReady_6() - throws Exception { - disk.setStatus(DEVICE_STATUS.UNKNOWN); - boolean result = disk.isReady(); - - assertTrue(!result); - } - - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @Before - public void setUp() - throws Exception { - Server server = new Server("Server1", null, 2, 25D, 5000D, 2000D); - disk = new Disk(server,"sda1", "/md0/sda1", 5000D, 3000D, DEVICE_STATUS.INITIALIZED); - disk.setDescription("Hitachi HTS72323 ATA"); - disk.setFsType("ext4"); - disk.setFsVersion("3.2.3"); - disk.setType(DEVICE_TYPE.DATA); - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(DiskTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java deleted file mode 100644 index 159ff256..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/model/TestAll.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.gluster.storage.management.core.model; - -import org.junit.runner.JUnitCore; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -/** - * The class TestAll builds a suite that can be used to run all - * of the tests within its package as well as within any subpackages of its - * package. - * - * @generatedBy CodePro at 10/19/11 6:26 PM - * @author root - * @version $Revision: 1.0 $ - */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - BrickTest.class, - ClusterTest.class, - AlertTest.class, - DiskTest.class, -}) -public class TestAll { - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 10/19/11 6:26 PM - */ - public static void main(String[] args) { - JUnitCore.runClasses(new Class[] { TestAll.class }); - } -} diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/DateUtilTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/DateUtilTest.java deleted file mode 100644 index c19b75d2..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/DateUtilTest.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.gluster.storage.management.core.utils; - -import static org.junit.Assert.assertEquals; - -import java.util.Date; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -/** - * The class DateUtilTest contains tests for the class {@link DateUtil}. - * - * @generatedBy CodePro at 9/27/11 12:31 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class DateUtilTest { - - private Date date = DateUtil.getDate(2011, 9, 29, 11, 17, 38, 10); - - /** - * Run the String dateToString(Date) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testDateToString_1() - throws Exception { - String result = DateUtil.dateToString(date); - - assertEquals("09/29/2011 11:17:38", result); - } - - /** - * Run the String dateToString(Date,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testDateToString_2() - throws Exception { - String dateFormat = ""; - - String result = DateUtil.dateToString(date, dateFormat); - assertEquals("", result); - } - - /** - * Run the String dateToString(Date,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testDateToString_3() - throws Exception { - String dateFormat = CoreConstants.PURE_DATE_FORMAT; - - String result = DateUtil.dateToString(date, dateFormat); - assertEquals("09/29/2011", result); - } - - /** - * Run the String formatDate(Date) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testFormatDate_1() - throws Exception { - String result = DateUtil.formatDate(date); - - assertEquals("09/29/2011", result); - } - - /** - * Run the String formatDate(Date) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testFormatDate_2() - throws Exception { - Date date1 = DateUtil.getDate(1965, 1, 12, 0, 0, 0, 0); - String result = DateUtil.formatDate(date1); - assertEquals("01/12/1965", result); - } - - /** - * Run the String formatTime(Date) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testFormatTime_1() - throws Exception { - String result = DateUtil.formatTime(date); - - // add additional test code here - assertEquals("11:17:38.010", result); - } - - /** - * Run the Date stringToDate(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test(expected=GlusterRuntimeException.class) - public void testStringToDate_1() - throws Exception { - DateUtil.stringToDate(""); - } - - /** - * Run the Date stringToDate(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test(expected=GlusterRuntimeException.class) - public void testStringToDate_2() - throws Exception { - String testDate = "09/29/2011"; - DateUtil.stringToDate(testDate); - } - - /** - * Run the Date stringToDate(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test - public void testStringToDate_3() - throws Exception { - String dateFormat = "MM/dd/yyyy"; - String input = "09/29/2011"; // MM/dd/yyyy HH:mm:ss - Date expectedDate = DateUtil.getDate(2011, 9, 29, 0, 0, 0, 0); - - Date result = DateUtil.stringToDate(input, dateFormat); - assertEquals(expectedDate, result); - } - - /** - * Run the Date stringToDate(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Test(expected = GlusterRuntimeException.class) - public void testStringToDate_4() - throws Exception { - String inputDate = ""; - String dateFormat = ""; - - DateUtil.stringToDate(inputDate, dateFormat); - } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 9/27/11 12:31 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(DateUtilTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/FileUtilTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/FileUtilTest.java deleted file mode 100644 index 9302619e..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/FileUtilTest.java +++ /dev/null @@ -1,481 +0,0 @@ -package com.gluster.storage.management.core.utils; - -import static org.junit.Assert.*; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - - -/** - * The class FileUtilTest contains tests for the class {@link FileUtil}. - * - * @generatedBy CodePro at 9/29/11 2:39 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class FileUtilTest { - - - private static final String TEST_FILE_PATH = FileUtil.getTempDirName() + "/test.txt"; - private static final String TEST_FILE_CONTENT = "Welcome to Gluster Storage Management console."; - - - /** - * To write the text into given file. - * - * @generatedBy - */ - private boolean writeToFile(String fileName, String text) { - try { - Writer output = null; - File file = new File(fileName); - output = new BufferedWriter(new FileWriter(file)); - output.write(text); - output.close(); - return true; - } catch (Exception e) { - return false; - } - } - - private boolean createNestedDir(String path) { - File file = new File(path); - return file.mkdirs(); - } - - private boolean createEmptyFile(String fileName) { - File file = new File(fileName); - if (file.exists()) { - return true; - } - - try { - return file.createNewFile(); - } catch (IOException e) { - return false; - } - } - - /** - * Run the File createTempDir() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testCreateTempDir_1() - throws Exception { - - File result = FileUtil.createTempDir(); - - assertNotNull(result); - assertTrue(File.class.equals(result.getClass())); - } - - /** - * Run the File createTempDir() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testCreateTempDir_2() - throws Exception { - - File result1 = FileUtil.createTempDir(); - File result2 = FileUtil.createTempDir(); - - assertNotSame(result1, result2); - } - - - /** - * Run the void createTextFile(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test(expected=GlusterRuntimeException.class) - public void testCreateTextFile_1() - throws Exception { - String fileName = ""; - String contents = ""; - FileUtil.createTextFile(fileName, contents); - } - - /** - * Run the String getTempDirName() method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testGetTempDirName_1() - throws Exception { - String result = FileUtil.getTempDirName(); - - // while running on linux - assertEquals("/tmp", result); - } - - /** - * Run the byte[] readFileAsByteArray(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - - @Test(expected=GlusterRuntimeException.class) - public void testReadFileAsByteArray_1() - throws Exception { - File file = new File(""); - - byte[] result = FileUtil.readFileAsByteArray(file); - } - - /** - * Run the byte[] readFileAsByteArray(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testReadFileAsByteArray_2() - throws Exception { - File file = new File(TEST_FILE_PATH); - - byte[] result = FileUtil.readFileAsByteArray(file); - assertNotNull(result); - assertTrue(result instanceof byte[]); - assertTrue(TEST_FILE_CONTENT.equals(new String(result))); - } - - - /** - * Run the String readFileAsString(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - - @Test(expected=GlusterRuntimeException.class) - public void testReadFileAsString_1() - throws Exception { - File file = new File(""); - - FileUtil.readFileAsString(file); - } - - - /** - * Run the String readFileAsString(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testReadFileAsString_2() - throws Exception { - File file = new File(TEST_FILE_PATH); - String result = FileUtil.readFileAsString(file); - - assertNotNull(result); - assertTrue(result instanceof String); - assertTrue(result.equals(TEST_FILE_CONTENT)); - } - - /** - * Run the void recursiveDelete(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testRecursiveDelete_1() - throws Exception { - - //Delete empty directories recursively - File fileOrDir = new File(FileUtil.getTempDirName() + "/rd"); - - FileUtil.recursiveDelete(fileOrDir); - assertTrue(!fileOrDir.exists()); - } - - /** - * Run the void recursiveDelete(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - - @Test(expected=GlusterRuntimeException.class) - public void testRecursiveDelete_2() - throws Exception { - //Delete directories recursively (with some files) - File fileOrDir = new File(FileUtil.getTempDirName() + "/rdx"); - - FileUtil.recursiveDelete(fileOrDir); - assertTrue(!fileOrDir.exists()); - } - - /** - * Run the void recursiveDelete(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testRecursiveDelete_3() - throws Exception { - File fileOrDir = new File(FileUtil.getTempDirName() + "/rd"); - FileUtil.recursiveDelete(fileOrDir); - assertTrue(!fileOrDir.exists()); - } - - /** - * Run the void recursiveDelete(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testRecursiveDelete_4() - throws Exception { - File file = new File(FileUtil.getTempDirName() + "/rd/b/bc/mydoc.txt"); - assertTrue(!file.exists()); - - file = new File(FileUtil.getTempDirName() + "/rd//b/bc"); - assertTrue(!file.exists()); - } - - /** - * Run the void recursiveDelete(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test(expected=GlusterRuntimeException.class) - public void testRecursiveDelete_5() - throws Exception { - File fileOrDir = new File(FileUtil.getTempDirName() + "/rd/*"); //Wild cards - FileUtil.recursiveDelete(fileOrDir); - } - - - /** - * Run the void recursiveDelete(File) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test(expected=GlusterRuntimeException.class) - public void testRecursiveDelete_6() - throws Exception { - File fileOrDir = new File(FileUtil.getTempDirName() + "/abcxyz"); - FileUtil.recursiveDelete(fileOrDir); - } - - /** - * Run the void renameFile(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - - @Test(expected=GlusterRuntimeException.class) - public void testRenameFile_1() - throws Exception { - String fromPath = FileUtil.getTempDirName() + "/test.txt"; - new File(fromPath).createNewFile(); - String toPath = "~/abc.txt"; // Relative path - - FileUtil.renameFile(fromPath, toPath); - assertTrue(!new File(fromPath).exists()); - assertTrue(new File(toPath).exists()); - } - - /** - * Run the void renameFile(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Test - public void testRenameFile_2() - throws Exception { - String fromPath = FileUtil.getTempDirName() + "/test.txt"; - new File(fromPath).createNewFile(); - - String toPath = FileUtil.getTempDirName() + "/abc.txt"; // Absolute path example - FileUtil.renameFile(fromPath, toPath); - assertTrue(!new File(fromPath).exists()); - assertTrue(new File(toPath).exists()); - } - - @Test - public void testRenameFile_3() - throws Exception { - String fromPath = FileUtil.getTempDirName() + "/test.txt"; - new File(fromPath).createNewFile(); - - String toPath = FileUtil.getTempDirName() + "/renamefile.txt"; - FileUtil.renameFile(fromPath, toPath); - assertTrue(!new File(fromPath).exists()); - assertTrue(new File(toPath).exists()); - } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @Before - public void setUp() - throws Exception { - - // testReadFileAsByteArray_2() - if (!writeToFile(TEST_FILE_PATH, TEST_FILE_CONTENT)) { - fail("Setup: Text file creation error!"); - } - - // testRecursiveDelete_1() - if (!createNestedDir(FileUtil.getTempDirName() + "/rd/b/c/d")) { - createEmptyFile(FileUtil.getTempDirName() + "/rd/b/mydoc.txt"); - createEmptyFile(FileUtil.getTempDirName() + "/rd/b/songs.mp3"); - createEmptyFile(FileUtil.getTempDirName() + "/rd/b/mysetup.cfg"); - - createEmptyFile(FileUtil.getTempDirName() + "/rd/b/bc/mydoc.txt"); - createEmptyFile(FileUtil.getTempDirName() + "/rd/songs.mp3"); - createEmptyFile(FileUtil.getTempDirName() + "/rd/b/bc/mysetup.cfg"); - - createEmptyFile(FileUtil.getTempDirName() + "/rd//b/mydoc.txt"); - createEmptyFile(FileUtil.getTempDirName() + "/rd/b/bc/songs.mp3"); - - } - - if (! createEmptyFile(FileUtil.getTempDirName() + "/renamefile.txt") ) { - fail("Failed to create file [/renamefile.txt]"); - } - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - @After - public void tearDown() - throws Exception { - File file = new File(TEST_FILE_PATH); - file.delete(); - file = new File(FileUtil.getTempDirName() + "/rd/b/c/d"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/rd/b/c"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/rd/b/mydoc.txt"); - if (file.exists()) { - file.delete(); - } - file = new File(FileUtil.getTempDirName() + "/rd/b/songs.mp3"); - if (file.exists()) { - file.delete(); - } - file = new File(FileUtil.getTempDirName() + "/rd/b/mysetup.cfg"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/rd/b/bc/mydoc.txt"); - if (file.exists()) { - file.delete(); - } - file = new File(FileUtil.getTempDirName() + "/rd/b/bc/mysetup.cfg"); - if (file.exists()) { - file.delete(); - } - file = new File(FileUtil.getTempDirName() + "/rd/b/bc/songs.mp3"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/rd/b/bc"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/rd/b"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/rd"); - if (file.exists()) { - file.delete(); - } - - file = new File(FileUtil.getTempDirName() + "/abc.txt"); - if (file.exists()) { - file.delete(); - } - file = new File("~/abc.txt"); - if (file.exists()) { - file.delete(); - } - file = new File(FileUtil.getTempDirName() + "/test.txt"); - if (file.exists()) { - file.delete(); - } - file = new File(FileUtil.getTempDirName() + "/renamefile.txt"); - if (file.exists()) { - file.delete(); - } - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 9/29/11 2:39 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(FileUtilTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/StringUtilTest.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/StringUtilTest.java deleted file mode 100644 index dc8c6c80..00000000 --- a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/StringUtilTest.java +++ /dev/null @@ -1,309 +0,0 @@ -package com.gluster.storage.management.core.utils; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -/** - * The class StringUtilTest contains tests for the class {@link StringUtil}. - * - * @generatedBy CodePro at 21/9/11 4:53 PM - * @author root - * @version $Revision: 1.0 $ - */ -public class StringUtilTest { - public enum Season { WINTER, SPRING, SUMMER, FALL }; - /** - * Run the String collectionToString(Collection,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testCollectionToString_1() - throws Exception { - List string = new ArrayList(); - string.add("test string"); - String delimiter = ""; - - String result = StringUtil.collectionToString(string, delimiter); - assertEquals("test string", result); - } - - /** - * Run the String collectionToString(Collection,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testCollectionToString_2() - throws Exception { - List string = new ArrayList(); - string.add("test string"); - string.add("welcome to world"); - String delimiter = "::"; - - String result = StringUtil.collectionToString(string, delimiter); - - assertEquals("test string::welcome to world", result); - } - - /** - * Run the String collectionToString(Collection,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testCollectionToString_3() - throws Exception { - List string = new ArrayList(); - string.add("test ## string"); - string.add("java world"); - String delimiter = "##"; - - String result = StringUtil.collectionToString(string, delimiter); - assertEquals("test ## string##java world", result); - } - - /** - * Run the String collectionToString(Collection,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testCollectionToString_4() - throws Exception { - List string = new ArrayList(); - String delimiter = ""; - - String result = StringUtil.collectionToString(string, delimiter); - assertEquals("", result); - } - - /** - * Run the List enumToArray(T[]) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testEnumToArray_1() - throws Exception { - - String[] expected = new String[] {"WINTER", "SPRING", "SUMMER", "FALL"}; - List result = StringUtil.enumToArray(Season.values()); - - assertNotNull(result); - assertEquals(4, result.size()); - } - - /** - * Run the List extractList(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testExtractList_1() - throws Exception { - String input = "This is test message"; - String delim = " "; - - List result = StringUtil.extractList(input, delim); - - assertNotNull(result); - assertEquals(4, result.size()); - } - - /** - * Run the List extractList(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testExtractList_2() - throws Exception { - String input = "welcome#to#java#world"; - String delim = "#"; - - List result = StringUtil.extractList(input, delim); - - assertNotNull(result); - assertEquals(4, result.size()); - } - - /** - * Run the List extractList(String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testExtractList_3() - throws Exception { - String input = "list$to%string"; - String delim = "%"; - - List result = StringUtil.extractList(input, delim); - - assertNotNull(result); - assertEquals(2, result.size()); - } - - /** - * Run the Map extractMap(String,String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testExtractMap_1() - throws Exception { - String input = "k1=v1,k2=v2,k3=v3"; - String majorDelim = ","; - String minorDelim = "="; - - Map result = StringUtil.extractMap(input, majorDelim, minorDelim); - - // add additional test code here - assertNotNull(result); - assertEquals(3, result.size()); - } - - /** - * Run the Map extractMap(String,String,String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testExtractMap_2() - throws Exception { - String input = "k1=>v1&k2=>v2&k3=>v3"; - String majorDelim = "&"; - String minorDelim = "=>"; - - Map result = StringUtil.extractMap(input, majorDelim, minorDelim); - - // add additional test code here - assertNotNull(result); - assertEquals(3, result.size()); - } - - /** - * Run the boolean filterString(String,String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testFilterString_1() - throws Exception { - String sourceString = "This is java program"; - String filterString = "Java"; - boolean caseSensitive = true; - - boolean result = StringUtil.filterString(sourceString, filterString, caseSensitive); - - assertEquals(false, result); - } - - /** - * Run the boolean filterString(String,String,boolean) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testFilterString_2() - throws Exception { - String sourceString = "This is java program"; - String filterString = "Java"; - boolean caseSensitive = false; - - boolean result = StringUtil.filterString(sourceString, filterString, caseSensitive); - - assertEquals(true, result); - } - - /** - * Run the String removeSpaces(String) method test. - * - * @throws Exception - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Test - public void testRemoveSpaces_1() - throws Exception { - String str = "this is test string"; - - String result = StringUtil.removeSpaces(str); - - // add additional test code here - assertEquals("thisisteststring", result); - } - - /** - * Perform pre-test initialization. - * - * @throws Exception - * if the initialization fails for some reason - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @Before - public void setUp() - throws Exception { - // add additional set up code here - } - - /** - * Perform post-test clean-up. - * - * @throws Exception - * if the clean-up fails for some reason - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - @After - public void tearDown() - throws Exception { - // Add additional tear down code here - } - - /** - * Launch the test. - * - * @param args the command line arguments - * - * @generatedBy CodePro at 21/9/11 4:53 PM - */ - public static void main(String[] args) { - new org.junit.runner.JUnitCore().run(StringUtilTest.class); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/junit/core.junit.launch b/src/com.gluster.storage.management.core/junit/core.junit.launch deleted file mode 100644 index 0bf6dc30..00000000 --- a/src/com.gluster.storage.management.core/junit/core.junit.launch +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.core/junit/test/test.txt b/src/com.gluster.storage.management.core/junit/test/test.txt deleted file mode 100644 index 267ce144..00000000 --- a/src/com.gluster.storage.management.core/junit/test/test.txt +++ /dev/null @@ -1 +0,0 @@ -Test Resource \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java deleted file mode 100644 index 42f0e7a9..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/CoreConstants.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.constants; - - -/** - * - */ -public class CoreConstants { - public static final String NEWLINE = System.getProperty("line.separator"); - public static final String FILE_SEPARATOR = System.getProperty("file.separator"); - public static final String USER_HOME = System.getProperty("user.home"); - public static final String ENCODING_UTF8 = "UTF-8"; - public static final String ALL = "ALL"; - public static final String DATE_WITH_TIME_FORMAT = "MM/dd/yyyy HH:mm:ss"; - public static final String PURE_DATE_FORMAT = "MM/dd/yyyy"; - public static final String PURE_TIME_FORMAT = "HH:mm:ss.SSS"; - public static final String NA = "NA"; - public static final String DEFAULT_PASSWORD = "syst3m"; - public static final String OFFLINE = "OFFLINE"; - public static final String ONLINE = "ONLINE"; - public static final String UNKNOWN = "UNKNOWN"; - public static final String RUNNING_TASKS = "Tasks"; -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java deleted file mode 100644 index cbc51b10..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.constants; - -import java.util.List; - -import com.gluster.storage.management.core.utils.StringUtil; - -/** - * - */ -public class GlusterConstants { - public enum VOLUME_LOG_LEVELS { - EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG, TRACE - }; - - public static final List VOLUME_LOG_LEVELS_ARR = StringUtil.enumToArray(VOLUME_LOG_LEVELS.values()); - public static final String FSTYPE_DEFAULT = "default"; - public static final String FSTYPE_EXT_3 = "ext3"; - public static final String FSTYPE_EXT_4 = "ext4"; - public static final String FSTYPE_XFS = "xfs"; - - public static final String ON = "on"; - public static final String OFF = "off"; - public static final String NONE = "none"; - - public static final String STATS_PERIOD_1DAY = "1d"; - public static final String STATS_PERIOD_1WEEK = "1w"; - public static final String STATS_PERIOD_1MONTH = "1m"; - public static final String STATS_PERIOD_1YEAR = "1y"; -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java deleted file mode 100644 index 4b1251b6..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * RESTConstants.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.constants; - -/** - * All constants related to the Gluster REST server and client - */ -public class RESTConstants { - // REST Resource paths - public static final String RESOURCE_PATH_USERS = "/users"; - public static final String RESOURCE_PATH_CLUSTERS = "/clusters"; - public static final String RESOURCE_PATH_DISCOVERED_SERVERS = "/discoveredservers"; - public static final String RESOURCE_PATH_KEYS = "/keys"; - - // REST Resource names - public static final String RESOURCE_VOLUMES = "volumes"; - public static final String RESOURCE_DEFAULT_OPTIONS = "options"; - public static final String RESOURCE_OPTIONS = "options"; - public static final String RESOURCE_LOGS = "logs"; - public static final String RESOURCE_DOWNLOAD = "download"; - public static final String RESOURCE_BRICKS = "bricks"; - public static final String RESOURCE_DISKS = "disks"; - public static final String RESOURCE_ALERTS = "alerts"; - public static final String RESOURCE_SERVERS = "servers"; - public static final String RESOURCE_TASKS = "tasks"; - public static final String RESOURCE_KEYS = "keys"; - public static final String RESOURCE_STATISTICS = "statistics"; - public static final String RESOURCE_USERS = "users"; - public static final String RESOURCE_FSTYPES = "fstypes"; - - public static final String TASK_START = "start"; - public static final String TASK_PAUSE = "pause"; - public static final String TASK_RESUME = "resume"; - public static final String TASK_STOP = "stop"; - public static final String TASK_COMMIT = "commit"; - public static final String TASK_STATUS = "status"; - public static final String TASK_DELETE = "delete"; - public static final String TASK_LOG_ROTATE = "logRotate"; - public static final String TASK_REBALANCE_START = "rebalanceStart"; - public static final String TASK_REBALANCE_STATUS = "rebalanceStatus"; - public static final String TASK_REBALANCE_STOP = "rebalanceStop"; - - public static final String FORM_PARAM_VOLUME_NAME = "volumeName"; - public static final String FORM_PARAM_VOLUME_TYPE = "volumeType"; - public static final String FORM_PARAM_TRANSPORT_TYPE = "transportType"; - public static final String FORM_PARAM_REPLICA_COUNT = "replicaCount"; - public static final String FORM_PARAM_STRIPE_COUNT = "stripeCount"; - public static final String FORM_PARAM_BRICKS = "bricks"; - public static final String FORM_PARAM_ACCESS_PROTOCOLS = "accessProtocols"; - public static final String FORM_PARAM_VOLUME_OPTIONS = "options"; - public static final String FORM_PARAM_FSTYPE = "fsType"; - public static final String FORM_PARAM_CIFS_ENABLE = "enableCifs"; - public static final String FORM_PARAM_CIFS_USERS = "cifsUsers"; - public static final String FORM_PARAM_CIFS_CONFIG = "cifs-config"; - public static final String FORM_PARAM_LOG_ROTATE = "log-rotate"; - - public static final String FORM_PARAM_CLUSTER_NAME = "clusterName"; - public static final String FORM_PARAM_SERVER_NAME = "serverName"; - public static final String FORM_PARAM_DISKS = "disks"; - public static final String FORM_PARAM_OPERATION = "operation"; - public static final String FORM_PARAM_VALUE_STATUS = "status"; - public static final String FORM_PARAM_OPTION_KEY = "key"; - public static final String FORM_PARAM_OPTION_VALUE = "value"; - public static final String FORM_PARAM_SOURCE = "source"; - public static final String FORM_PARAM_TARGET = "target"; - public static final String FORM_PARAM_AUTO_COMMIT = "autoCommit"; - public static final String FORM_PARAM_FIX_LAYOUT = "fixLayout"; - public static final String FORM_PARAM_MIGRATE_DATA = "migrateData"; - public static final String FORM_PARAM_FORCED_DATA_MIGRATE = "forcedDataMigrate"; - public static final String FORM_PARAM_OLD_PASSWORD = "oldPassword"; - public static final String FORM_PARAM_NEW_PASSWORD = "newPassword"; - public static final String FORM_PARAM_FORCE = "force"; - public static final String FORM_PARAM_MOUNTPOINT = "mountPoint"; - - public static final String PATH_PARAM_FORMAT = "format"; - public static final String PATH_PARAM_VOLUME_NAME = "volumeName"; - public static final String PATH_PARAM_CLUSTER_NAME = "clusterName"; - public static final String PATH_PARAM_SERVER_NAME = "serverName"; - public static final String PATH_PARAM_TASK_ID = "taskId"; - public static final String PATH_PARAM_DISK_NAME = "diskName"; - public static final String PATH_PARAM_USER = "user"; - - public static final String QUERY_PARAM_BRICK_NAME = "brickName"; - public static final String QUERY_PARAM_DISKS = "disks"; - public static final String QUERY_PARAM_BRICKS = "bricks"; - public static final String QUERY_PARAM_LINE_COUNT = "lineCount"; - public static final String QUERY_PARAM_VOLUME_NAME = "volumeName"; - public static final String QUERY_PARAM_DELETE_OPTION = "deleteData"; - public static final String QUERY_PARAM_LOG_SEVERITY = "severity"; - public static final String QUERY_PARAM_FROM_TIMESTAMP = "fromTimeStamp"; - public static final String QUERY_PARAM_TO_TIMESTAMP = "toTimeStamp"; - public static final String QUERY_PARAM_DOWNLOAD = "download"; - public static final String QUERY_PARAM_SERVER_NAME = "serverName"; - public static final String QUERY_PARAM_DETAILS = "details"; - public static final String QUERY_PARAM_TYPE = "type"; - public static final String QUERY_PARAM_PERIOD = "period"; - public static final String QUERY_PARAM_INTERFACE = "interface"; - public static final String QUERY_PARAM_MAX_COUNT = "maxCount"; - public static final String QUERY_PARAM_NEXT_TO = "nextTo"; - - public static final String STATISTICS_TYPE_CPU = "cpu"; - public static final String STATISTICS_TYPE_NETWORK = "network"; - public static final String STATISTICS_TYPE_MEMORY = "memory"; - - public static final String FORMAT_XML = "xml"; - public static final String FORMAT_JSON = "json"; -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/ConnectionException.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/ConnectionException.java deleted file mode 100644 index ec19ffd8..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/ConnectionException.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.exceptions; - -/** - * - */ -public class ConnectionException extends GlusterRuntimeException { - - private static final long serialVersionUID = 1L; - - - public ConnectionException(String message) { - super(message); - } - - public ConnectionException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java deleted file mode 100644 index e7e604fc..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterRuntimeException.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.exceptions; - -public class GlusterRuntimeException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public GlusterRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public GlusterRuntimeException(String message) { - super(message); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterValidationException.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterValidationException.java deleted file mode 100644 index ca5e01f8..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/exceptions/GlusterValidationException.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.exceptions; - -public class GlusterValidationException extends GlusterRuntimeException { - private static final long serialVersionUID = 1L; - - public GlusterValidationException(String message) { - super(message); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java deleted file mode 100644 index ceb3e77e..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.gluster.storage.management.core.model; - -import org.eclipse.osgi.internal.signedcontent.Base64; - -public class Alert extends Entity { - - public enum ALERT_TYPES { - CPU_USAGE_ALERT, MEMORY_USAGE_ALERT, DISK_USAGE_ALERT, OFFLINE_VOLUME_BRICKS_ALERT, OFFLINE_SERVERS_ALERT, OFFLINE_VOLUME_ALERT - }; - - public static final String[] ALERT_TYPE_STR = { "High CPU Usage", "High Memory Usage", "Low Disk Space", - "Offline Brick", "Offline Server", "Offline Volume" }; - - // protected String id; - protected ALERT_TYPES type; - protected String reference; // [for server- "Server", for Disk- "Server:disk", for volume- "Volume:Server:disk"] - protected String message; - - public String getAlertType() { - return ALERT_TYPE_STR[type.ordinal()]; - } - - public Alert() { - } - - public Alert(ALERT_TYPES type, String reference, String Message) { - setType(type); - setReference(reference); - setMessage(Message); - setId(buildAlertId()); - } - - public String buildAlertId() { - return Base64.encode((getAlertType() + "-" + getReference()).getBytes()).toString(); - } - - public String getId() { - return getName(); - } - - public void setId(String id) { - setName(id); - } - - public ALERT_TYPES getType() { - return type; - } - - public void setType(ALERT_TYPES type) { - this.type = type; - } - - public String getReference() { - return reference; - } - - public void setReference(String reference) { - this.reference = reference; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public void copyFrom(Alert alert) { - this.setId(alert.getId()); - this.setReference(alert.getReference()); - this.setType(alert.getType()); - this.setMessage(alert.getMessage()); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Brick.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Brick.java deleted file mode 100644 index 0b8ad6fd..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Brick.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class Brick extends Entity { - public enum BRICK_STATUS {ONLINE, OFFLINE}; - private String[] BRICK_STATUS_STR = {"Online", "Offline"}; - - private String serverName; - // private String deviceName; - private String brickDirectory; - private BRICK_STATUS status; - - public Brick() { - } - - @Override - @XmlTransient - public String getName() { - return getQualifiedName(); - } - - public BRICK_STATUS getStatus() { - return status; - } - - public String getStatusStr() { - return BRICK_STATUS_STR[getStatus().ordinal()]; - } - - public void setStatus(BRICK_STATUS status) { - this.status = status; - } - - public Brick(String serverName, BRICK_STATUS brickStatus, String brickDirectory) { - setServerName(serverName); - setStatus(brickStatus); - // setDeviceName(deviceName); - setBrickDirectory(brickDirectory); - } - - public void setServerName(String serverName) { - this.serverName = serverName; - } - - public String getServerName() { - return serverName; - } - - public void setBrickDirectory(String brickDirectory) { - this.brickDirectory = brickDirectory; - } - - public String getBrickDirectory() { - return brickDirectory; - } - -// public void setDeviceName(String deviceName) { -// this.deviceName = deviceName; -// } - -// public String getDeviceName() { -// return deviceName; -// } - - public String getQualifiedName() { - return serverName + ":" + brickDirectory; - } - - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getServerName() + getBrickDirectory() + getStatusStr(), filterString, - caseSensitive); - } - - @Override - public String toString() { - return getQualifiedName(); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof Brick)) { - return false; - } - - Brick brick = (Brick)obj; - if(getQualifiedName().equals(brick.getQualifiedName()) && getStatus() == brick.getStatus()) { - return true; - } - - return false; - } - - public void copyFrom(Brick newBrick) { - setServerName(newBrick.getServerName()); - setBrickDirectory(newBrick.getBrickDirectory()); - // setDeviceName(newBrick.getDeviceName()); - setStatus(newBrick.getStatus()); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java deleted file mode 100644 index e11199f6..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java +++ /dev/null @@ -1,196 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="cluster") -public class Cluster extends Entity { - List servers = new ArrayList(); - List discoveredServers = new ArrayList(); - List volumes = new ArrayList(); - List taskInfoList = new ArrayList(); - List alerts = new ArrayList(); - ServerStats aggregatedCpuStats; - ServerStats aggregatedNetworkStats; - - public Cluster() { - } - - public List getServers() { - return servers; - } - - public void addServer(GlusterServer server) { - servers.add(server); - } - - public void removeServer(GlusterServer server) { - servers.remove(server); - } - - public void addDiscoveredServer(Server server) { - discoveredServers.add(server); - } - - public void removeDiscoveredServer(Server server) { - discoveredServers.remove(server); - } - - public void deleteVolume(Volume volume) { - volumes.remove(volume); - } - - public void setServers(List servers) { - this.servers = servers; - children.add(new EntityGroup("Servers", GlusterServer.class, this, servers)); - } - - public List getAutoDiscoveredServers() { - return discoveredServers; - } - - public void setAutoDiscoveredServers(List autoDiscoveredServers) { - this.discoveredServers = autoDiscoveredServers; - children.add(new EntityGroup("Discovered Servers", Server.class, this, autoDiscoveredServers)); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public EntityGroup getEntityGroup(Class type) { - for(Entity entity : getChildren()) { - if(entity instanceof EntityGroup && ((EntityGroup)entity).getEntityType() == type) { - return (EntityGroup)entity; - } - } - return null; - } - - public List getVolumes() { - return volumes; - } - - public void setVolumes(List volumes) { - this.volumes = volumes; - children.add(new EntityGroup("Volumes", Volume.class, this, volumes)); - } - - public void addVolume(Volume volume) { - this.volumes.add(volume); - } - - public void updateVolume(String volumeName, List bricks) { - Volume volume = getVolume(volumeName); - volume.setBricks(bricks); - } - - public Cluster(String name, Entity parent) { - super(name, parent); - } - - public Cluster(String name, Entity parent, List servers, List volumes) { - super(name, parent); - setServers(servers); - setVolumes(volumes); - } - - public List getTaskInfoList() { - return taskInfoList; - } - - public void setTaskInfoList(List taskInfoList) { - this.taskInfoList = taskInfoList; - } - - public void addTaskInfo(TaskInfo taskInfo) { - this.taskInfoList.add(taskInfo); - } - - public void removeTaskInfo(TaskInfo taskInfo) { - this.taskInfoList.remove(taskInfo); - } - - public List getAlerts() { - return alerts; - } - - public void setAlerts(List alerts) { - this.alerts = alerts; - } - - public void addAlert(Alert alert) { - this.alerts.add(alert); - } - - public void removeAlert(Alert alert) { - this.alerts.remove(alert); - } - - public double getTotalDiskSpace() { - double totalDiskSpace = 0; - for(GlusterServer server : getServers()) { - totalDiskSpace += server.getTotalDiskSpace(); - } - return totalDiskSpace; - } - - public double getDiskSpaceInUse() { - double diskSpaceInUse = 0; - for(GlusterServer server : getServers()) { - diskSpaceInUse += server.getDiskSpaceInUse(); - } - return diskSpaceInUse; - } - - public GlusterServer getServer(String serverName) { - for(GlusterServer server : servers) { - if (server.getName().equalsIgnoreCase(serverName) || server.getIpAddressesAsString().contains(serverName)) { - return server; - } - } - return null; - } - - public Volume getVolume(String volumeName) { - for (Volume volume : getVolumes() ) { - if (volume.getName().equals(volumeName)) { - return volume; - } - } - return null; - } - - public ServerStats getAggregatedCpuStats() { - return aggregatedCpuStats; - } - - public void setAggregatedCpuStats(ServerStats aggregatedCpuStats) { - this.aggregatedCpuStats = aggregatedCpuStats; - } - - public ServerStats getAggregatedNetworkStats() { - return aggregatedNetworkStats; - } - - public void setAggregatedNetworkStats(ServerStats aggregatedNetworkStats) { - this.aggregatedNetworkStats = aggregatedNetworkStats; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java deleted file mode 100644 index eb8c191e..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ClusterListener.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -/** - * Interface for a cluster listener. Every registered listener will be notified - * on various events happening on the cluster. - */ -public interface ClusterListener { - public void discoveredServerAdded(Server server); - - public void discoveredServerRemoved(Server server); - - public void discoveredServerChanged(Server server, Event event); - - public void serverAdded(GlusterServer server); - - public void serverRemoved(GlusterServer server); - - public void serverChanged(GlusterServer server, Event event); - - public void volumeChanged(Volume volume, Event event); - - public void volumeCreated(Volume volume); - - public void volumeDeleted(Volume volume); - - public void taskAdded(TaskInfo taskInfo); - - public void taskRemoved(TaskInfo taskInfo); - - public void taskUpdated(TaskInfo taskInfo); - - public void alertsGenerated(); - - public void aggregatedStatsChanged(); - - public void alertRemoved(Alert alert); - - public void alertCreated(Alert alert); -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java deleted file mode 100644 index 9f66ba5b..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ConnectionDetails.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -/** - * Class used for binding UI fields on login / password-change dialog boxes - */ -public class ConnectionDetails { - private String userId, password, newPassword, confirmNewPassword; - - public ConnectionDetails() { - - } - - public ConnectionDetails(String userId, String password) { - this.userId = userId; - this.password = password; - this.confirmNewPassword = ""; - } - - public String getUserId() { - return userId; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setNewPassword(String newPassword) { - this.newPassword = newPassword; - } - - public String getNewPassword() { - return newPassword; - } - - public void setConfirmNewPassword(String confirmNewPassword) { - this.confirmNewPassword = confirmNewPassword; - } - - public String getConfirmNewPassword() { - return confirmNewPassword; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java deleted file mode 100644 index eb98090f..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/DefaultClusterListener.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -/** - * Default listener - doesn't do anything. Sub-class and override the method for - * the event you want to handle. - */ -public class DefaultClusterListener implements ClusterListener { - - @Override - public void serverAdded(GlusterServer server) { - modelChanged(); - } - - @Override - public void serverRemoved(GlusterServer server) { - modelChanged(); - } - - @Override - public void serverChanged(GlusterServer server, Event event) { - modelChanged(); - } - - @Override - public void volumeChanged(Volume volume, Event event) { - modelChanged(); - } - - @Override - public void discoveredServerAdded(Server server) { - modelChanged(); - } - - @Override - public void discoveredServerRemoved(Server server) { - modelChanged(); - } - - @Override - public void volumeCreated(Volume volume) { - modelChanged(); - } - - @Override - public void volumeDeleted(Volume volume) { - modelChanged(); - } - - - @Override - public void taskAdded(TaskInfo taskInfo) { - modelChanged(); - } - - - @Override - public void taskRemoved(TaskInfo taskInfo) { - modelChanged(); - } - - - @Override - public void taskUpdated(TaskInfo taskInfo) { - modelChanged(); - } - - /** - * This method is called by every other event method. Thus, if a view/listener is interested in performing the same - * task on any change happening in the data model, it can simply override this method and implement the - * logic. e.g. A view may simply refresh its tree/table viewer whenever the data model changes. - */ - public void modelChanged() { - - } - - @Override - public void discoveredServerChanged(Server server, Event event) { - modelChanged(); - } - - @Override - public void alertsGenerated() { - modelChanged(); - } - - @Override - public void aggregatedStatsChanged() { - modelChanged(); - } - - @Override - public void alertRemoved(Alert alert) { - modelChanged(); - } - - @Override - public void alertCreated(Alert alert) { - modelChanged(); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java deleted file mode 100644 index b0de9aa7..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Device.java +++ /dev/null @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.utils.StringUtil; - - -/** - * - */ -public class Device extends Entity { - public enum DEVICE_STATUS { - //TODO: Status "READY" to be removed after python script is changed accordingly - INITIALIZED, UNINITIALIZED, INITIALIZING, IO_ERROR, UNKNOWN - }; - - public enum DEVICE_TYPE { - DATA, BOOT, SWAP, UNKNOWN - }; - - private static final String[] DEVICE_STATUS_STR = { "Initialized", "Uninitialized", "Initializing", "I/O Error", "Unknown" }; - private static final String[] DEVICE_TYPE_STR = { "Data", "Boot", "Swap", "Unknown" }; - - // type = data, boot, other - private DEVICE_TYPE type; - - private String fsType; - private String fsVersion; - - private String serverName; - private String mountPoint; - - private Double space = 0.0; - private Double spaceInUse = 0.0; - private DEVICE_STATUS status; - - public Device() { - } - - public Device(Server server, String name, String mountPoint, Double space, Double spaceInUse, DEVICE_STATUS status) { - super(name, server); - setServerName(server != null ? server.getName() : ""); - setMountPoint(mountPoint); - setSpace(space); - setSpaceInUse(spaceInUse); - setStatus(status); - } - - @XmlElement(name="size") - public Double getSpace() { - return space; - } - - public Double getFreeSpace() { - return (getSpace() - getSpaceInUse()); - } - - public void setSpace(Double space) { - this.space = space; - } - - public boolean isUninitialized() { - return getStatus() == DEVICE_STATUS.UNINITIALIZED; - } - - public boolean hasErrors() { - return getStatus() == DEVICE_STATUS.IO_ERROR; - } - - public boolean isInitialized() { - return getStatus() == DEVICE_STATUS.INITIALIZED; - } - - public boolean isReady() { - return (getStatus() == DEVICE_STATUS.INITIALIZED && getType() == DEVICE_TYPE.DATA); - } - - public DEVICE_STATUS getStatus() { - return status; - } - - public String getStatusStr() { - if (getStatus() == null) { - // Return as Unknown - return DEVICE_STATUS_STR[DEVICE_STATUS.UNKNOWN.ordinal()]; - } - - if(isReady()) { - return "Available"; - } - return DEVICE_STATUS_STR[getStatus().ordinal()]; - } - - public void setStatus(DEVICE_STATUS status) { - this.status = status; - } - - public Double getSpaceInUse() { - return spaceInUse; - } - - public void setSpaceInUse(Double spaceInUse) { - this.spaceInUse = spaceInUse; - } - - @XmlTransient - public String getServerName() { - return serverName; - } - - public void setServerName(String serverName) { - this.serverName = serverName; - } - - public void setMountPoint(String mountPoint) { - this.mountPoint = mountPoint; - } - - public String getMountPoint() { - return mountPoint; - } - - public DEVICE_TYPE getType() { - return type; - } - - public String getTypeStr() { - return DEVICE_TYPE_STR[type.ordinal()]; - } - - public void setType(DEVICE_TYPE diskType) { - this.type = diskType; - } - - public String getFsType() { - return fsType; - } - - public void setFsType(String fsType) { - this.fsType = fsType; - } - - public String getFsVersion() { - return fsVersion; - } - - public void setFsVersion(String fsVersion) { - this.fsVersion = fsVersion; - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getServerName() + getName() + getStatusStr() + getSpace() + getFreeSpace() - + getType(), filterString, caseSensitive); - } - - public String getQualifiedName() { - return getServerName() + ":" + getName(); - } - - public String getQualifiedBrickName(String volumeName) { - return getServerName() + ":" + getMountPoint() + "/" + volumeName; - } - - @Override - public boolean equals(Object obj) { - if(this == obj) { - return true; - } - - if(!(obj instanceof Device)) { - return false; - } - - Device device = (Device)obj; - - String oldMountPoint = (getMountPoint() == null ? "" : getMountPoint()); - String oldFsType = (getFsType() == null ? "" : getFsType()); - String oldFsVersion = (getFsVersion() == null ? "" : getFsVersion()); - - String newMountPoint = (device.getMountPoint() == null ? "" : getMountPoint()); - String newFsType = (device.getFsType() == null ? "" : getFsType()); - String newFsVersion = (device.getFsVersion() == null ? "" : getFsVersion()); - - if (getName().equals(device.getName()) && getServerName().equals(device.getServerName()) - && oldMountPoint.equals(newMountPoint) && getStatus() == device.getStatus() - && getSpace().equals(device.getSpace()) && getSpaceInUse().equals(device.getSpaceInUse()) - && oldFsType.equals(newFsType) && oldFsVersion.equals(newFsVersion) - && getType() == device.getType()) { - return true; - } - - return false; - } - - public void copyFrom(Device newDevice) { - setName(newDevice.getName()); - setParent(newDevice.getParent()); - setMountPoint(newDevice.getMountPoint()); - setServerName(newDevice.getServerName()); - setStatus(newDevice.getStatus()); - setFsType(newDevice.getFsType()); - setType(newDevice.getType()); - setFsVersion(newDevice.getFsVersion()); - setSpace(newDevice.getSpace()); - setSpaceInUse(newDevice.getSpaceInUse()); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java deleted file mode 100644 index 93485926..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Disk.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.Collection; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement(name="disk") -public class Disk extends Device { - private String description; - - // interface = pci, raid0, raid3, etc - private String diskInterface; - - private Collection partitions = new ArrayList(); - - // In case of a software raid, the disk will contain an array of other disks - private Collection raidDisks; - - public Disk() { - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDescription() { - return description; - } - - @XmlElement(name="interface") - public String getDiskInterface() { - return diskInterface; - } - - public void setDiskInterface(String diskInterface) { - this.diskInterface = diskInterface; - } - - @XmlElementWrapper(name="raidDisks") - @XmlElement(name="disk", type=Disk.class) - public Collection getRaidDisks() { - return raidDisks; - } - - public void setRaidDisks(Collection raidDisks) { - this.raidDisks = raidDisks; - } - - public void setPartitions(Collection partitions) { - this.partitions = partitions; - } - - @XmlElementWrapper(name="partitions") - @XmlElement(name="partition", type=Partition.class) - public Collection getPartitions() { - return partitions; - } - - public boolean hasPartitions() { - return (partitions != null && partitions.size() > 0); - } - - public Disk(Server server, String name, String mountPoint, Double space, Double spaceInUse, DEVICE_STATUS status) { - super(server, name, mountPoint, space, spaceInUse, status); - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - if (StringUtil.filterString(getServerName() + getName() + getStatusStr() + getSpace() + getFreeSpace() - + getType() + getDescription(), filterString, caseSensitive)) { - return true; - } - - // disk doesn't match. check if any of the partitions of this disk match the filter - for(Partition partition : getPartitions()) { - if(partition.filter(filterString, caseSensitive)) { - return true; - } - } - - return false; - } - - @Override - public boolean equals(Object obj) { - if(this == obj) { - return true; - } - - if(!(obj instanceof Disk)) { - return false; - } - - Disk disk = (Disk)obj; - - if (!(super.equals(obj) && getDescription().equals(disk.getDescription()) && (getDiskInterface() == disk.getDiskInterface() || getDiskInterface().equals( - disk.getDiskInterface()) ))) { - return false; - } - - if (raidDisks != null) { - for (Disk raidDisk : raidDisks) { - // check if the disk contains same raid disks - if (!(raidDisk.equals(GlusterCoreUtil.getEntity(disk.getRaidDisks(), raidDisk.getName(), false)))) { - return false; - } - } - } - -// // check if the disk contains same partitions -// if (partitions != null) { -// for (Partition partition : partitions) { -// if (!(partition.equals(GlusterCoreUtil.getEntity(disk.getPartitions(), partition.getName(), false)))) { -// return false; -// } -// } -// } - return true; - } - - public void copyFrom(Disk newDisk) { - super.copyFrom(newDisk); - setDescription(newDisk.getDescription()); - setDiskInterface(newDisk.getDiskInterface()); - setPartitions(newDisk.getPartitions()); - setRaidDisks(newDisk.getRaidDisks()); - } - - @Override - public boolean isReady() { - if (hasPartitions()) { - for (Partition partition : getPartitions()) { - if (partition.isReady()) { - return true; - } - } - return false; - } else { - return super.isReady(); - } - } - - @Override - public Double getSpace() { - Double space = 0d; - if (hasPartitions()) { - for (Partition partition : getPartitions()) { - space += partition.getSpace(); - } - return space; - } else { - return super.getSpace(); - } - } - - @Override - public Double getSpaceInUse() { - Double spaceInUse = 0d; - if (hasPartitions()) { - for (Partition partition : getPartitions()) { - if (partition.isInitialized()) { - spaceInUse += partition.getSpaceInUse(); - } - } - return spaceInUse; - } else { - return super.getSpaceInUse(); - } - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java deleted file mode 100644 index b905afc3..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Entity.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import org.eclipse.core.runtime.PlatformObject; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class Entity extends PlatformObject implements Filterable { - private static final long serialVersionUID = 1L; - - protected String name; - protected List children = new ArrayList(); - private Entity parent; - - public Entity() { - - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlTransient - public Entity getParent() { - return parent; - } - - public void setParent(Entity parent) { - this.parent = parent; - } - - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } - - public Entity(String name, Entity parent) { - this.name = name; - this.parent = parent; - } - - public Entity(String name, Entity parent, List children) { - this.name = name; - this.parent = parent; - this.children = children; - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName(), filterString, caseSensitive); - } - - @Override - public String toString() { - return name; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java deleted file mode 100644 index 8e0311f5..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/EntityGroup.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.List; - -public class EntityGroup extends Entity { - private Class type; - - public EntityGroup(String name, Class type, Cluster cluster) { - this(name, type, cluster, null); - } - - @SuppressWarnings("unchecked") - public EntityGroup(String name, Class type, Cluster cluster, List entities) { - super(name, cluster, (List)entities); - this.type = type; - } - - public List getEntities() { - return (List)children; - } - - public void setEntities(List entities) { - children = (List)entities; - } - - public Class getEntityType() { - return type; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java deleted file mode 100644 index fe7b8495..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Event.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -public class Event { - public enum EVENT_TYPE { - BRICKS_ADDED, - BRICKS_REMOVED, - BRICKS_CHANGED, - VOLUME_STATUS_CHANGED, - ALERT_CREATED, - ALERT_REMOVED, - VOLUME_OPTIONS_RESET, - VOLUME_OPTION_SET, - VOLUME_CHANGED, - GLUSTER_SERVER_CHANGED, - DEVICES_ADDED, - DEVICES_REMOVED, - DEVICES_CHANGED, - DISCOVERED_SERVER_CHANGED - } - - private EVENT_TYPE eventType; - private Object eventData; - - public Event(EVENT_TYPE eventType, Object eventData) { - this.eventType = eventType; - this.eventData = eventData; - } - - public EVENT_TYPE getEventType() { - return eventType; - } - - public void setEventType(EVENT_TYPE eventType) { - this.eventType = eventType; - } - - public Object getEventData() { - return eventData; - } - - public void setEventData(Object eventData) { - this.eventData = eventData; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java deleted file mode 100644 index 9a2ed405..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Filterable.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -/** - * By default, the {@link EntityViewerFilter} filters the objects by parsing the - * output of {@link Object#toString()} with the filter string. Classes that need - * specific filtering logic can implement this interface. The default logic will - * then be overridden by the method {@link Filterable#filter(String)}. - */ -public interface Filterable { - /** - * @param filterString - * String to be used for filtering - * @param caseSensitive - * Flag indicating whether the filtering should be case sensitive - * @return true if the object can be selected using the filter string, else - * false - */ - public boolean filter(String filterString, boolean caseSensitive); -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java deleted file mode 100644 index 733527c3..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDataModel.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -public class GlusterDataModel extends Entity { - public GlusterDataModel(String name, List clusters) { - super(name, null); - children.addAll(clusters); - } - - public GlusterDataModel(String name) { - this(name, new ArrayList()); - } - - public void setClusters(List clusters) { - children.clear(); - children.addAll(clusters); - } - - public void addCluster(Cluster cluster) { - children.add(cluster); - } - - public Cluster getCluster() { - return (Cluster) children.get(0); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java deleted file mode 100644 index 2139bbd7..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterDummyModel.java +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import com.gluster.storage.management.core.model.Device.DEVICE_STATUS; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; - -public class GlusterDummyModel { - // private Server discoveredServer1, discoveredServer2, discoveredServer3, discoveredServer4, discoveredServer5; - private GlusterServer server1, server2, server3, server4, server5; - private Volume volume1, volume2, volume3, volume4, volume5; - private Disk s1da, s1db, s2da, s2db, s2dc, s2dd, s3da, s4da, s5da, s5db; - private static List logMessages = new ArrayList(); - private static GlusterDummyModel instance = new GlusterDummyModel(); - private GlusterDataModel model; - - private GlusterDummyModel() { - model = initializeModel(); - } - - public GlusterDataModel getModel() { - return model; - } - - public static GlusterDummyModel getInstance() { - return instance; - } - - // Renamed preferredInterfaceName to interfaceName - private GlusterServer addGlusterServer(List servers, Entity parent, String name, - SERVER_STATUS status, String interfaceName, int numOfCPUs, double cpuUsage, double totalMemory, - double memoryInUse) { - GlusterServer glusterServer = new GlusterServer(name, parent, status, numOfCPUs, cpuUsage, totalMemory, - memoryInUse); - NetworkInterface networkInterface = addNetworkInterface(glusterServer, interfaceName); - - servers.add(glusterServer); - return glusterServer; - } - - private NetworkInterface addNetworkInterface(Server server, String interfaceName) { - NetworkInterface networkInterface = new NetworkInterface(interfaceName, server, "00:00:00:00", "IPV6-IN-IPV4", - "1000MB/S", "192.168.1." + Math.round(Math.random() * 255), "255.255.255.0", "192.168.1.1"); - server.setNetworkInterfaces(Arrays.asList(new NetworkInterface[] { networkInterface })); - return networkInterface; - } - - private void addDiscoveredServer(List servers, Entity parent, String name, int numOfCPUs, double cpuUsage, - double totalMemory, double memoryInUse, double totalDiskSpace, double diskSpaceInUse) { - Server server = new Server(name, parent, numOfCPUs, cpuUsage, totalMemory, memoryInUse); - server.addDisk(new Disk(server, "sda", "/export/md0", totalDiskSpace, diskSpaceInUse, DEVICE_STATUS.INITIALIZED)); - addNetworkInterface(server, "eth0"); - - servers.add(server); - } - - private GlusterDataModel initializeModel() { - // Create the dummy data model for demo - GlusterDataModel model = new GlusterDataModel("Clusters"); - Cluster cluster = new Cluster("Home", model); - - initializeGlusterServers(cluster); - initializeVolumes(cluster); - initializeAutoDiscoveredServers(cluster); - initializeDisks(); - addDisksToServers(); - addVolumeOptions(); - - createDummyLogMessages(); - - model.addCluster(cluster); - return model; - } - - private void addVolumeOptions() { - for (Volume vol : new Volume[] { volume1, volume2, volume3, volume4, volume5 }) { - for (int i = 1; i <= 5; i++) { - String key = vol.getName() + "key" + i; - String value = vol.getName() + "value" + i; - vol.setOption(key, value); - } - } - } - - private Volume addVolume(List volumes, String name, Cluster cluster, VOLUME_TYPE volumeType, - TRANSPORT_TYPE transportType, VOLUME_STATUS status) { - Volume volume = new Volume(name, cluster, volumeType, transportType, status); - volumes.add(volume); - - return volume; - } - - private void initializeVolumes(Cluster cluster) { - List volumes = new ArrayList(); - - volume1 = addVolume(volumes, "Volume1", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - - volume2 = addVolume(volumes, "Volume2", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - - volume3 = addVolume(volumes, "Volume3", cluster, VOLUME_TYPE.DISTRIBUTED_REPLICATE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.OFFLINE); - volume3.setReplicaCount(2); - - volume4 = addVolume(volumes, "Volume4", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, - VOLUME_STATUS.ONLINE); - - volume5 = addVolume(volumes, "Volume5", cluster, VOLUME_TYPE.DISTRIBUTED_STRIPE, TRANSPORT_TYPE.INFINIBAND, - VOLUME_STATUS.OFFLINE); - volume5.setStripeCount(3); - - cluster.setVolumes(volumes); - } - - private void initializeDisks() { - s1da = new Disk(server1, "sda", "/export/md0", 100d, 80d, DEVICE_STATUS.INITIALIZED); - s1db = new Disk(server1, "sdb", "/export/md1", 100d, 67.83, DEVICE_STATUS.INITIALIZED); - - s2da = new Disk(server2, "sda", "/export/md0", 200d, 157.12, DEVICE_STATUS.INITIALIZED); - s2db = new Disk(server2, "sdb", "/export/md1", 200d, 182.27, DEVICE_STATUS.INITIALIZED); - s2dc = new Disk(server2, "sdc", "/export/md0", 200d, -1d, DEVICE_STATUS.UNINITIALIZED); - s2dd = new Disk(server2, "sdd", "/export/md1", 200d, 124.89, DEVICE_STATUS.INITIALIZED); - - s4da = new Disk(server4, "sda", "/export/md0", 100d, 85.39, DEVICE_STATUS.INITIALIZED); - - s5da = new Disk(server5, "sda", "/export/md1", 100d, 92.83, DEVICE_STATUS.INITIALIZED); - s5db = new Disk(server5, "sdb", "/export/md1", 200d, 185.69, DEVICE_STATUS.INITIALIZED); - } - - private void addDisksToServers() { - server1.addDisk(s1da); - server1.addDisk(s1db); - - server2.addDisk(s2da); - server2.addDisk(s2db); - server2.addDisk(s2dc); - server2.addDisk(s2dd); - - // server3.addDisk(s3da); - - server4.addDisk(s4da); - - server5.addDisk(s5da); - server5.addDisk(s5db); - } - - private void initializeGlusterServers(Cluster cluster) { - List servers = new ArrayList(); - server1 = addGlusterServer(servers, cluster, "Server1", SERVER_STATUS.ONLINE, "eth0", 4, 56.3, 16, 8.4); - server2 = addGlusterServer(servers, cluster, "Server2", SERVER_STATUS.ONLINE, "eth1", 8, 41.92, 32, 18.76); - server3 = addGlusterServer(servers, cluster, "Server3", SERVER_STATUS.OFFLINE, "eth0", -1, -1, -1, -1); - server4 = addGlusterServer(servers, cluster, "Server4", SERVER_STATUS.ONLINE, "eth0", 1, 92.83, 4, 3.18); - server5 = addGlusterServer(servers, cluster, "Server5", SERVER_STATUS.ONLINE, "inf0", 2, 87.24, 8, 7.23); - - cluster.setServers(servers); - } - - private void initializeAutoDiscoveredServers(Cluster cluster) { - List servers = new ArrayList(); - addDiscoveredServer(servers, cluster, "ADServer1", 4, 56.3, 16, 8.4, 200, 147.83); - addDiscoveredServer(servers, cluster, "ADServer2", 8, 41.92, 32, 18.76, 800, 464.28); - addDiscoveredServer(servers, cluster, "ADServer3", 2, 84.28, 2, 1.41, 120, 69.93); - addDiscoveredServer(servers, cluster, "ADServer4", 1, 92.83, 4, 3.18, 100, 85.39); - addDiscoveredServer(servers, cluster, "ADServer5", 2, 87.24, 8, 7.23, 250, 238.52); - cluster.setAutoDiscoveredServers(servers); - } - - private void addMessages(List messages, Disk disk, String severity, int count) { - for (int i = 1; i <= count; i++) { - String message = severity + "message" + i; - messages.add(new VolumeLogMessage(new Date(), disk.getMountPoint(), severity, message)); - } - } - - private void addMessagesForDisk(List logMessages, Disk disk) { - addMessages(logMessages, disk, "SEVERE", 5); - addMessages(logMessages, disk, "WARNING", 5); - addMessages(logMessages, disk, "DEBUG", 5); - addMessages(logMessages, disk, "INFO", 5); - } - - public List createDummyLogMessages() { - addMessagesForDisk(logMessages, s1da); - addMessagesForDisk(logMessages, s1db); - addMessagesForDisk(logMessages, s2da); - addMessagesForDisk(logMessages, s2db); - addMessagesForDisk(logMessages, s2dc); - addMessagesForDisk(logMessages, s2dd); - addMessagesForDisk(logMessages, s4da); - addMessagesForDisk(logMessages, s5da); - addMessagesForDisk(logMessages, s5db); - return logMessages; - } - - public static List getDummyLogMessages() { - return logMessages; - } - - public Disk getVolumeDisk(String volumeDisk) { - List allDisks = getReadyDisksOfAllServers(); - String brickInfo[] = volumeDisk.split(":"); - for (Disk disk : allDisks) { - if (disk.getServerName() == brickInfo[0] && disk.getName() == brickInfo[1]) { - return disk; - } - } - return null; - } - - public List getReadyDisksOfAllServers() { - return getReadyDisksOfAllServersExcluding(new ArrayList()); - } - - public List getReadyDisksOfAllServersExcluding(List excludeDisks) { - List disks = new ArrayList(); - - for (Server server : ((Cluster) model.getChildren().get(0)).getServers()) { - for (Disk disk : server.getDisks()) { - if (disk.isReady() && !excludeDisks.contains(disk)) { - disks.add(disk); - } - } - } - return disks; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java deleted file mode 100644 index 9c7ac80b..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/GlusterServer.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement(name = "glusterServer") -public class GlusterServer extends Server { - private String uuid; - - public GlusterServer() { - } - - public GlusterServer(String name) { - super(name); - } - - public GlusterServer(String name, Entity parent, SERVER_STATUS status, int numOfCPUs, double cpuUsage, - double totalMemory, double memoryInUse) { - super(name, parent, numOfCPUs, cpuUsage, totalMemory, memoryInUse); - setStatus(status); - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - /** - * Filter matches if any of the properties name and status contains the filter string - */ - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName() + getStatusStr(), filterString, caseSensitive); - } - - @Override - public boolean equals(Object obj) { - if(this == obj) { - return true; - } - - if(!(obj instanceof GlusterServer)) { - return false; - } - GlusterServer server = (GlusterServer)obj; - - if (super.equals(server) && getUuid().equals(server.getUuid()) && getStatus() == server.getStatus()) { - return true; - } - - return false; - } - - public void copyFrom(GlusterServer server) { - super.copyFrom(server); - setUuid(server.getUuid()); - setStatus(server.getStatus()); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/InitDiskStatusResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/InitDiskStatusResponse.java deleted file mode 100644 index f09dfc88..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/InitDiskStatusResponse.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * InitDiskStatusResponse.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="response") -public class InitDiskStatusResponse { - - public enum FORMAT_STATUS { - IN_PROGRESS, COMPLETED, NOT_RUNNING - }; - - private String[] FORMAT_STATUS_STR = { "In Progress", "Completed", "Not Running" }; - - private String device; - private String message; - private float totalBlocks; - private float completedBlocks; - private FORMAT_STATUS formatStatus; - - public InitDiskStatusResponse() { - - } - - public void setDevice(String device) { - this.device = device; - } - - public String getDevice() { - return device; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - - public void setTotalBlocks(float totalBlocks) { - this.totalBlocks = totalBlocks; - } - - public float getTotalBlocks() { - return totalBlocks; - } - - public void setCompletedBlocks(float completedBlocks) { - this.completedBlocks = completedBlocks; - } - - public float getCompletedBlocks() { - return completedBlocks; - } - - public String getFormatStatusStr() { - return FORMAT_STATUS_STR[getFormatStatus().ordinal()]; - } - - public FORMAT_STATUS getFormatStatus() { - return formatStatus; - } - - public void setFormatStatus(FORMAT_STATUS status) { - this.formatStatus = status; - } - -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java deleted file mode 100644 index 181b8e66..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/NetworkInterface.java +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "networkInterface") -public class NetworkInterface extends Entity { - private String hwAddr; - private String model; - private String speed; - private String ipAddress; - private String netMask; - private String defaultGateway; - - public NetworkInterface() { - - } - - public NetworkInterface(String name, Entity parent, String hwAddr, String model, String speed, String ipAddress, - String netMask, String defaultGateway) { - super(name, parent); - setHwAddr(hwAddr); - setModel(model); - setSpeed(speed); - setIpAddress(ipAddress); - setNetMask(netMask); - setDefaultGateway(defaultGateway); - } - - public String getIpAddress() { - return ipAddress; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - } - - public String getNetMask() { - return netMask; - } - - public void setNetMask(String netMask) { - this.netMask = netMask; - } - - public String getDefaultGateway() { - return defaultGateway; - } - - public void setDefaultGateway(String defaultGateway) { - this.defaultGateway = defaultGateway; - } - - public String getHwAddr() { - return hwAddr; - } - - public void setHwAddr(String hwAddr) { - this.hwAddr = hwAddr; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getSpeed() { - return speed; - } - - public void setSpeed(String speed) { - this.speed = speed; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof NetworkInterface)) { - return false; - } - - NetworkInterface networkInterface = (NetworkInterface) obj; - if (getName().equals(networkInterface.getName()) && getHwAddr().equals(networkInterface.getHwAddr()) - && getIpAddress().equals(networkInterface.getIpAddress()) - && getDefaultGateway().equals(networkInterface.getDefaultGateway()) - && getNetMask().equals(networkInterface.getNetMask()) && getSpeed().equals(networkInterface.getSpeed()) - && getModel().equals(networkInterface.getModel())) { - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Partition.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Partition.java deleted file mode 100644 index ecf4035b..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Partition.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="partition") -public class Partition extends Device { - - public Partition() { - super(); - } - - public Partition(Server server, String name, String mountPoint, Double space, Double spaceInUse, - DEVICE_STATUS status) { - super(server, name, mountPoint, space, spaceInUse, status); - } - -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java deleted file mode 100644 index 96ea8497..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Response.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -/** - * Interface for server response. Any request handled by the Gluster Management - * Server will result in a response that must be an instance of a class - * implementing this interface. - */ -public interface Response { - /** - * @return Status of request processing - */ - public Status getStatus(); - - /** - * @return Data associated with the response. e.g. A "discover servers" - * request will return the list of discovered servers. - */ - public T getData(); -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java deleted file mode 100644 index 3662188c..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Server.java +++ /dev/null @@ -1,247 +0,0 @@ -/******************************************************************************* - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement(name = "server") -public class Server extends Entity { - public enum SERVER_STATUS { - ONLINE, OFFLINE - }; - - protected static final String[] STATUS_STR = new String[] { "Online", "Offline" }; - - private int numOfCPUs; - private double cpuUsage; - private double totalMemory; - private double memoryInUse; - private List disks = new ArrayList(); - private List networkInterfaces = new ArrayList(); - private SERVER_STATUS status; - - public Server() { - - } - - public Server(String name) { - super(name, null); - } - - public Server(String name, Entity parent, int numOfCPUs, double cpuUsage, double totalMemory, double memoryInUse) { - super(name, parent); - setNumOfCPUs(numOfCPUs); - setCpuUsage(cpuUsage); - setTotalMemory(totalMemory); - setMemoryInUse(memoryInUse); - } - - public int getNumOfCPUs() { - return numOfCPUs; - } - - public void setNumOfCPUs(int numOfCPUs) { - this.numOfCPUs = numOfCPUs; - } - - public double getCpuUsage() { - return cpuUsage; - } - - public void setCpuUsage(double cpuUsage) { - this.cpuUsage = cpuUsage; - } - - public double getTotalMemory() { - return totalMemory; - } - - public void setTotalMemory(double totalMemory) { - this.totalMemory = totalMemory; - } - - public double getMemoryInUse() { - return memoryInUse; - } - - public void setMemoryInUse(double memoryInUse) { - this.memoryInUse = memoryInUse; - } - - public double getTotalDiskSpace() { - double totalDiskSpace = 0; - for (Disk disk : getDisks()) { - totalDiskSpace += disk.getSpace(); - } - return totalDiskSpace; - } - - public double getDiskSpaceInUse() { - double diskSpaceInUse = 0; - for(Disk disk : getDisks()) { - if(disk.isReady()) { - diskSpaceInUse += disk.getSpaceInUse(); - } - } - return diskSpaceInUse; - } - - public double getFreeDiskSpace() { - return getTotalDiskSpace() - getDiskSpaceInUse(); - } - - @XmlElementWrapper(name = "networkInterfaces") - @XmlElement(name = "networkInterface", type = NetworkInterface.class) - public List getNetworkInterfaces() { - return networkInterfaces; - } - - public void setNetworkInterfaces(List networkInterfaces) { - this.networkInterfaces = networkInterfaces; - } - - @XmlElementWrapper(name = "disks") - @XmlElement(name = "disk", type = Disk.class) - public List getDisks() { - return disks; - } - - public void addNetworkInterface(NetworkInterface networkInterface) { - networkInterfaces.add(networkInterface); - } - - public void addDisk(Disk disk) { - disks.add(disk); - } - - public void addDisks(Collection disks) { - for (Disk disk : disks) { - addDisk(disk); - } - } - - public void removeDisk(Disk disk) { - disks.remove(disk); - } - - public void removeAllDisks() { - disks.clear(); - } - - public void setDisks(List disks) { - removeAllDisks(); - addDisks(disks); - } - - public int getNumOfDisks() { - return disks.size(); - } - - public String getIpAddressesAsString() { - String ipAddresses = ""; - for (NetworkInterface networkInterface : getNetworkInterfaces()) { - String ipAddr = networkInterface.getIpAddress(); - if(!ipAddr.equals("127.0.0.1")) { - ipAddresses += (ipAddresses.isEmpty() ? ipAddr : ", " + ipAddr); - } - } - return ipAddresses; - } - - public String getStatusStr() { - return STATUS_STR[getStatus().ordinal()]; - } - - public SERVER_STATUS getStatus() { - return status; - } - - public void setStatus(SERVER_STATUS status) { - this.status = status; - } - - public Boolean isOnline() { - return getStatus() == SERVER_STATUS.ONLINE; - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName() + getIpAddressesAsString(), filterString, caseSensitive); - } - - /** - * Note: this method doesn't copy the disks. Clients should write separate code to identify added/removed/modified - * disks and update the server disks appropriately. - * - * @param server - */ - public void copyFrom(Server server) { - setName(server.getName()); - setParent(server.getParent()); - setChildren((List) server.getChildren()); - setNetworkInterfaces(server.getNetworkInterfaces()); - setNumOfCPUs(server.getNumOfCPUs()); - setCpuUsage(server.getCpuUsage()); - setTotalMemory(server.getTotalMemory()); - setMemoryInUse(server.getMemoryInUse()); - setStatus(server.getStatus()); - } - - @Override - public boolean equals(Object obj) { - if(this == obj) { - return true; - } - - if(!(obj instanceof Server)) { - return false; - } - Server server = (Server)obj; - - if (!(getName().equals(server.getName()) && getNumOfCPUs() == server.getNumOfCPUs() - && getCpuUsage() == server.getCpuUsage() && getTotalMemory() == server.getTotalMemory() - && getMemoryInUse() == server.getMemoryInUse() && getDisks().size() == server.getDisks().size() && getNetworkInterfaces() - .size() == server.getNetworkInterfaces().size())) { - return false; - } - - for(Disk disk : getDisks()) { - if (!disk.equals(GlusterCoreUtil.getEntity(server.getDisks(), disk.getName(), false))) { - return false; - } - } - - for (NetworkInterface networkInterface : getNetworkInterfaces()) { - if (!networkInterface.equals(GlusterCoreUtil.getEntity(server.getNetworkInterfaces(), - networkInterface.getName(), false))) { - return false; - } - } - - return true; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java deleted file mode 100644 index 042af256..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - */ -@XmlRootElement(name="xport") -public class ServerStats { - private StatsMetadata metadata; - private List rows; - - public ServerStats() { - } - - public ServerStats(ServerStats newStats) { - copyFrom(newStats); - } - - public void setRows(List rows) { - this.rows = rows; - } - - @XmlElementWrapper(name="data") - @XmlElement(name="row", type=ServerStatsRow.class) - public List getRows() { - return rows; - } - - public void setMetadata(StatsMetadata metadata) { - this.metadata = metadata; - } - - @XmlElement(name="meta") - public StatsMetadata getMetadata() { - return metadata; - } - - public void copyFrom(ServerStats newStats) { - setMetadata(newStats.getMetadata()); - - List newRows = newStats.getRows(); - int rowCount = newRows.size(); - - rows = new ArrayList(rowCount); - for(ServerStatsRow newRow : newRows) { - rows.add(new ServerStatsRow(newRow)); - } - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java deleted file mode 100644 index 0088cef6..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - */ -@XmlRootElement(name="row") -public class ServerStatsRow { - private Long timestamp; - private List usageData; - - public ServerStatsRow() { - } - - public ServerStatsRow(ServerStatsRow newRow) { - copyFrom(newRow); - } - - private void copyFrom(ServerStatsRow newRow) { - setTimestamp(newRow.getTimestamp()); - - List myData = new ArrayList(newRow.getUsageData().size()); - for(Double dataElement : newRow.getUsageData()) { - myData.add(dataElement); - } - setUsageData(myData); - } - - @XmlElement(name="t") - public Long getTimestamp() { - return timestamp; - } - - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - public void setUsageData(List usageData) { - this.usageData = usageData; - } - - @XmlElement(name="v") - public List getUsageData() { - return usageData; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java deleted file mode 100644 index 22b42671..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - */ -@XmlRootElement(name="meta") -public class StatsMetadata { - private Long startTimestamp; - private Long endTimestamp; - private Integer step; - private Integer rowCount; - private List legend = new ArrayList(); - - @XmlElement(name="start") - public Long getStartTimestamp() { - return startTimestamp; - } - - public void setStartTimestamp(Long startTimestamp) { - this.startTimestamp = startTimestamp; - } - - @XmlElement(name="end") - public Long getEndTimestamp() { - return endTimestamp; - } - - public void setEndTimestamp(Long endTimestamp) { - this.endTimestamp = endTimestamp; - } - - @XmlElement(name="step") - public Integer getStep() { - return step; - } - - public void setStep(Integer step) { - this.step = step; - } - - @XmlElement(name="rows") - public Integer getRowCount() { - return rowCount; - } - - public void setRowCount(Integer rowCount) { - this.rowCount = rowCount; - } - - @XmlElementWrapper(name="legend") - @XmlElement(name="entry", type=String.class) - public List getLegend() { - return legend; - } - - public void setLegend(List legend) { - this.legend = legend; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java deleted file mode 100644 index fc824db2..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.ProcessResult; - -@XmlRootElement(name = "status") -public class Status { - // TODO: Convert the status codes to an enumeration - public static final int STATUS_CODE_SUCCESS = 0; - public static final int STATUS_CODE_FAILURE = 1; - public static final int STATUS_CODE_PART_SUCCESS = 2; - public static final int STATUS_CODE_RUNNING = 3; - public static final int STATUS_CODE_PAUSE = 4; - public static final int STATUS_CODE_WARNING = 5; - public static final int STATUS_CODE_COMMIT_PENDING = 6; - public static final Status STATUS_SUCCESS = new Status(STATUS_CODE_SUCCESS, "Success"); - public static final Status STATUS_FAILURE = new Status(STATUS_CODE_FAILURE, "Failure"); - - // public static final Status - - private Integer code; - private String message; - - public Status() { - } - - public boolean isSuccess() { - return code == STATUS_CODE_SUCCESS; - } - - public boolean isPartSuccess() { - return code == STATUS_CODE_PART_SUCCESS; - } - - public Status(Integer code, String message) { - this.code = code; - this.message = message; - } - - public Status(ProcessResult result) { - this.code = result.getExitValue(); - this.message = result.getOutput(); - } - - public Status(Exception e) { - this.code = STATUS_CODE_FAILURE; - this.message = e.getMessage(); - } - - @XmlElement(name = "code", type = Integer.class) - public Integer getCode() { - return code; - } - - public void setCode(Integer executionStatus) { - this.code = executionStatus; - } - - @XmlElement - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return isSuccess() ? "Success" : "[" + getCode() + "][" + getMessage() + "]"; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java deleted file mode 100644 index 43299863..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskInfo.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * TaskInfo.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class TaskInfo extends Entity { - public enum TASK_TYPE { - DISK_FORMAT, BRICK_MIGRATE, VOLUME_REBALANCE - } - - private TASK_TYPE type; - private String reference; - private String description; - private Boolean pauseSupported; - private Boolean stopSupported; - private Boolean commitSupported; - private TaskStatus status; - - public TaskInfo() { - } - - @XmlElement(name="id") - public String getName() { - return super.getName(); - } - - public TASK_TYPE getType() { - return type; - } - - public void setType(TASK_TYPE type) { - this.type = type; - } - - public String getReference() { - return reference; - } - - public void setReference(String reference) { - this.reference = reference; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public TaskStatus getStatus() { - return status; - } - - public void setStatus(TaskStatus status) { - this.status = status; - } - - public Boolean getPauseSupported() { - return pauseSupported; - } - - public void setPauseSupported(Boolean canPause) { - this.pauseSupported = canPause; - } - - public Boolean getStopSupported() { - return stopSupported; - } - - public void setStopSupported(Boolean canStop) { - this.stopSupported = canStop; - } - - public Boolean getCommitSupported() { - return this.commitSupported; - } - - public void setCommitSupported(Boolean canCommit) { - this.commitSupported = canCommit; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.core.model.Entity#filter(java.lang.String, boolean) - */ - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getDescription() + getStatus().getMessage(), filterString, caseSensitive); - } - - public void copyFrom(TaskInfo newTask) { - setName(newTask.getName()); - setDescription(newTask.getDescription()); - setReference(newTask.getReference()); - setStatus(newTask.getStatus()); - setType(newTask.getType()); - setPauseSupported(newTask.getPauseSupported()); - setStopSupported(newTask.getStopSupported()); - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof TaskInfo)) { - return false; - } - - TaskInfo newTask = (TaskInfo)obj; - if (newTask.getName().equals(getName()) && newTask.getDescription().equals(getDescription()) - && newTask.getReference().equals(getReference()) && newTask.getStatus().equals(getStatus()) - && newTask.getType() == getType() && newTask.getPauseSupported() == getPauseSupported() - && newTask.getStopSupported() == getStopSupported()) { - return true; - } - - return false; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java deleted file mode 100644 index 579cc9da..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/TaskStatus.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * TaskStatus.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.model; - -public class TaskStatus extends Status { - - private boolean isPercentageSupported = false; - private float percentCompleted; - private String description; - - public TaskStatus() { - - } - - public TaskStatus(Status status) { - super(status.getCode(), status.getMessage()); - } - - public boolean isCommitPending() { - return getCode() == STATUS_CODE_COMMIT_PENDING; - } - - public boolean isPercentageSupported() { - return isPercentageSupported; - } - - public void setPercentageSupported(boolean isPercentageSupported) { - this.isPercentageSupported = isPercentageSupported; - } - - public float getPercentCompleted() { - return percentCompleted; - } - - public void setPercentCompleted(float percentCompleted) { - this.percentCompleted = percentCompleted; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java deleted file mode 100644 index ed5d12f7..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/User.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -@XmlRootElement -public class User { - private String userId; - private String password; - - public String getUserId() { - return userId; - } - public void setUserId(String userId) { - this.userId = userId; - } - - @XmlTransient - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java deleted file mode 100644 index 887506a9..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Version.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -/** - * - */ -public class Version implements Comparable { - public int major = 0; - public int minor = 0; - public int maintenance = 0; - - public Version(String version) { - String[] versionParts = version.split(".", -1); - major = Integer.valueOf(versionParts[0]); - if(versionParts.length > 1) { - minor = Integer.valueOf(versionParts[1]); - } - if(versionParts.length > 2) { - maintenance = Integer.valueOf(versionParts[2]); - } - } - - @Override - public int compareTo(Version newVer) { - if(this.major < newVer.major) { - return -1; - } else if(this.major > newVer.major) { - return 1; - } - - // major version is same - if(this.minor < newVer.minor) { - return -1; - } else if(this.minor > newVer.minor) { - return 1; - } - - // major.minor is same - if(this.maintenance < newVer.maintenance) { - return -1; - } else if(this.maintenance > newVer.maintenance) { - return 1; - } - - // major.minor.maintenance is same - return 0; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java deleted file mode 100644 index 9356f14a..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java +++ /dev/null @@ -1,367 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class Volume extends Entity { - public enum VOLUME_STATUS { - ONLINE, OFFLINE - }; - - public enum VOLUME_TYPE { - DISTRIBUTE, REPLICATE, DISTRIBUTED_REPLICATE, STRIPE, DISTRIBUTED_STRIPE - }; - - public enum TRANSPORT_TYPE { - ETHERNET, INFINIBAND - }; - - public enum NAS_PROTOCOL { - GLUSTERFS, NFS, CIFS - }; - - - public static final int DEFAULT_REPLICA_COUNT = 2; - public static final int DEFAULT_STRIPE_COUNT = 4; - - public static final String OPTION_AUTH_ALLOW = "auth.allow"; - public static final String OPTION_NFS_DISABLE = "nfs.disable"; - - private static final String[] VOLUME_TYPE_STR = new String[] { "Distribute", "Replicate", "Distributed Replicate", - "Stripe", "Distributed Stripe" }; - - private static final String[] TRANSPORT_TYPE_STR = new String[] { "Ethernet", "Infiniband" }; - private static final String[] STATUS_STR = new String[] { "Online", "Offline" }; - private static final String[] NAS_PROTOCOL_STR = new String[] { "Gluster", "NFS", "CIFS" }; - - private VOLUME_TYPE volumeType; - private TRANSPORT_TYPE transportType; - private VOLUME_STATUS status; - private int replicaCount; - private int stripeCount; - private VolumeOptions options = new VolumeOptions(); - private List bricks = new ArrayList(); - private List cifsUsers; - - public Volume() { - } - - // Only GlusterFS is enabled - private Set nasProtocols = new LinkedHashSet(Arrays.asList(new NAS_PROTOCOL[] { - NAS_PROTOCOL.GLUSTERFS })); - - public String getVolumeTypeStr() { - return getVolumeTypeStr(getVolumeType()); - } - - public static String getVolumeTypeStr(VOLUME_TYPE volumeType) { - return VOLUME_TYPE_STR[volumeType.ordinal()]; - } - - public static VOLUME_TYPE getVolumeTypeByStr(String volumeTypeStr) { - return VOLUME_TYPE.valueOf(volumeTypeStr); - } - - public static TRANSPORT_TYPE getTransportTypeByStr(String transportTypeStr) { - return TRANSPORT_TYPE.valueOf(transportTypeStr); - } - - public String getTransportTypeStr() { - return TRANSPORT_TYPE_STR[getTransportType().ordinal()]; - } - - public String getStatusStr() { - return STATUS_STR[getStatus().ordinal()]; - } - - public int getNumOfBricks() { - return bricks.size(); - } - - public VOLUME_TYPE getVolumeType() { - return volumeType; - } - - public void setVolumeType(VOLUME_TYPE volumeType) { - this.volumeType = volumeType; - // TODO find a way to get the replica / strip count - if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - setReplicaCount(0); - setStripeCount(DEFAULT_STRIPE_COUNT); - } else if (volumeType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { - setReplicaCount(DEFAULT_REPLICA_COUNT); - setStripeCount(0); - } else { - setReplicaCount(0); - setStripeCount(0); - } - } - - public TRANSPORT_TYPE getTransportType() { - return transportType; - } - - public void setTransportType(TRANSPORT_TYPE transportType) { - this.transportType = transportType; - } - - public VOLUME_STATUS getStatus() { - return status; - } - - public int getReplicaCount() { - return replicaCount; - } - - public void setReplicaCount(int replicaCount) { - this.replicaCount = replicaCount; - } - - public int getStripeCount() { - return stripeCount; - } - - public void setStripeCount(int stripeCount) { - this.stripeCount = stripeCount; - } - - public void setStatus(VOLUME_STATUS status) { - this.status = status; - } - - @XmlElementWrapper(name = "nasProtocols") - @XmlElement(name = "nasProtocol", type=NAS_PROTOCOL.class) - public Set getNASProtocols() { - return nasProtocols; - } - - public void setNASProtocols(Set nasProtocols) { - this.nasProtocols = nasProtocols; - } - - public String getNASProtocolsStr() { - String protocolsStr = ""; - for (NAS_PROTOCOL protocol : nasProtocols) { - String protocolStr = NAS_PROTOCOL_STR[protocol.ordinal()]; - protocolsStr += (protocolsStr.isEmpty() ? protocolStr : ", " + protocolStr); - } - return protocolsStr; - } - - @XmlTransient - public String getAccessControlList() { - return options.get(OPTION_AUTH_ALLOW); - } - - public void setAccessControlList(String accessControlList) { - setOption(OPTION_AUTH_ALLOW, accessControlList); - } - - @XmlTransient - public boolean isNfsEnabled() { - String nfsDisabled = options.get(OPTION_NFS_DISABLE); - if(nfsDisabled == null || nfsDisabled.equalsIgnoreCase(GlusterConstants.OFF)) { - return true; - } else { - return false; - } - } - - @XmlElement(name="options") - public VolumeOptions getOptions() { - return options; - } - - public void setOption(String key, String value) { - options.put(key, value); - } - - public void setOptions(VolumeOptions options) { - this.options = options; - } - - public void setOptions(LinkedHashMap options) { - List volumeOptions = new ArrayList(); - for(Entry entry : options.entrySet()) { - volumeOptions.add(new VolumeOption(entry.getKey(), entry.getValue())); - } - this.options.setOptions(volumeOptions); - } - - public void addBrick(Brick brick) { - bricks.add(brick); - } - - public void addBricks(Collection bricks) { - this.bricks.addAll(bricks); - } - - - public void setBricks(List bricks) { - this.bricks = bricks; - } - - public void removeBrick(Brick brick) { - bricks.remove(brick); - } - - @XmlElementWrapper(name = "bricks") - @XmlElement(name = "brick", type=Brick.class) - public List getBricks() { - return bricks; - } - - public void enableNFS() { - nasProtocols.add(NAS_PROTOCOL.NFS); - setOption(OPTION_NFS_DISABLE, GlusterConstants.OFF); - } - - public void disableNFS() { - nasProtocols.remove(NAS_PROTOCOL.NFS); - setOption(OPTION_NFS_DISABLE, GlusterConstants.ON); - } - - public void enableCifs() { - if (!nasProtocols.contains(NAS_PROTOCOL.CIFS)) { - nasProtocols.add(NAS_PROTOCOL.CIFS); - } - } - - public void disableCifs() { - nasProtocols.remove(NAS_PROTOCOL.CIFS); - } - - public boolean isCifsEnable() { - return nasProtocols.contains(NAS_PROTOCOL.CIFS); - } - - public void setCifsUsers(List cifsUsers) { - this.cifsUsers = cifsUsers; - } - - public List getCifsUsers() { - return cifsUsers; - } - - - public Volume(String name, Entity parent, VOLUME_TYPE volumeType, TRANSPORT_TYPE transportType, VOLUME_STATUS status) { - super(name, parent); - setVolumeType(volumeType); - setTransportType(transportType); - setStatus(status); - } - - /** - * Filter matches if any of the properties name, volume type, transport type, status and number of disks contains - * the filter string - */ - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getName() + getVolumeTypeStr() + getTransportTypeStr() + getStatusStr() - + getNumOfBricks(), filterString, caseSensitive); - } - - public List getBrickDirectories() { - List brickDirectories = new ArrayList(); - for(Brick brick : getBricks()) { - brickDirectories.add(brick.getQualifiedName()); - } - return brickDirectories; - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof Volume)) { - return false; - } - - Volume volume = (Volume)obj; - - if (!(getName().equals(volume.getName()) && getVolumeType() == volume.getVolumeType() - && getTransportType() == volume.getTransportType() && getStatus() == volume.getStatus() - && getReplicaCount() == volume.getReplicaCount() && getStripeCount() == volume.getStripeCount() - && getOptions().equals(volume.getOptions()))) { - return false; - } - - for(NAS_PROTOCOL nasProtocol : getNASProtocols()) { - if(!(volume.getNASProtocols().contains(nasProtocol))) { - return false; - } - } - - List oldBricks = getBricks(); - List newBricks = volume.getBricks(); - if(oldBricks.size() != newBricks.size()) { - return false; - } - - if(!GlusterCoreUtil.getAddedEntities(oldBricks, newBricks, false).isEmpty()) { - return false; - } - - if(!GlusterCoreUtil.getAddedEntities(newBricks, oldBricks, false).isEmpty()) { - return false; - } - - Map modifiedBricks = GlusterCoreUtil.getModifiedEntities(oldBricks, newBricks); - if(modifiedBricks.size() > 0) { - return false; - } - - return true; - } - - /** - * Note: this method doesn't copy the bricks. Clients should write separate code to identify added/removed/modified - * bricks and update the volume bricks appropriately. - * - * @param newVolume - */ - public void copyFrom(Volume newVolume) { - setName(newVolume.getName()); - setVolumeType(newVolume.getVolumeType()); - setTransportType(newVolume.getTransportType()); - setStatus(newVolume.getStatus()); - setReplicaCount(newVolume.getReplicaCount()); - setStripeCount(newVolume.getStripeCount()); - setNASProtocols(newVolume.getNASProtocols()); - setCifsUsers(newVolume.getCifsUsers()); - getOptions().copyFrom(newVolume.getOptions()); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeLogMessage.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeLogMessage.java deleted file mode 100644 index 7b7b77c8..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeLogMessage.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.Date; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.gluster.storage.management.core.model.adapters.VolumeLogDateAdapter; -import com.gluster.storage.management.core.utils.StringUtil; - -@XmlRootElement -public class VolumeLogMessage implements Filterable { - private Date timestamp; - private String brick; - private String severity; - private String message; - - public VolumeLogMessage() { - } - - public VolumeLogMessage(String logMessage) { - // TODO: Parse the log message and extract fields - } - - @XmlElement(name = "timestamp", required = true) - @XmlJavaTypeAdapter(VolumeLogDateAdapter.class) - public Date getTimestamp() { - return timestamp; - } - - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - public String getSeverity() { - return severity; - } - - public void setSeverity(String severity) { - this.severity = severity; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public void setBrick(String brick) { - this.brick = brick; - } - - @XmlElement(name = "brick") - public String getBrick() { - return brick; - } - - public VolumeLogMessage(Date timestamp, String brickDirectory, String severity, String message) { - setTimestamp(timestamp); - setBrick(brickDirectory); - setSeverity(severity); - setMessage(message); - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getSeverity() + getTimestamp() + getBrick() + getMessage(), filterString, - caseSensitive); - } - -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java deleted file mode 100644 index 6eb0c1bf..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOption.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.utils.StringUtil; - -/** - * - */ -@XmlRootElement(name="option") -public class VolumeOption implements Filterable { - private String key; - private String value; - - public VolumeOption() { - } - - public VolumeOption(String key, String value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @Override - public String toString() { - return key + "=" + value; - } - - @Override - public boolean filter(String filterString, boolean caseSensitive) { - return StringUtil.filterString(getKey() + getValue(), filterString, caseSensitive); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java deleted file mode 100644 index 2cafc4b5..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * VolumeOptionInfo.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.model; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Class to hold information about a volume option - */ -@XmlRootElement(name = "option") -public class VolumeOptionInfo { - private String name; - private String description; - private String defaultValue; - - public VolumeOptionInfo() { - } - - public VolumeOptionInfo(String name, String description, String defaultValue) { - setName(name); - setDescription(description); - setDefaultValue(defaultValue); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java deleted file mode 100644 index edeec768..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptions.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.model; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - */ -@XmlRootElement(name="options") -public class VolumeOptions { - private List options = new ArrayList(); - - public VolumeOptions() { - } - - public String get(String key) { - for(VolumeOption option : options) { - if(option.getKey().equals(key)) { - return option.getValue(); - } - } - return null; - } - - public void put(String key, String value) { - VolumeOption option = getOption(key); - if(option != null) { - option.setValue(value); - } else { - options.add(new VolumeOption(key, value)); - } - } - - @XmlElement(name="option", type=VolumeOption.class) - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } - - public void clear() { - options.clear(); - } - - public boolean remove(String key) { - return options.remove(getOption(key)); - } - - public VolumeOption getOption(String key) { - for(VolumeOption option : options) { - if(option.getKey().equals(key)) { - return option; - } - } - return null; - } - - public int size() { - return options.size(); - } - - public boolean containsKey(String key) { - return get(key) != null; - } - - @Override - public boolean equals(Object obj) { - if(!(obj instanceof VolumeOptions)) { - return false; - } - - VolumeOptions options = (VolumeOptions)obj; - if(getOptions().size() != options.size()) { - return false; - } - - for(VolumeOption option : getOptions()) { - if(!(option.getValue().equals(options.get(option.getKey())))) { - return false; - } - } - - return true; - } - - public void copyFrom(VolumeOptions options) { - this.options.clear(); - this.options.addAll(options.getOptions()); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java deleted file mode 100644 index fac208ad..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ - -package com.gluster.storage.management.core.model.adapters; - -import java.util.Date; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import com.gluster.storage.management.core.utils.DateUtil; - -/** - * Adapter class used for converting timestamp from Gluster volume log files to Date object. - */ -public class VolumeLogDateAdapter extends XmlAdapter { - private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; - - /* (non-Javadoc) - * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) - */ - @Override - public Date unmarshal(String input) { - input = input.trim(); - if(input.length() > DATE_FORMAT.length()) { - input = input.substring(0, DATE_FORMAT.length()); - } - return DateUtil.stringToDate(input, DATE_FORMAT); - } - - /* (non-Javadoc) - * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) - */ - @Override - public String marshal(Date input) { - return DateUtil.dateToString(input, DATE_FORMAT); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/AbstractResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/AbstractResponse.java deleted file mode 100644 index 9a6a48f5..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/AbstractResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import com.gluster.storage.management.core.model.Response; -import com.gluster.storage.management.core.model.Status; - -public abstract class AbstractResponse implements Response { - private Status status; - - @Override - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ClusterNameListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ClusterNameListResponse.java deleted file mode 100644 index 3b10ac86..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ClusterNameListResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Response object for transferring cluster names during REST communication. This is just a wrapper over a list of - * Strings, and is required because the jersey rest framework can't transfer lists directly. - */ -@XmlRootElement(name="clusters") -public class ClusterNameListResponse { -private List clusterNames = new ArrayList(); - - public ClusterNameListResponse() { - } - - public ClusterNameListResponse(List clusterNames) { - this.clusterNames = clusterNames; - } - - @XmlElement(name = "cluster", type = String.class) - public List getClusterNames() { - return clusterNames; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java deleted file mode 100644 index 0235fa5f..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/FsTypeListResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * FsTypesListResponse.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.response; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "fsTypes") -public class FsTypeListResponse { - private List fsTypes; - - public FsTypeListResponse() { - } - - public FsTypeListResponse(List fsTypes) { - setFsTypes(fsTypes); - } - - @XmlElement(name = "fsType", type=String.class) - public List getFsTypes() { - return fsTypes; - } - - public void setFsTypes(List fsTypes) { - this.fsTypes = fsTypes; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java deleted file mode 100644 index 868e2fc2..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerListResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * GlusterServerListResponse.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.GlusterServer; - -/** - * - */ -@XmlRootElement(name = "servers") -public class GlusterServerListResponse { - private List servers = new ArrayList(); - - public GlusterServerListResponse() { - } - - public GlusterServerListResponse(List servers) { - setServers(servers); - } - - @XmlElement(name = "server", type=GlusterServer.class) - public List getServers() { - return servers; - } - - public void setServers(List servers) { - this.servers = servers; - } -} - diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerResponse.java deleted file mode 100644 index 7af9b240..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/GlusterServerResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.gluster.storage.management.core.response; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlTransient; - -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Status; - -@XmlRootElement(name = "response") -public class GlusterServerResponse extends AbstractResponse { - private GlusterServer glusterServer; - - public GlusterServerResponse() { - } - - public GlusterServerResponse(Status status, GlusterServer server) { - setStatus(status); - setGlusterServer(server); - } - - public GlusterServer getGlusterServer() { - return glusterServer; - } - - public void setGlusterServer(GlusterServer glusterServer) { - this.glusterServer = glusterServer; - } - - @XmlTransient - @Override - public GlusterServer getData() { - return getGlusterServer(); - } - -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/LogMessageListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/LogMessageListResponse.java deleted file mode 100644 index 8c362fa9..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/LogMessageListResponse.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - */ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.VolumeLogMessage; - -@XmlRootElement(name = "logMessages") -public class LogMessageListResponse { - private List logMessages = new ArrayList(); - - public LogMessageListResponse() { - } - - public LogMessageListResponse(List logMessages) { - setLogMessages(logMessages); - } - - @XmlElement(name = "logMessage", type = VolumeLogMessage.class) - public List getLogMessages() { - return logMessages; - } - - public void setLogMessages(List logMessages) { - this.logMessages = logMessages; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerListResponse.java deleted file mode 100644 index 05627ab1..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerListResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.Server; - -@XmlRootElement(name = "servers") -public class ServerListResponse { - private List servers = new ArrayList(); - - public ServerListResponse() { - } - - public ServerListResponse(List servers) { - setServers(servers); - } - - @XmlElement(name = "server", type=Server.class) - public List getServers() { - return servers; - } - - public void setServers(List servers) { - this.servers = servers; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerNameListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerNameListResponse.java deleted file mode 100644 index 2211f29f..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/ServerNameListResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Response object for transferring cluster names during REST communication. This is just a wrapper over a list of - * Strings, and is required because the jersey rest framework can't transfer lists directly. - */ -@XmlRootElement(name="servers") -public class ServerNameListResponse { -private List serverNames = new ArrayList(); - - public ServerNameListResponse() { - } - - public ServerNameListResponse(List serverNames) { - this.serverNames = serverNames; - } - - @XmlElement(name = "server", type = String.class) - public List getServerNames() { - return serverNames; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/StringListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/StringListResponse.java deleted file mode 100644 index 785c6efb..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/StringListResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.Status; - -@XmlRootElement(name = "response") -public class StringListResponse extends AbstractResponse { - private List data = new ArrayList(); - - public StringListResponse() { - } - - public StringListResponse(List data) { - this.data = data; - setStatus(Status.STATUS_SUCCESS); - } - - @Override - @XmlElementWrapper(name = "list") - @XmlElement(name = "value", type = String.class) - public List getData() { - return data; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskIdResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskIdResponse.java deleted file mode 100644 index f2610104..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskIdResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - */ -@XmlRootElement(name="task") -public class TaskIdResponse { - private String id; - - public TaskIdResponse() { - } - - public TaskIdResponse(String id) { - setId(id); - } - - public void setId(String id) { - this.id = id; - } - - @XmlElement(name="id") - public String getId() { - return id; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskInfoListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskInfoListResponse.java deleted file mode 100644 index ba1c4f9f..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskInfoListResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * TaskListResponse.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.TaskInfo; - -@XmlRootElement(name = "tasks") -public class TaskInfoListResponse { - private List taskInfoList = new ArrayList(); - - public TaskInfoListResponse() { - - } - - public TaskInfoListResponse(List taskInfoList) { - this.taskInfoList = taskInfoList; - } - - @XmlElement(name="task", type=TaskInfo.class) - public List getTaskList() { - return taskInfoList; - } - - public void setTaskList(List taskInfoList) { - this.taskInfoList = taskInfoList; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java deleted file mode 100755 index a11c9903..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/TaskResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * TaskInfoResponse.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.response; - -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; - -@XmlRootElement(name = "response") -public class TaskResponse extends AbstractResponse { - private TaskInfo taskInfo; - private Status status; - - public TaskResponse() { - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public void setData(TaskInfo taskInfo) { - this.taskInfo = taskInfo; - } - - @Override - public TaskInfo getData() { - return taskInfo; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeListResponse.java deleted file mode 100644 index 6518f0d5..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeListResponse.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.Volume; - -@XmlRootElement(name = "volumes") -public class VolumeListResponse { - private List volumes = new ArrayList(); - - public VolumeListResponse() { - - } - - public VolumeListResponse(List volumes) { - setVolumes(volumes); - } - - @XmlElement(name = "volume", type = Volume.class) - public List getVolumes() { - return this.volumes; - } - - public void setVolumes(List volumes) { - this.volumes = volumes; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java deleted file mode 100644 index dfacf19f..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.response; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.gluster.storage.management.core.model.VolumeOptionInfo; - -@XmlRootElement(name = "options") -public class VolumeOptionInfoListResponse { - private List options = new ArrayList(); - - public VolumeOptionInfoListResponse() { - } - - @XmlElement(name = "option", type=VolumeOptionInfo.class) - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java deleted file mode 100644 index 5fd9ae8b..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/DateUtil.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -public class DateUtil { - - /** - * Formats given date in pure date format (without time component) using default format - * {@link CoreConstants#PURE_DATE_FORMAT} - * - * @param inputDate - * Date to be formatted - * @return Formatted String representation of the given date - */ - public static final String formatDate(Date inputDate) { - return dateToString(inputDate, CoreConstants.PURE_DATE_FORMAT); - } - - /** - * Formats given date in pure time format (without date component) using default format - * {@link CoreConstants#PURE_TIME_FORMAT} - * - * @param inputDate - * Date to be formatted - * @return Formatted String representation of the given date - */ - public static final String formatTime(Date inputDate) { - return dateToString(inputDate, CoreConstants.PURE_TIME_FORMAT); - } - - /** - * Converts given date object to string by formatting it in given format - * - * @param date - * Date to be formatted - * @param dateFormat - * Date format - * @return String representation of the given Date - */ - public static final String dateToString(Date date, String dateFormat) { - SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat); - return dateFormatter.format(date); - } - - /** - * Converts given date object to string by formatting it using default date format - * {@link CoreConstants#DATE_WITH_TIME_FORMAT} - * - * @param date - * Date to be formatted - * @param dateFormat - * Date format - * @return String representation of the given Date - */ - public static final String dateToString(Date date) { - return dateToString(date, CoreConstants.DATE_WITH_TIME_FORMAT); - } - - /** - * Converts given string to date using the given date format - * - * @param input - * Input string - * @param dateFormat - * The date format to be used - * @return Date object - */ - public static final Date stringToDate(String input, String dateFormat) { - try { - SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat); - return dateFormatter.parse(input); - } catch (ParseException e) { - throw new GlusterRuntimeException("Error trying to parse string [" + input + "] in to date using format [" - + dateFormat + "]", e); - } - } - - /** - * Converts given string to date using the default date format {@link CoreConstants#DATE_WITH_TIME_FORMAT} - * - * @param input - * Input string - * @return Date object - */ - public static final Date stringToDate(String input) { - return stringToDate(input, CoreConstants.DATE_WITH_TIME_FORMAT); - } - - public static final Date getDate(int year, int month, int day, int hour, int min, int sec, int msec) { - Calendar calendar = Calendar.getInstance(); - calendar.set(year, month-1, day, hour, min, sec); - calendar.set(Calendar.MILLISECOND, msec); - return calendar.getTime(); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java deleted file mode 100644 index 601a3790..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/FileUtil.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.util.UUID; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -public class FileUtil { - public static String readFileAsString(File file) { - try { - return new String(readFileAsByteArray(file), CoreConstants.ENCODING_UTF8); - } catch (Exception e) { - e.printStackTrace(); - throw new GlusterRuntimeException("Could not read file [" + file + "]", e); - } - } - - public static byte[] readFileAsByteArray(File file) { - try { - FileInputStream fileInputStream = new FileInputStream(file); - byte[] data = new byte[fileInputStream.available()]; - fileInputStream.read(data); - fileInputStream.close(); - return data; - } catch (Exception e) { - throw new GlusterRuntimeException("Exception while reading file [" + file.getName() + "]: " - + e.getMessage(), e); - } - } - - public static void createTextFile(String fileName, String contents) { - try { - FileWriter writer = new FileWriter(fileName); - writer.write(contents); - writer.close(); - } catch (Exception e) { - throw new GlusterRuntimeException("Exception while trying to create text file [" + fileName + "]", e); - } - } - - public static String getTempDirName() { - return System.getProperty("java.io.tmpdir"); - } - - /** - * Create a new temporary directory. Use something like - * {@link #recursiveDelete(File)} to clean this directory up since it isn't - * deleted automatically - * @return the new directory - * @throws IOException if there is an error creating the temporary directory - */ - public static File createTempDir() - { - final File sysTempDir = new File(getTempDirName()); - File newTempDir; - final int maxAttempts = 9; - int attemptCount = 0; - do - { - attemptCount++; - if(attemptCount > maxAttempts) - { - throw new GlusterRuntimeException( - "The highly improbable has occurred! Failed to " + - "create a unique temporary directory after " + - maxAttempts + " attempts."); - } - String dirName = UUID.randomUUID().toString(); - newTempDir = new File(sysTempDir, dirName); - } while(newTempDir.exists()); - - if(newTempDir.mkdirs()) - { - return newTempDir; - } - else - { - throw new GlusterRuntimeException( - "Failed to create temp dir named " + - newTempDir.getAbsolutePath()); - } - } - - /** - * Recursively delete file or directory - * - * @param fileOrDir - * the file or dir to delete - * @return true if all files are successfully deleted - */ - public static void recursiveDelete(File fileOrDir) - { - if(fileOrDir.isDirectory()) - { - // recursively delete contents - for(File innerFile: fileOrDir.listFiles()) - { - recursiveDelete(innerFile); - } - } - - if(!fileOrDir.delete()) { - throw new GlusterRuntimeException("Couldn't delete file/directory [" + fileOrDir + "]"); - } - } - - public static void renameFile(String fromPath, String toPath) { - File fromFile = new File(fromPath); - File toFile = new File(toPath); - - if(!fromFile.renameTo(toFile)) { - throw new GlusterRuntimeException("Couldn't rename [" + fromFile + "] to [" + toFile + "]"); - } - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java deleted file mode 100644 index 39794b79..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterCoreUtil.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * GlusterCoreUtil.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Disk; -import com.gluster.storage.management.core.model.Entity; -import com.gluster.storage.management.core.model.Partition; -import com.gluster.storage.management.core.model.Server; - - -public class GlusterCoreUtil { - // Convert from Disk list to Qualified disk name list - public static final List getQualifiedDiskNames(List diskList) { - List qualifiedDiskNames = new ArrayList(); - for (Disk disk : diskList) { - qualifiedDiskNames.add(disk.getQualifiedName()); - } - return qualifiedDiskNames; - } - - public static final List getQualifiedBrickList(Set bricks) { - List qualifiedBricks = new ArrayList(); - for (Brick brick : bricks) { - qualifiedBricks.add(brick.getQualifiedName()); - } - return qualifiedBricks; - } - - /** - * Compares the two entity lists and returns the list of entities from first list that have been modified in the second - * - * @param oldEntities - * @param newEntities - * @return List of entities that have been modified - */ - public static Map getModifiedEntities(List oldEntities, List newEntities) { - Map modifiedEntities = new HashMap(); - for (T oldEntity : oldEntities) { - T newEntity = getEntity(newEntities, oldEntity.getName(), false); - if(newEntity != null && !oldEntity.equals(newEntity)) { - // old and new entities differ. mark it as modified. - modifiedEntities.put(oldEntity, newEntity); - } - } - return modifiedEntities; - } - - /** - * Compares the two entity lists and returns the list of entities present only in the second argument - * newEntities - * - * @param oldEntities - * @param newEntities - * @param caseInsensitive If true, the entity name comparison will be done in case insensitive manner - * @return List of entities that are present only in the second argument newEntities - */ - public static Set getAddedEntities(List oldEntities, List newEntities, - boolean caseInsensitive) { - Set addedEntities = new HashSet(); - for (T newEntity : newEntities) { - if (!containsEntity(oldEntities, newEntity, caseInsensitive)) { - // old entity list doesn't contain this entity. mark it as new. - addedEntities.add(newEntity); - } - } - return addedEntities; - } - - public static boolean containsEntity(List entityList, Entity searchEntity, - boolean caseInsensitive) { - return getEntity(entityList, searchEntity.getName(), caseInsensitive) != null; - } - - public static boolean containsEntityWithName(List entityList, String searchName, - boolean caseInsensitive) { - return getEntity(entityList, searchName, caseInsensitive) != null; - } - - public static T getEntity(Collection entityList, String searchEntityName, boolean caseInsensitive) { - for (T entity : entityList) { - String nextEntityName = entity.getName(); - if (nextEntityName.equals(searchEntityName) - || (caseInsensitive && nextEntityName.equalsIgnoreCase(searchEntityName))) { - return entity; - } - } - - return null; - } - - public static void updateServerNameOnDevices(Server server) { - String serverName = server.getName(); - for(Disk disk : server.getDisks()) { - disk.setServerName(serverName); - - if (disk.getRaidDisks() != null) { - for (Disk raidDisk : disk.getRaidDisks()) { - raidDisk.setServerName(serverName); - } - } - - if (disk.getPartitions() != null) { - for (Partition partition : disk.getPartitions()) { - partition.setServerName(serverName); - } - } - } - } - - /** - * Skips (removes) the entities from given list till (including) the given {@code tillServer}, upto a maximum of - * {@code maxCount} entities
    - * - * @param entities - * List of entities to be pruned - * @param maxCount - * Maximum number of entities to be returned - * @param tillEntity - * A list of entities after skipping the ones appearing before, and including {@code tillEntity}. If the - * resulting list is bigger than {@code maxCount}, then the first {@code maxCount} number of entities - * will be returned. - */ - public static List skipEntities(List entities, Integer maxCount, String tillEntity) { - List servers = skipEntitiesTill(entities, tillEntity); - return skipEntitiesByMaxCount(servers, maxCount); - } - - /** - * Removes extra entities from given list to return the first (or maximum of) {@code maxCount} entities
    - * - * @param entities - * List of entities to be pruned - * @param maxCount - * Maximum number of entities to be returned - * @param tillEntity - * the first (or a maximum of) {@code maxCount} entities from the given list - */ - public static List skipEntitiesByMaxCount(List entities, Integer maxCount) { - if(maxCount == null || maxCount <= 0 || maxCount > entities.size()) { - return entities; - } - - return entities.subList(0, maxCount); - } - - /** - * Skips (removes) the entities from given list till (including) the given entity.
    - * - * @param entities - * List of entities to be pruned - * @param tillEntity - * A list of entities after skipping the ones appearing before, and including {@code tillEntity} - */ - public static List skipEntitiesTill(List entities, String tillEntity) { - if(tillEntity == null) { - return entities; - } - - int index = indexOfEntity(entities, tillEntity); - if(index == -1) { - // given entity not found. return an empty list. - return new ArrayList(); - } else { - return entities.subList(index + 1, entities.size()); - } - } - - public static int indexOfEntity(List entities, String entityName) { - int index = -1; - for(int i = 0; i < entities.size(); i++) { - if(entities.get(i).getName().equalsIgnoreCase(entityName)) { - index = i; - break; - } - } - return index; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/JavaUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/JavaUtil.java deleted file mode 100644 index fe2fc860..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/JavaUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import java.util.List; - -/** - * - */ -public class JavaUtil { - @SuppressWarnings("rawtypes") - public static boolean listsDiffer(List list1, List list2) { - if(list1.size() != list2.size()) { - return true; - } - - for(Object obj : list1) { - if(!list2.contains(obj)) { - return true; - } - } - - return false; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/LRUCache.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/LRUCache.java deleted file mode 100644 index f3c9c72d..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/LRUCache.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * LRUCache.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.core.utils; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * An LRU cache, based on LinkedHashMap. - *

    - * This cache has a fixed maximum number of elements (cacheSize). If the cache is full and another entry is - * added, the LRU (least recently used) entry is dropped. - * - */ -public class LRUCache extends LinkedHashMap { - - private static final long serialVersionUID = 1L; - private static final float loadFactor = 0.75f; - private int cacheSize; - - /** - * Creates a new LRU cache. - * - * @param cacheSize - * the maximum number of entries that will be kept in this cache. - */ - public LRUCache(int cacheSize) { - super((int) Math.ceil(cacheSize / loadFactor) + 1, loadFactor, true); - this.cacheSize = cacheSize; - } - - @Override - protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > cacheSize; - } - -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java deleted file mode 100644 index e0daaf81..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5.java +++ /dev/null @@ -1,504 +0,0 @@ -/* - * MD5 in Java JDK Beta-2 - * written Santeri Paavolainen, Helsinki Finland 1996 - * (c) Santeri Paavolainen, Helsinki Finland 1996 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * See http://www.cs.hut.fi/~santtu/java/ for more information on this - * class. - * - * This is rather straight re-implementation of the reference implementation - * given in RFC1321 by RSA. - * - * Passes MD5 test suite as defined in RFC1321. - * - * - * This Java class has been derivedfrom the RSA Data Security, Inc. MD5 - * Message-Digest Algorithm and its reference implementation. - * - * - * $Log: MD5.java,v $ - * Revision 1.1 2004/07/12 13:35:20 aubryp - * initial commit - * - * Revision 1.3 2002/03/16 01:46:39 broccol - * Moved the MD5 classes into the md5 package to make 1.4 javac happy - * - * Revision 1.2 1999/11/04 21:38:00 broccol - * Got MD5Crypt calculating the same hash as the OpenBSD md5crypt.c routine. - * - * Revision 1.1 1999/08/05 22:07:03 broccol - * Added support for the MD5 classes. - * - * Revision 1.3 1996/04/15 07:28:09 santtu - * Added GPL statements, and RSA derivate statements. - * - * Revision 1.2 1996/03/04 08:05:48 santtu - * Added offsets to Update method - * - * Revision 1.1 1996/01/07 20:51:59 santtu - * Initial revision - * - */ -package com.gluster.storage.management.core.utils; - -/** - * Contains internal state of the MD5 class - * - * @author Santeri Paavolainen - */ - -class MD5State { - /** - * 128-byte state - */ - int state[]; - - /** - * 64-bit character count (could be true Java long?) - */ - int count[]; - - /** - * 64-byte buffer (512 bits) for storing to-be-hashed characters - */ - byte buffer[]; - - public MD5State() { - buffer = new byte[64]; - count = new int[2]; - state = new int[4]; - - state[0] = 0x67452301; - state[1] = 0xefcdab89; - state[2] = 0x98badcfe; - state[3] = 0x10325476; - - count[0] = count[1] = 0; - } - - /** Create this State as a copy of another state */ - public MD5State(MD5State from) { - this (); - - int i; - - for (i = 0; i < buffer.length; i++) - this .buffer[i] = from.buffer[i]; - - for (i = 0; i < state.length; i++) - this .state[i] = from.state[i]; - - for (i = 0; i < count.length; i++) - this .count[i] = from.count[i]; - } -}; - -/** - * Implementation of RSA's MD5 hash generator - * - * @version $Revision: 1.1 $ - * @author Santeri Paavolainen - */ - -public class MD5 { - /** - * MD5 state - */ - MD5State state; - - /** - * If Final() has been called, finals is set to the current finals - * state. Any Update() causes this to be set to null. - */ - MD5State finals; - - /** - * Padding for Final() - */ - static byte padding[] = { (byte) 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - /** - * Initialize MD5 internal state (object can be reused just by - * calling Init() after every Final() - */ - public synchronized void Init() { - state = new MD5State(); - finals = null; - } - - /** - * Class constructor - */ - public MD5() { - this .Init(); - } - - /** - * Initialize class, and update hash with ob.toString() - * - * @param ob Object, ob.toString() is used to update hash - * after initialization - */ - public MD5(Object ob) { - this (); - Update(ob.toString()); - } - - public String debugDump() { - return asHex(); - } - - private int rotate_left(int x, int n) { - return (x << n) | (x >>> (32 - n)); - } - - /* I wonder how many loops and hoops you'll have to go through to - get unsigned add for longs in java */ - - private int uadd(int a, int b) { - long aa, bb; - aa = ((long) a) & 0xffffffffL; - bb = ((long) b) & 0xffffffffL; - - aa += bb; - - return (int) (aa & 0xffffffffL); - } - - private int uadd(int a, int b, int c) { - return uadd(uadd(a, b), c); - } - - private int uadd(int a, int b, int c, int d) { - return uadd(uadd(a, b, c), d); - } - - private int FF(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, ((b & c) | (~b & d)), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int GG(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, ((b & d) | (c & ~d)), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int HH(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, (b ^ c ^ d), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int II(int a, int b, int c, int d, int x, int s, int ac) { - a = uadd(a, (c ^ (b | ~d)), x, ac); - return uadd(rotate_left(a, s), b); - } - - private int[] Decode(byte buffer[], int len, int shift) { - int out[]; - int i, j; - - out = new int[16]; - - for (i = j = 0; j < len; i++, j += 4) { - out[i] = ((int) (buffer[j + shift] & 0xff)) - | (((int) (buffer[j + 1 + shift] & 0xff)) << 8) - | (((int) (buffer[j + 2 + shift] & 0xff)) << 16) - | (((int) (buffer[j + 3 + shift] & 0xff)) << 24); - } - - return out; - } - - private void Transform(MD5State state, byte buffer[], int shift) { - int a = state.state[0], b = state.state[1], c = state.state[2], d = state.state[3], x[]; - - x = Decode(buffer, 64, shift); - - /* Round 1 */ - a = FF(a, b, c, d, x[0], 7, 0xd76aa478); /* 1 */ - d = FF(d, a, b, c, x[1], 12, 0xe8c7b756); /* 2 */ - c = FF(c, d, a, b, x[2], 17, 0x242070db); /* 3 */ - b = FF(b, c, d, a, x[3], 22, 0xc1bdceee); /* 4 */ - a = FF(a, b, c, d, x[4], 7, 0xf57c0faf); /* 5 */ - d = FF(d, a, b, c, x[5], 12, 0x4787c62a); /* 6 */ - c = FF(c, d, a, b, x[6], 17, 0xa8304613); /* 7 */ - b = FF(b, c, d, a, x[7], 22, 0xfd469501); /* 8 */ - a = FF(a, b, c, d, x[8], 7, 0x698098d8); /* 9 */ - d = FF(d, a, b, c, x[9], 12, 0x8b44f7af); /* 10 */ - c = FF(c, d, a, b, x[10], 17, 0xffff5bb1); /* 11 */ - b = FF(b, c, d, a, x[11], 22, 0x895cd7be); /* 12 */ - a = FF(a, b, c, d, x[12], 7, 0x6b901122); /* 13 */ - d = FF(d, a, b, c, x[13], 12, 0xfd987193); /* 14 */ - c = FF(c, d, a, b, x[14], 17, 0xa679438e); /* 15 */ - b = FF(b, c, d, a, x[15], 22, 0x49b40821); /* 16 */ - - /* Round 2 */ - a = GG(a, b, c, d, x[1], 5, 0xf61e2562); /* 17 */ - d = GG(d, a, b, c, x[6], 9, 0xc040b340); /* 18 */ - c = GG(c, d, a, b, x[11], 14, 0x265e5a51); /* 19 */ - b = GG(b, c, d, a, x[0], 20, 0xe9b6c7aa); /* 20 */ - a = GG(a, b, c, d, x[5], 5, 0xd62f105d); /* 21 */ - d = GG(d, a, b, c, x[10], 9, 0x2441453); /* 22 */ - c = GG(c, d, a, b, x[15], 14, 0xd8a1e681); /* 23 */ - b = GG(b, c, d, a, x[4], 20, 0xe7d3fbc8); /* 24 */ - a = GG(a, b, c, d, x[9], 5, 0x21e1cde6); /* 25 */ - d = GG(d, a, b, c, x[14], 9, 0xc33707d6); /* 26 */ - c = GG(c, d, a, b, x[3], 14, 0xf4d50d87); /* 27 */ - b = GG(b, c, d, a, x[8], 20, 0x455a14ed); /* 28 */ - a = GG(a, b, c, d, x[13], 5, 0xa9e3e905); /* 29 */ - d = GG(d, a, b, c, x[2], 9, 0xfcefa3f8); /* 30 */ - c = GG(c, d, a, b, x[7], 14, 0x676f02d9); /* 31 */ - b = GG(b, c, d, a, x[12], 20, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - a = HH(a, b, c, d, x[5], 4, 0xfffa3942); /* 33 */ - d = HH(d, a, b, c, x[8], 11, 0x8771f681); /* 34 */ - c = HH(c, d, a, b, x[11], 16, 0x6d9d6122); /* 35 */ - b = HH(b, c, d, a, x[14], 23, 0xfde5380c); /* 36 */ - a = HH(a, b, c, d, x[1], 4, 0xa4beea44); /* 37 */ - d = HH(d, a, b, c, x[4], 11, 0x4bdecfa9); /* 38 */ - c = HH(c, d, a, b, x[7], 16, 0xf6bb4b60); /* 39 */ - b = HH(b, c, d, a, x[10], 23, 0xbebfbc70); /* 40 */ - a = HH(a, b, c, d, x[13], 4, 0x289b7ec6); /* 41 */ - d = HH(d, a, b, c, x[0], 11, 0xeaa127fa); /* 42 */ - c = HH(c, d, a, b, x[3], 16, 0xd4ef3085); /* 43 */ - b = HH(b, c, d, a, x[6], 23, 0x4881d05); /* 44 */ - a = HH(a, b, c, d, x[9], 4, 0xd9d4d039); /* 45 */ - d = HH(d, a, b, c, x[12], 11, 0xe6db99e5); /* 46 */ - c = HH(c, d, a, b, x[15], 16, 0x1fa27cf8); /* 47 */ - b = HH(b, c, d, a, x[2], 23, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - a = II(a, b, c, d, x[0], 6, 0xf4292244); /* 49 */ - d = II(d, a, b, c, x[7], 10, 0x432aff97); /* 50 */ - c = II(c, d, a, b, x[14], 15, 0xab9423a7); /* 51 */ - b = II(b, c, d, a, x[5], 21, 0xfc93a039); /* 52 */ - a = II(a, b, c, d, x[12], 6, 0x655b59c3); /* 53 */ - d = II(d, a, b, c, x[3], 10, 0x8f0ccc92); /* 54 */ - c = II(c, d, a, b, x[10], 15, 0xffeff47d); /* 55 */ - b = II(b, c, d, a, x[1], 21, 0x85845dd1); /* 56 */ - a = II(a, b, c, d, x[8], 6, 0x6fa87e4f); /* 57 */ - d = II(d, a, b, c, x[15], 10, 0xfe2ce6e0); /* 58 */ - c = II(c, d, a, b, x[6], 15, 0xa3014314); /* 59 */ - b = II(b, c, d, a, x[13], 21, 0x4e0811a1); /* 60 */ - a = II(a, b, c, d, x[4], 6, 0xf7537e82); /* 61 */ - d = II(d, a, b, c, x[11], 10, 0xbd3af235); /* 62 */ - c = II(c, d, a, b, x[2], 15, 0x2ad7d2bb); /* 63 */ - b = II(b, c, d, a, x[9], 21, 0xeb86d391); /* 64 */ - - state.state[0] += a; - state.state[1] += b; - state.state[2] += c; - state.state[3] += d; - } - - /** - * Updates hash with the bytebuffer given (using at maximum length bytes from - * that buffer) - * - * @param stat Which state is updated - * @param buffer Array of bytes to be hashed - * @param offset Offset to buffer array - * @param length Use at maximum `length' bytes (absolute - * maximum is buffer.length) - */ - public void Update(MD5State stat, byte buffer[], int offset, - int length) { - int index, partlen, i, start; - - finals = null; - - /* Length can be told to be shorter, but not inter */ - if ((length - offset) > buffer.length) - length = buffer.length - offset; - - /* compute number of bytes mod 64 */ - index = (int) (stat.count[0] >>> 3) & 0x3f; - - if ((stat.count[0] += (length << 3)) < (length << 3)) - stat.count[1]++; - - stat.count[1] += length >>> 29; - - partlen = 64 - index; - - if (length >= partlen) { - for (i = 0; i < partlen; i++) - stat.buffer[i + index] = buffer[i + offset]; - - Transform(stat, stat.buffer, 0); - - for (i = partlen; (i + 63) < length; i += 64) - Transform(stat, buffer, i); - - index = 0; - } else - i = 0; - - /* buffer remaining input */ - if (i < length) { - start = i; - for (; i < length; i++) - stat.buffer[index + i - start] = buffer[i + offset]; - } - } - - /* - * Update()s for other datatypes than byte[] also. Update(byte[], int) - * is only the main driver. - */ - - /** - * Plain update, updates this object - */ - - public void Update(byte buffer[], int offset, int length) { - Update(this .state, buffer, offset, length); - } - - public void Update(byte buffer[], int length) { - Update(this .state, buffer, 0, length); - } - - /** - * Updates hash with given array of bytes - * - * @param buffer Array of bytes to use for updating the hash - */ - public void Update(byte buffer[]) { - Update(buffer, 0, buffer.length); - } - - /** - * Updates hash with a single byte - * - * @param b Single byte to update the hash - */ - public void Update(byte b) { - byte buffer[] = new byte[1]; - buffer[0] = b; - - Update(buffer, 1); - } - - /** - * Update buffer with given string. - * - * @param s String to be update to hash (is used as - * s.getBytes()) - */ - public void Update(String s) { - byte chars[]; - - chars = s.getBytes(); - - Update(chars, chars.length); - } - - private byte[] Encode(int input[], int len) { - int i, j; - byte out[]; - - out = new byte[len]; - - for (i = j = 0; j < len; i++, j += 4) { - out[j] = (byte) (input[i] & 0xff); - out[j + 1] = (byte) ((input[i] >>> 8) & 0xff); - out[j + 2] = (byte) ((input[i] >>> 16) & 0xff); - out[j + 3] = (byte) ((input[i] >>> 24) & 0xff); - } - - return out; - } - - /** - * Returns array of bytes (16 bytes) representing hash as of the - * current state of this object. Note: getting a hash does not - * invalidate the hash object, it only creates a copy of the real - * state which is finalized. - * - * @return Array of 16 bytes, the hash of all updated bytes - */ - public synchronized byte[] Final() { - byte bits[]; - int index, padlen; - MD5State fin; - - if (finals == null) { - fin = new MD5State(state); - - bits = Encode(fin.count, 8); - - index = (int) ((fin.count[0] >>> 3) & 0x3f); - padlen = (index < 56) ? (56 - index) : (120 - index); - - Update(fin, padding, 0, padlen); - /**/ - Update(fin, bits, 0, 8); - - /* Update() sets finalds to null */ - finals = fin; - } - - return Encode(finals.state, 16); - } - - /** - * Turns array of bytes into string representing each byte as - * unsigned hex number. - * - * @param hash Array of bytes to convert to hex-string - * @return Generated hex string - */ - public static String asHex(byte hash[]) { - StringBuffer buf = new StringBuffer(hash.length * 2); - int i; - - for (i = 0; i < hash.length; i++) { - if (((int) hash[i] & 0xff) < 0x10) - buf.append("0"); - - buf.append(Long.toString((int) hash[i] & 0xff, 16)); - } - - return buf.toString(); - } - - /** - * Returns 32-character hex representation of this objects hash - * - * @return String of this object's hash - */ - public String asHex() { - return asHex(this .Final()); - } - - /** - * One-stop md5 string encrypting. - */ - - public static String md5crypt(String input) { - MD5 md5 = new MD5(); - md5.Init(); - md5.Update(input); - return md5.asHex(); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java deleted file mode 100644 index 25c757a2..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/MD5Crypt.java +++ /dev/null @@ -1,339 +0,0 @@ -/*------------------------------------------------------------------------------ - class - MD5Crypt - ------------------------------------------------------------------------------*/ - -package com.gluster.storage.management.core.utils; - - -/** - *

    This class defines a method, - * {@link MD5Crypt#crypt(java.lang.String, java.lang.String) crypt()}, which - * takes a password and a salt string and generates an OpenBSD/FreeBSD/Linux-compatible - * md5-encoded password entry.

    - * - *

    Created: 3 November 1999

    - *

    Release: $Name: $

    - *

    Version: $Revision: 1.1 $

    - *

    Last Mod Date: $Date: 2004/07/12 13:35:20 $

    - *

    Java Code By: Jonathan Abbey, jonabbey@arlut.utexas.edu

    - *

    Original C Version:

    - * ----------------------------------------------------------------------------
    - * "THE BEER-WARE LICENSE" (Revision 42):
    - *  wrote this file.  As long as you retain this notice you
    - * can do whatever you want with this stuff. If we meet some day, and you think
    - * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
    - * ----------------------------------------------------------------------------
    - * 

    - * - * @author Jonathan Abbey - */ -public final class MD5Crypt { - - /** - * - * Command line test rig. - * - */ - - static public void main(String argv[]) { - if ((argv.length < 1) || (argv.length > 3)) { - System.err - .println("Usage: MD5Crypt [-apache] password salt"); - System.exit(1); - } - - if (argv.length == 3) { - System.err.println(MD5Crypt.apacheCrypt(argv[1], argv[2])); - } else if (argv.length == 2) { - System.err.println(MD5Crypt.crypt(argv[0], argv[1])); - } else { - System.err.println(MD5Crypt.crypt(argv[0])); - } - - System.exit(0); - } - - static private final String SALTCHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - - static private final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - - static private final String to64(long v, int size) { - StringBuffer result = new StringBuffer(); - - while (--size >= 0) { - result.append(itoa64.charAt((int) (v & 0x3f))); - v >>>= 6; - } - - return result.toString(); - } - - static private final void clearbits(byte bits[]) { - for (int i = 0; i < bits.length; i++) { - bits[i] = 0; - } - } - - /** - * convert an encoded unsigned byte value into a int - * with the unsigned value. - */ - - static private final int bytes2u(byte inp) { - return (int) inp & 0xff; - } - - /** - *

    This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible - * md5-encoded password hash from a plaintext password and a - * salt.

    - * - *

    The resulting string will be in the form '$1$<salt>$<hashed mess>

    - * - * @param password Plaintext password - * - * @return An OpenBSD/FreeBSD/Linux-compatible md5-hashed password field. - */ - - static public final String crypt(String password) { - StringBuffer salt = new StringBuffer(); - java.util.Random randgen = new java.util.Random(); - - /* -- */ - - while (salt.length() < 8) { - int index = (int) (randgen.nextFloat() * SALTCHARS.length()); - salt.append(SALTCHARS.substring(index, index + 1)); - } - - return MD5Crypt.crypt(password, salt.toString()); - } - - /** - *

    This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible - * md5-encoded password hash from a plaintext password and a - * salt.

    - * - *

    The resulting string will be in the form '$1$<salt>$<hashed mess>

    - * - * @param password Plaintext password - * @param salt A short string to use to randomize md5. May start with $1$, which - * will be ignored. It is explicitly permitted to pass a pre-existing - * MD5Crypt'ed password entry as the salt. crypt() will strip the salt - * chars out properly. - * - * @return An OpenBSD/FreeBSD/Linux-compatible md5-hashed password field. - */ - - static public final String crypt(String password, String salt) { - return MD5Crypt.crypt(password, salt, "$1$"); - } - - /** - *

    This method generates an Apache MD5 compatible - * md5-encoded password hash from a plaintext password and a - * salt.

    - * - *

    The resulting string will be in the form '$apr1$<salt>$<hashed mess>

    - * - * @param password Plaintext password - * - * @return An Apache-compatible md5-hashed password string. - */ - - static public final String apacheCrypt(String password) { - StringBuffer salt = new StringBuffer(); - java.util.Random randgen = new java.util.Random(); - - /* -- */ - - while (salt.length() < 8) { - int index = (int) (randgen.nextFloat() * SALTCHARS.length()); - salt.append(SALTCHARS.substring(index, index + 1)); - } - - return MD5Crypt.apacheCrypt(password, salt.toString()); - } - - /** - *

    This method actually generates an Apache MD5 compatible - * md5-encoded password hash from a plaintext password and a - * salt.

    - * - *

    The resulting string will be in the form '$apr1$<salt>$<hashed mess>

    - * - * @param password Plaintext password - * @param salt A short string to use to randomize md5. May start with $apr1$, which - * will be ignored. It is explicitly permitted to pass a pre-existing - * MD5Crypt'ed password entry as the salt. crypt() will strip the salt - * chars out properly. - * - * @return An Apache-compatible md5-hashed password string. - */ - - static public final String apacheCrypt(String password, String salt) { - return MD5Crypt.crypt(password, salt, "$apr1$"); - } - - /** - *

    This method actually generates md5-encoded password hash from - * a plaintext password, a salt, and a magic string.

    - * - *

    There are two magic strings that make sense to use here.. '$1$' is the - * magic string used by the FreeBSD/Linux/OpenBSD MD5Crypt algorithm, and - * '$apr1$' is the magic string used by the Apache MD5Crypt algorithm.

    - * - *

    The resulting string will be in the form '<magic><salt>$<hashed mess>

    - * - * @param password Plaintext password @param salt A short string to - * use to randomize md5. May start with the magic string, which - * will be ignored. It is explicitly permitted to pass a - * pre-existing MD5Crypt'ed password entry as the salt. crypt() - * will strip the salt chars out properly. - * - * @return An md5-hashed password string. - */ - - static public final String crypt(String password, String salt, - String magic) { - /* This string is magic for this algorithm. Having it this way, - * we can get get better later on */ - - byte finalState[]; - MD5 ctx, ctx1; - long l; - - /* -- */ - - /* Refine the Salt first */ - - /* If it starts with the magic string, then skip that */ - - if (salt.startsWith(magic)) { - salt = salt.substring(magic.length()); - } - - /* It stops at the first '$', max 8 chars */ - - if (salt.indexOf('$') != -1) { - salt = salt.substring(0, salt.indexOf('$')); - } - - if (salt.length() > 8) { - salt = salt.substring(0, 8); - } - - ctx = new MD5(); - - ctx.Update(password); // The password first, since that is what is most unknown - ctx.Update(magic); // Then our magic string - ctx.Update(salt); // Then the raw salt - - /* Then just as many characters of the MD5(pw,salt,pw) */ - - ctx1 = new MD5(); - ctx1.Update(password); - ctx1.Update(salt); - ctx1.Update(password); - finalState = ctx1.Final(); - - for (int pl = password.length(); pl > 0; pl -= 16) { - ctx.Update(finalState, pl > 16 ? 16 : pl); - } - - /* the original code claimed that finalState was being cleared - to keep dangerous bits out of memory, but doing this is also - required in order to get the right output. */ - - clearbits(finalState); - - /* Then something really weird... */ - - for (int i = password.length(); i != 0; i >>>= 1) { - if ((i & 1) != 0) { - ctx.Update(finalState, 1); - } else { - ctx.Update(password.getBytes(), 1); - } - } - - finalState = ctx.Final(); - - /* - * and now, just to make sure things don't run too fast - * On a 60 Mhz Pentium this takes 34 msec, so you would - * need 30 seconds to build a 1000 entry dictionary... - * - * (The above timings from the C version) - */ - - for (int i = 0; i < 1000; i++) { - ctx1 = new MD5(); - - if ((i & 1) != 0) { - ctx1.Update(password); - } else { - ctx1.Update(finalState, 16); - } - - if ((i % 3) != 0) { - ctx1.Update(salt); - } - - if ((i % 7) != 0) { - ctx1.Update(password); - } - - if ((i & 1) != 0) { - ctx1.Update(finalState, 16); - } else { - ctx1.Update(password); - } - - finalState = ctx1.Final(); - } - - /* Now make the output string */ - - StringBuffer result = new StringBuffer(); - - result.append(magic); - result.append(salt); - result.append("$"); - - l = (bytes2u(finalState[0]) << 16) - | (bytes2u(finalState[6]) << 8) - | bytes2u(finalState[12]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[1]) << 16) - | (bytes2u(finalState[7]) << 8) - | bytes2u(finalState[13]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[2]) << 16) - | (bytes2u(finalState[8]) << 8) - | bytes2u(finalState[14]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[3]) << 16) - | (bytes2u(finalState[9]) << 8) - | bytes2u(finalState[15]); - result.append(to64(l, 4)); - - l = (bytes2u(finalState[4]) << 16) - | (bytes2u(finalState[10]) << 8) - | bytes2u(finalState[5]); - result.append(to64(l, 4)); - - l = bytes2u(finalState[11]); - result.append(to64(l, 2)); - - /* Don't leave anything around in vm they could use. */ - clearbits(finalState); - - return result.toString(); - } -} - diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java deleted file mode 100644 index 9b1cd5e2..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/NumberUtil.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import java.text.NumberFormat; - -public class NumberUtil { - public static final String formatNumber(double num) { - NumberFormat formatter = NumberFormat.getNumberInstance(); - formatter.setMinimumFractionDigits(2); - formatter.setMaximumFractionDigits(2); - return formatter.format(num); - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java deleted file mode 100644 index c297a9c4..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Represents the result of a command execution in a separate process. Consists of the "exit status" of the process and - * output from the process. The output includes stdout as well as stderr streams - */ -@XmlRootElement -public class ProcessResult { - - public static final int SUCCESS = 0; - public static final int FAILURE = 1; - private int exitValue; - private String output; - - // Required for JAXB de-serialization - public ProcessResult() { - - } - - public ProcessResult(int exitValue, String output) { - this.exitValue = exitValue; - this.output = output; - } - - public int getExitValue() { - return exitValue; - } - - public void setExitValue(int exitValue) { - this.exitValue = exitValue; - } - - public String getOutput() { - return output; - } - - public void setOutput(String output) { - this.output = output; - } - - public boolean isSuccess() { - return exitValue == SUCCESS; - } - - @Override - public String toString() { - return "["+ getExitValue() + "][" + getOutput() + "]"; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java deleted file mode 100644 index 87c74cf0..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessUtil.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import static com.gluster.storage.management.core.constants.CoreConstants.NEWLINE; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -/** - * Utility class for creating processes (foreground/background) with given - * command and checking the output/exit status - */ -public class ProcessUtil { - - public static ProcessResult executeCommand(List command) { - return executeCommand(true, command); - } - - /** - * Waits till all the threads in given list are dead - * @param threads Threads to watch - * @throws InterruptedException - */ - public static void waitForThreads(List threads) throws InterruptedException { - // Wait till all servers have been processed - for (int i = threads.size() - 1; i >= 0; i--) { - if (threads.get(i).isAlive()) { - // thread alive. sleep for half a second and check again. - Thread.sleep(500); - i++; // check the same thread in next iteration - } - } - } - - /** - * Executes given command in a separate process in FOREGROUND - * @param command - * @return {@link ProcessResult} object - */ - public static ProcessResult executeCommand(String... command) { - ArrayList commandList = new ArrayList(); - for (String part : command) { - commandList.add(part); - } - return executeCommand(commandList); - } - - /** - * Executes given command in foreground/background - * @param runInForeground Boolean flag indicating whether the command should - * be executed in foreground - * @param command - * @return {@link ProcessResult} object - */ - public static ProcessResult executeCommand(boolean runInForeground, List command) { - StringBuilder output = new StringBuilder(); - try { - Process process = new ProcessBuilder(command).redirectErrorStream(true).start(); - if (runInForeground) { - process.waitFor(); // Wait for process to finish - - InputStream is = process.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - String line; - - while ((line = br.readLine()) != null) { - output.append(line); - output.append(NEWLINE); - } - br.close(); - isr.close(); - is.close(); - } else { - output.append("Command ["); - output.append(command); - output.append("] triggerred in background."); - } - - return new ProcessResult(process.exitValue(), output.toString()); - } catch (Throwable e) { - throw new GlusterRuntimeException("Exception while executing command [" + command + "] : [" - + e.getMessage() + "]", e); - } - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java deleted file mode 100644 index 26c244dd..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/StringUtil.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.core.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public class StringUtil { - public static boolean filterString(String sourceString, String filterString, boolean caseSensitive) { - return caseSensitive ? sourceString.contains(filterString) : sourceString.toLowerCase().contains( - filterString.toLowerCase()); - } - - public static String removeSpaces(String str) { - return str.replaceAll("\\s+", ""); - } - - public static String collectionToString(Collection list, String delimiter) { - if (list.size() == 0) { - return ""; - } - StringBuilder output = new StringBuilder(); - for (Object element : list) { - output.append(element.toString()).append(delimiter); - } - String outputStr = output.toString(); - int endIndex = outputStr.length() - delimiter.length(); - return outputStr.substring(0, endIndex); - } - - public static > List enumToArray(T[] values) { - List enumAsArray = new ArrayList(); - for (T value : values) { - enumAsArray.add(value.toString()); - } - return enumAsArray; - } - - /** - * Extracts a list from a string by splitting it on given delimiter - * @param input the input string - * @return A {@link List} of extracted tokens - */ - public static List extractList(String input, String delim) { - String[] arr = input.split(delim); - List output = new ArrayList(); - for(String str : arr) { - String brick = str.trim(); - if(!brick.isEmpty()) { - output.add(brick); - } - } - return output; - } - - /** - * Extracts a map from a string by splitting it on the given primary and secondary delimiter. e.g. The input string - * k1=v1,k2=v2,k3=v3 will yield the following map:
    - * k1 -> v1
    - * k2 -> v2
    - * k3 -> v3
    - * where , is the primary delimiter and = is the secondary delimiter. - * - * @param input - * @param majorDelim - * @param minorDelim - * @return Map of key value pairs - */ - public static Map extractMap(String input, String majorDelim, String minorDelim) { - String[] arr = input.split(majorDelim); - Map output = new LinkedHashMap(); - for(String str : arr) { - String[] elements = str.split(minorDelim); - if(elements.length == 2) { - String key = elements[0].trim(); - String value = elements[1].trim(); - if(!key.isEmpty() && !value.isEmpty()) { - output.put(key, value); - } - } - } - return output; - } - - /** - * Extract value of given token from given line. It is assumed that the token, if present, will be of the following - * form: token: value - * - * @param line - * Line to be analyzed - * @param token - * Token whose value is to be extracted - * @return Value of the token, if present in the line - */ - public static String extractToken(String line, String token) { - if (line.contains(token)) { - return line.split(token)[1].trim(); - } - return null; - } -} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java deleted file mode 100644 index df0b749a..00000000 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.gluster.storage.management.core.utils; - -import java.util.regex.Pattern; - -public class ValidationUtil { - - // Access control may contains IP with wild card(*), hostname and/or multiple ip/hostnames - public static boolean isValidAccessControl(String ac) { - String access[] = ac.split(","); - String ip; - boolean isValidAccessControl = true; - for (int i = 0; i < access.length && isValidAccessControl; i++) { - ip = access[i].trim(); - isValidAccessControl = (isValidIpWithWC(ip) || isValidHostName(ip)); - } - return isValidAccessControl; - } - - public static String getInvalidIpOrHostname(String ac) { - String access[] = ac.split(","); - String ip; - boolean isValidAccessControl = true; - for (int i = 0; i < access.length && isValidAccessControl; i++) { - ip = access[i].trim(); - if (!(isValidIpWithWC(ip) || isValidHostName(ip))) { - return access[i]; - } - } - return ""; - } - - public static boolean isValidIpWithWC(String ip) { - String ipAddress[] = ip.split("\\."); - boolean isValid = true; - - if (ip.equals("0.0.0.0") || ip.equals("255.255.255.255")) { // Invalidate the special ip's - isValid = false; - } - - int iterator=ipAddress.length-1; - - if (ipAddress.length <= 4 && ipAddress[ipAddress.length - 1].equals("*")) { - iterator = ipAddress.length - 2; - } else if (ipAddress.length < 4 || ipAddress.length > 4 ){ - isValid = false; - iterator = ipAddress.length - 1; - } - - for (int i = 0; i <= iterator && isValid; i++) { - if (ipAddress[i].equals("*")) { - isValid = (i == ipAddress.length - 1) ? isValid : false; - } else { - isValid = isValidIpQuad(ipAddress[i]); - } - } - return isValid; - } - - public static boolean isValidIp(String ip) { - String ipAddress[] = ip.split("\\."); - boolean isValid = true; - - if (ip.equals("0.0.0.0") || ip.equals("255.255.255.255")) { // Invalidate the special ip's - isValid = false; - } - if (ipAddress.length < 4) { - isValid = false; - } - for (int i = 0; i < ipAddress.length && isValid; i++) { - isValid = isValidIpQuad(ipAddress[i]); - } - return isValid; - } - - private static boolean isValidIpQuad(String ipQuad) { - Pattern pattern = Pattern.compile("([01]?\\d\\d?|2[0-4]\\d|25[0-5])"); - return pattern.matcher(ipQuad).matches(); - } - - public static boolean isValidHostName(String hostName) { - Pattern pattern = Pattern - .compile("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"); - return pattern.matcher(hostName).matches(); - } - - public static void main(String[] argv) { - String ip = "0.0.0.0"; - // System.out.println("Is valid ip (" + ip + ")? " + isValidIp(ip)); - String hostName = "myhost.q"; - // System.out.println(isValidHostName(hostName)); - // System.out.println(isValidHostName(hostName)); - System.out.println(isValidAccessControl(hostName)); - } - -} diff --git a/src/com.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch b/src/com.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch deleted file mode 100644 index 1cae618a..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/com.gluster.storage.management.gateway.scripts/.project b/src/com.gluster.storage.management.gateway.scripts/.project deleted file mode 100644 index bc0ebd63..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - com.gluster.storage.management.gateway.scripts - - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch - - - - - - org.eclipse.wst.common.project.facet.core.nature - - diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py deleted file mode 100644 index 4d1b701a..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import glob -import Globals -import Utils -import FsTabUtils - -def _stripDev(device): - if Utils.isString(device) and device.startswith("/dev/"): - return device[5:] - return device - - -def _addDev(deviceName): - if Utils.isString(deviceName) and not deviceName.startswith("/dev/"): - return "/dev/" + deviceName - return deviceName - - -def getDeviceName(device): - if type(device) == type([]): - nameList = [] - for d in device: - nameList.append(_stripDev(d)) - return nameList - return _stripDev(device) - - -def getDevice(deviceName): - if Utils.isString(deviceName): - return _addDev(deviceName) - if type(deviceName) == type([]): - nameList = [] - for d in deviceName: - nameList.append(_addDev(d)) - return nameList - return _addDev(deviceName) - - -def getDiskPartitionByUuid(uuid): - uuidFile = "/dev/disk/by-uuid/%s" % uuid - if os.path.exists(uuidFile): - return getDeviceName(os.path.realpath(uuidFile)) - return None - - -def getUuidByDiskPartition(device): - for uuidFile in glob.glob("/dev/disk/by-uuid/*"): - if os.path.realpath(uuidFile) == device: - return os.path.basename(uuidFile) - return None - - -def getDiskPartitionByLabel(label): - ## TODO: Finding needs to be enhanced - labelFile = "/dev/disk/by-label/%s" % label - if os.path.exists(labelFile): - if os.path.islink(labelFile): - return getDeviceName(os.path.realpath(labelFile)) - return None - - -def getDiskPartitionLabel(device): - rv = Utils.runCommand("e2label %s" % device, output=True, root=True) - if rv["Status"] == 0: - return rv["Stdout"].strip() - return False - - -def getDiskInfo(diskNameList=None): - procPartitionsDict = getProcPartitions() - diskDict = {} - for name, values in procPartitionsDict.iteritems(): - values["Description"] = None - values["Uuid"] = None - values["FsType"] = None - values["MountPoint"] = None - values["SpaceInUse"] = None - values["Member"] = None - ## extras ?!?! - values["Init"] = False - values["Status"] = None - values["Interface"] = None - values["DriveType"] = None - values["Type"] = None - values["FsVersion"] = None - values["ReadOnlyAccess"] = None - - device = getDevice(name) - values["Uuid"] = getUuidByDiskPartition(device) - rv = Utils.runCommand("blkid -c /dev/null -o value %s" % device, output=True, root=True) - if rv["Status"] == 0: - lines = rv["Stdout"].strip().split("\n") - values["FsType"] = lines[-1].strip() - values["MountPoint"] = getDeviceMountPoint(device) - if values["FsType"]: - values["Init"] = True - if values["MountPoint"]: - rv = Utils.runCommand(["df", values["MountPoint"]], output=True) - if rv["Status"] == 0: - try: - values["SpaceInUse"] = long(rv["Stdout"].split("\n")[1].split()[2]) - except IndexError, e: - pass - except ValueError, e: - pass - if os.path.isdir("/sys/block/%s" % name): - model = Utils.readFile("/sys/block/%s/device/model" % name) - vendor = Utils.readFile("/sys/block/%s/device/vendor" % name) - values["Description"] = "%s %s" % (model.strip(), vendor.strip()) - values["Partitions"] = {} - diskDict[name] = values - - for diskName in diskDict.keys(): - del procPartitionsDict[diskName] - for partName, values in procPartitionsDict.iteritems(): - if os.path.isdir("/sys/block/%s/%s" % (diskName, partName)): - diskDict[diskName]["Partitions"][partName] = values - - procMdstatDict = getProcMdstat() - for name, values in procMdstatDict.iteritems(): - try: - diskDict[name]["Description"] = "Software Raid Array - %s - %s" % (values["Type"], values["Status"]) - diskDict[name]["Member"] = values["Member"] - except KeyError, e: - pass - - diskNameList = getDeviceName(diskNameList) - if Utils.isString(diskNameList): - diskNameList = [diskNameList] - - if not diskNameList: - return diskDict - - outputDict = {} - for diskName in list(set(diskDict.keys()).intersection(set(diskNameList))): - outputDict[diskName] = diskDict[diskName] - return outputDict - - -def isDataDiskPartitionFormatted(device): - rv = Utils.runCommand("blkid -c /dev/null -o value %s" % device, output=True, root=True) - if rv["Status"] != 0: - return False - - uuid = getUuidByDiskPartition(device) - if not uuid: - return False - - for fsTabEntry in FsTabUtils.readFsTab(): - if fsTabEntry["Device"] == ("UUID=%s" % uuid) or fsTabEntry["Device"] == device: - return True - return False - - -def isDiskInFormatting(device): - DEVICE_FORMAT_LOCK_FILE = "/var/lock/%s.lock" % device - return os.path.exists(DEVICE_FORMAT_LOCK_FILE) - - -def getDeviceMountPoint(device): - lines = Utils.readFile("/proc/mounts", lines=True) - uuid = getUuidByDiskPartition(device) - for line in lines: - tokens = line.split() - if tokens[0] == device or (uuid and tokens[0].endswith(uuid)): - return tokens[1] - return None - -def getProcPartitions(): - procPartitionsDict = {} - s = Utils.readFile("/proc/partitions", lines=True) - for line in s[2:]: - tokens = line.strip().split() - procPartitionsDict[tokens[3]] = {"Size" : long(tokens[2])} - return procPartitionsDict - -def getProcMdstat(): - raidArrayDict = {} - lines = Utils.readFile("/proc/mdstat", lines=True) - for line in lines[1:]: - tokens = line.strip().split() - if not tokens: - continue - if tokens[0].startswith("md"): - raidArrayDict[tokens[0]] = {"Status" : tokens[2], "Type" : tokens[3], "Member" : [token.split('[')[0] for token in tokens[4:]]} - return raidArrayDict diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py deleted file mode 100644 index 653d0dda..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils -import Globals - -def readFsTab(fsTabFile=Globals.FSTAB_FILE): - lines = Utils.readFile(fsTabFile) - - fsTabEntryList = [] - for line in lines: - tokens = line.strip().split() - if not tokens or tokens[0].startswith('#'): - continue - fsTabEntry = {} - fsTabEntry["Device"] = None - fsTabEntry["MountPoint"] = None - fsTabEntry["FsType"] = None - fsTabEntry["Options"] = None - fsTabEntry["DumpOption"] = 0 - fsTabEntry["fsckOrder"] = 0 - try: - fsTabEntry["Device"] = tokens[0] - fsTabEntry["MountPoint"] = tokens[1] - fsTabEntry["FsType"] = tokens[2] - fsTabEntry["Options"] = tokens[3] - fsTabEntry["DumpOption"] = tokens[4] - fsTabEntry["fsckOrder"] = tokens[5] - except IndexError, e: - pass - if fsTabEntry["Device"] and fsTabEntry["MountPoint"] and fsTabEntry["FsType"] and fsTabEntry["Options"]: - fsTabEntryList.append(fsTabEntry) - return fsTabEntryList - -def writeFsTab(fsTabEntryList, fsTabFile=Globals.FSTAB_FILE): - try: - fsTabfp = open(fsTabFile, "w") - for fsTabEntry in fsTabEntryList: - fsTabfp.write("%s\t%s\t%s\t%s\t%s\t%s\n" % - (fsTabEntry["Device"], fsTabEntry["MountPoint"], - fsTabEntry["FsType"], fsTabEntry["Options"], - fsTabEntry["DumpOption"], fsTabEntry["fsckOrder"])) - fsTabfp.close() - except IOError, e: - log("writeFsTab(): " + str(e)) - return False - return True - -def addFsTabEntry(fsTabEntry, fsTabFile=Globals.FSTAB_FILE): - try: - fsTabfp = open(fsTabFile, "a") - fsTabfp.write("%s\t%s\t%s\t%s\t%s\t%s\n" % - (fsTabEntry["Device"], fsTabEntry["MountPoint"], - fsTabEntry["FsType"], fsTabEntry["Options"], - fsTabEntry["DumpOption"], fsTabEntry["fsckOrder"])) - fsTabfp.close() - except IOError, e: - log("addFsTabEntry(): " + str(e)) - return False - return True - -def removeFsTabEntry(fsTabEntry, fsTabFile=Globals.FSTAB_FILE): - fsTabEntryList = readFsTab(fsTabFile) - if not fsTabEntryList: - return False - - try: - fsTabEntryList.remove(fsTabEntry) - except ValueError, e: - return False - - return writeFsTab(fsTabEntryList, fsTabFile) - diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py deleted file mode 100755 index ff73af6f..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright (c) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - -def readResolvConfFile(fileName=None): - nameServerList = [] - domain = None - searchDomain = None - if not fileName: - fileName = Globals.RESOLV_CONF_FILE - lines = Utils.readFile(fileName, lines=True) - for line in lines: - tokens = line.split("#")[0].strip().split() - if len(tokens) < 2: - continue - if tokens[0].upper() == "NAMESERVER": - nameServerList.append(tokens[1]) - continue - if tokens[0].upper() == "DOMAIN": - domain = tokens[1:] - continue - if tokens[0].upper() == "SEARCH": - searchDomain = tokens[1:] - continue - return nameServerList, domain, searchDomain - - -def readIfcfgConfFile(deviceName, root=""): - conf = {} - fileName = "%s%s/ifcfg-%s" % (root, Globals.SYSCONFIG_NETWORK_DIR, deviceName) - lines = Utils.readFile(fileName, lines=True) - for line in lines: - tokens = line.split("#")[0].split("=") - if len(tokens) != 2: - continue - conf[tokens[0].strip().lower()] = tokens[1].strip() - return conf - - -def getBondMode(deviceName, fileName=None): - if not fileName: - fileName = Globals.MODPROBE_CONF_FILE - lines = Utils.readFile(fileName, lines=True) - for line in lines: - tokens = line.split("#")[0].split() - if len(tokens) < 4: - continue - if tokens[0].upper() == "OPTIONS" and tokens[1] == deviceName: - if tokens[2].startswith("mode="): - return tokens[2].split("=")[1] - if tokens[3].startswith("mode="): - return tokens[3].split("=")[1] - if tokens[4].startswith("mode="): - return tokens[4].split("=")[1] - if tokens[5].startswith("mode="): - return tokens[5].split("=")[1] - return None - - -def getNetDeviceList(root=""): - netDeviceList = {} - for deviceName in os.listdir("/sys/class/net/"): - netDevice = {} - netDevice["description"] = None - netDevice["hwaddr"] = None - netDevice["type"] = None - netDevice["onboot"] = None - netDevice["bootproto"] = None - netDevice["gateway"] = None - netDevice["peerdns"] = None - netDevice["autodns"] = None - netDevice["dns1"] = None - netDevice["dns2"] = None - netDevice["dns3"] = None - netDevice["master"] = None - netDevice["slave"] = None - netDevice["nmcontrolled"] = None - netDevice["link"] = None - netDevice["mode"] = None - netDevice["speed"] = None - netDevice["device"] = deviceName - netDevice["description"] = deviceName - netDevice["ipaddr"] = None - netDevice["netmask"] = None - netDevice["hwaddr"] = Utils.readFile("/sys/class/net/%s/address" % deviceName).strip() - - rv = Utils.runCommand("ifconfig %s" % deviceName, output=True) - if rv["Status"] == 0: - for line in rv["Stdout"].split("\n"): - if line.find("Link encap:") != -1: - netDevice["type"] = line.split("Link encap:")[1].split()[0] - continue - if line.find("inet addr:") != -1: - tokens = line.split("inet addr:")[1].split() - netDevice["ipaddr"] = tokens[0] - if line.find("Mask:") != -1: - netDevice["netmask"] = line.split("Mask:")[1].split()[0] - #print tokens[1].split(":")[1] - - rv = Utils.runCommand("ethtool %s" % deviceName, output=True, root=True) - if rv["Status"] == 0: - for line in rv["Stdout"].split("\n"): - if line.find("Speed: ") != -1: - netDevice["speed"] = line.split("Speed: ")[1].upper().split("MB")[0] - elif line.find("Link detected: ") != -1: - netDevice["link"] = line.split("Link detected: ")[1] - - rv = Utils.runCommand("route -n", output=True, root=True) - if rv["Status"] == 0: - for line in rv["Stdout"].split("\n"): - tokens = line.split() - if len(tokens) == 8 and tokens[-1] == deviceName and tokens[3] == "UG": - netDevice["gateway"] = tokens[1] - - netDevice["mode"] = getBondMode(deviceName, root + Globals.MODPROBE_CONF_FILE) - - netDeviceList[deviceName] = netDevice - - conf = readIfcfgConfFile(deviceName, root) - if not conf: - continue - try: - if not netDevice["ipaddr"]: - netDevice["ipaddr"] = conf["ipaddr"] - if not netDevice["netmask"]: - netDevice["netmask"] = conf["netmask"] - if not netDevice["gateway"]: - netDevice["gateway"] = conf["gateway"] - netDevice["onboot"] = conf["onboot"] - netDevice["bootproto"] = conf["bootproto"] - netDevice["peerdns"] = conf["peerdns"] - netDevice["autodns"] = conf["autodns"] - netDevice["dns1"] = conf["dns1"] - netDevice["dns2"] = conf["dns2"] - netDevice["dns3"] = conf["dns3"] - netDevice["master"] = conf["master"] - netDevice["slave"] = conf["slave"] - netDevice["nmcontrolled"] = conf["nmcontrolled"] - except KeyError, e: - pass - return netDeviceList diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py deleted file mode 100644 index 5476e090..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright (c) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def readVolumeSmbConfFile(fileName=Globals.VOLUME_SMBCONF_FILE): - entryList = [] - lines = Utils.readFile(fileName, lines=True) - for line in lines: - tokens = line.split("#")[0].strip().split(";")[0].strip().split("=") - if len(tokens) != 2: - continue - if tokens[0].strip().upper() == "INCLUDE": - entryList.append(tokens[1].strip()) - return entryList - - -def writeVolumeSmbConfFile(entryList, fileName=Globals.VOLUME_SMBCONF_FILE): - try: - fp = open(fileName, "w") - for entry in entryList: - fp.write("include = %s\n" % entry) - fp.close() - return True - except IOError, e: - Utils.log("Failed to write file %s: %s" % (fileName, str(e))) - return False - - -def includeVolume(volumeName, fileName=Globals.VOLUME_SMBCONF_FILE): - volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) - if not os.path.exists(volumeFile): - return False - entryList = readVolumeSmbConfFile(fileName) - if volumeFile in entryList: - return True - entryList.append(volumeFile) - return writeVolumeSmbConfFile(entryList, fileName) - - -def excludeVolume(volumeName, fileName=Globals.VOLUME_SMBCONF_FILE): - volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) - if not os.path.exists(volumeFile): - return False - entryList = readVolumeSmbConfFile(fileName) - if volumeFile not in entryList: - return True - entryList.remove(volumeFile) - Utils.log("entryList = %s" % entryList) - return writeVolumeSmbConfFile(entryList, fileName) - - -def writeVolumeCifsConfiguration(volumeName, userList, adminUser=None): - volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) - try: - fp = open(volumeFile, "w") - fp.write("[%s]\n" % volumeName) - fp.write(" comment = %s volume served by Gluster\n" % volumeName) - fp.write(" path = %s/%s\n" % (Globals.CIFS_EXPORT_DIR, volumeName)) - fp.write(" guest ok = yes\n") - fp.write(" public = yes\n") - fp.write(" writable = yes\n") - if adminUser: - fp.write(" admin users = %s, %s\n" % (adminUser, ", ".join(userList))) - fp.write(" valid users = %s, %s\n" % (adminUser, ", ".join(userList))) - else: - fp.write(" admin users = %s\n" % (", ".join(userList))) - fp.write(" valid users = %s\n" % (", ".join(userList))) - fp.close() - return True - except IOError, e: - Utils.log("Failed to write file %s: %s" % (volumeFile, str(e))) - return False - - -def removeVolumeCifsConfiguration(volumeName): - volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) - try: - os.remove(volumeFile) - return True - except OSError, e: - Utils.log("Failed to remove file %s: %s" % (volumeFile, str(e))) - return False - diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py deleted file mode 100755 index 2e1a1574..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import grp -import pwd -import Globals -import Utils - -def main(): - if len(sys.argv) < 4: - sys.stderr.write("usage: %s UID USERNAME PASSWORD\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - try: - uid = int(sys.argv[1]) - except ValueError, e: - sys.stderr.write("invalid uid %s\n" % sys.argv[1]) - sys.exit(-2) - userName = sys.argv[2] - password = sys.argv[3] - - try: - groupInfo = grp.getgrnam(userName) - if uid != groupInfo.gr_gid: - Utils.log("group %s exists with different gid %s\n" % (userName, groupInfo.gr_gid)) - sys.stderr.write("Group %s exists with different gid %s\n" % (userName, groupInfo.gr_gid)) - sys.exit(1) - except KeyError, e: - if Utils.runCommand("groupadd -g %s %s" % (uid, userName)) != 0: - Utils.log("failed to add group %s gid %s\n" % (userName, uid)) - sys.stderr.write("Failed to add group %s gid %s\n" % (userName, uid)) - sys.exit(2) - try: - userInfo = pwd.getpwnam(userName) - if uid != userInfo.pw_uid: - Utils.log("user %s exists with different uid %s\n" % (userName, userInfo.pw_uid)) - sys.stderr.write("User %s exists with different uid %s\n" % (userName, userInfo.pw_uid)) - sys.exit(3) - except KeyError, e: - command = ["useradd", "-c", Globals.VOLUME_USER_DESCRIPTION, "-M", "-d", "/", "-s", "/sbin/nologin", "-u", str(uid), "-g", str(uid), userName] - if Utils.runCommand(command) != 0: - Utils.log("failed to add user %s uid %s\n" % (userName, uid)) - sys.stderr.write("Failed to add user %s uid %s\n" % (userName, uid)) - sys.exit(4) - - if Utils.runCommand("smbpasswd -s -a %s" % userName, - input="%s\n%s\n" % (password, password)) != 0: - Utils.log("failed to set smbpassword of user %s\n" % userName) - sys.stderr.write("Failed to set smbpassword of user %s\n" % userName) - sys.exit(5) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py deleted file mode 100755 index 374a7e9c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import time -import Utils -from optparse import OptionParser - -def main(): - parser = OptionParser() - parser.add_option("-d", "--delete", dest="todelete", action="store_true", default=False, help="force delete") - (options, args) = parser.parse_args() - - if len(args) != 1: - sys.stderr.write("usage: %s [-d | --delete] VOLUME_PATH\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeDirectory = args[0] - if not os.path.exists(volumeDirectory): - sys.stderr.write("Given volume directory path:%s does not exists\n" % volumeDirectory) - sys.exit(1) - - if '/' == volumeDirectory[-1]: - volumeDirectory = volumeDirectory[:-1] - - newVolumeDirectoryName = "%s_%s" % (volumeDirectory, time.time()) - if Utils.runCommand("mv -f %s %s" % (volumeDirectory, newVolumeDirectoryName), root=True) != 0: - sys.stderr.write("Failed to rename volume directory\n") - sys.exit(2) - - if options.todelete: - process = Utils.runCommandBG("rm -fr %s" % newVolumeDirectoryName, root=True) - if not process: - sys.exit(3) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py deleted file mode 100755 index 5a27ab87..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import VolumeUtils - -def main(): - if len(sys.argv) < 3: - sys.stderr.write("usage: %s VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - userList = sys.argv[2:] - - volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) - try: - if not os.path.exists(volumeMountDirName): - os.mkdir(volumeMountDirName) - except OSError, e: - Utils.log("failed creating %s: %s\n" % (volumeMountDirName, str(e))) - sys.stderr.write("Failed creating %s: %s\n" % (volumeMountDirName, str(e))) - sys.exit(1) - - if not VolumeUtils.writeVolumeCifsConfiguration(volumeName, userList): - sys.stderr.write("Failed to write volume cifs configuration\n") - sys.exit(2) - - if Utils.runCommand("service smb reload") != 0: - Utils.log("Failed to reload smb service") - sys.stderr.write("Failed to reload smb service\n") - sys.exit(3) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py deleted file mode 100755 index aeda989f..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -def main(): - if len(sys.argv) < 2: - sys.stderr.write("usage: %s USERNAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - userName = sys.argv[1] - - if Utils.runCommand("userdel %s" % userName) != 0: - Utils.log("failed to remove user name:%s\n" % userName) - sys.stderr.write("Failed to remove user name:%s\n" % userName) - sys.exit(1) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py deleted file mode 100755 index 572d819c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import VolumeUtils - -def main(): - if len(sys.argv) != 2: - sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - - volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) - try: - os.rmdir(volumeMountDirName) - except OSError, e: - Utils.log("failed deleting %s: %s\n" % (volumeMountDirName, str(e))) - sys.stderr.write("Failed deleting %s: %s\n" % (volumeMountDirName, str(e))) - sys.exit(1) - - if VolumeUtils.removeVolumeCifsConfiguration(volumeName): - sys.exit(0) - sys.stderr.write("Unable to remove volume cifs configuration\n") - sys.exit(2) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/format_device.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/format_device.py deleted file mode 100755 index 8630635c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/format_device.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -import stat -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import DiskUtils - -SIZE_TB_16 = 17179869184L - -def main(): - if Utils.runCommand("wget -t 1 -T 1 -q -O /dev/null %s" % Globals.AWS_WEB_SERVICE_URL) == 0: - sys.stderr.write("format device unsupported\n") - sys.exit(1) - - if len(sys.argv) != 4: - sys.stderr.write("usage: %s FSTYPE MOUNT_POINT DEVICE_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - fsType = sys.argv[1] - mountPoint = sys.argv[2] - device = DiskUtils.getDevice(sys.argv[3]) - deviceName = DiskUtils.getDeviceName(sys.argv[3]) - - if not os.path.exists(device): - sys.stderr.write("device %s not found\n" % sys.argv[3]) - sys.exit(2) - - try: - if not stat.S_ISBLK(os.stat(device).st_mode): - sys.stderr.write("%s is not a block device\n" % sys.argv[3]) - sys.exit(3) - except OSError, e: - Utils.log("unable to get device %s mode: %s" % (device, str(e))) - sys.stderr.write("unable to get device %s mode\n" % sys.argv[3]) - sys.exit(-2) - - if fsType in ['ext3', 'ext4', 'ext4dev']: - deviceSize = DiskUtils.getProcPartitions()[deviceName]['Size'] - if deviceSize >= SIZE_TB_16: - Utils.log("device %s, size %s is greater than %s size for fstype %s" % (device, deviceSize, SIZE_TB_16, fsType)) - sys.stderr.write("size of device %s is unsupported for fstype %s\n" % (sys.argv[3], fsType)) - sys.exit(4) - - if DiskUtils.isDataDiskPartitionFormatted(device): - sys.stderr.write("device %s already formatted\n" % sys.argv[3]) - sys.exit(5) - - if os.path.exists(mountPoint): - if not os.path.isdir(mountPoint): - sys.stderr.write("mount point %s exists but not a directory" % mountPoint) - sys.exit(6) - procMounts = Utils.readFile("/proc/mounts") - if procMounts.find(" %s " % mountPoint) != -1: - sys.stderr.write("mount point %s already has a mount\n" % mountPoint) - sys.exit(7) - if procMounts.find(" %s/" % mountPoint) != -1: - sys.stderr.write("mount point %s has a submount\n" % mountPoint) - sys.exit(8) - else: - status = Utils.runCommand("mkdir -p %s" % mountPoint, output=True, root=True) - if status["Status"] != 0: - sys.stderr.write("failed to create mount point %s\n" % mountPoint) - sys.exit(9) - - if fsType not in Utils.getFileSystemType(): - sys.stderr.write("unsupported file system type %s\n" % fsType) - sys.exit(10) - - deviceFormatLockFile = Utils.getDeviceFormatLockFile(device) - deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) - deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) - - if os.path.exists(deviceFormatStatusFile): - Utils.log("format status file %s exists" % deviceFormatStatusFile) - line = Utils.readFile(deviceFormatStatusFile) - if not line: - sys.stderr.write("failed to read format status file %s\n" % deviceFormatStatusFile) - sys.exit(-3) - if line.strip().upper() == "COMPLETED": - sys.stderr.write("Device %s already formatted\n" % sys.argv[3]) - sys.exit(11) - else: - sys.stderr.write("Formatting device %s already running\n" % sys.argv[3]) - sys.exit(12) - - if os.path.exists(deviceFormatLockFile): - Utils.log("lock file %s exists" % deviceFormatLockFile) - sys.stderr.write("Formatting device %s already running\n" % sys.argv[3]) - sys.exit(13) - - command = ["%s/format_device_background.py" % p1, fsType, mountPoint, sys.argv[3]] - Utils.runCommandBG(command) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py deleted file mode 100755 index a804a59c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils -import FsTabUtils -import DiskUtils - -def writeStatus(deviceFormatStatusFile, message): - try: - fp = open(deviceFormatStatusFile, "w") - fp.write(message) - fp.close() - except IOError, e: - Utils.log("Failed to update log file %s: %s" % (deviceFormatStatusFile, str(e))) - return False - return True - -def main(): - if len(sys.argv) != 4: - sys.stderr.write("usage: %s FSTYPE MOUNT_POINT DEVICE_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - fsType = sys.argv[1] - mountPoint = sys.argv[2] - device = DiskUtils.getDevice(sys.argv[3]) - - deviceFormatLockFile = Utils.getDeviceFormatLockFile(device) - deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) - deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) - - if os.path.exists(deviceFormatStatusFile): - Utils.log("device format status file %s exists" % deviceFormatStatusFile) - sys.exit(1) - - if os.path.exists(deviceFormatLockFile): - Utils.log("device format lock file %s exists" % deviceFormatLockFile) - sys.exit(2) - - try: - fp = open(deviceFormatLockFile, "w") - fp.close() - except OSError, e: - Utils.log("failed to create lock file %s: %s" % (deviceFormatLockFile, str(e))) - writeStatus(deviceFormatStatusFile, "Lock file creation failed\n") - sys.exit(-2) - - try: - fptr = open(deviceFormatOutputFile, 'w') - except IOError, e: - Utils.log("failed to create output file %s" % deviceFormatOutputFile) - writeStatus(deviceFormatStatusFile, "Output file creation failed\n") - Utils.removeFile(deviceFormatLockFile) - sys.exit(-3) - - if fsType in ['ext3', 'ext4', 'ext4dev']: - command = "/sbin/mkfs.%s -F -I 512 %s" % (fsType, device) - elif fsType == "xfs": - command = "/sbin/mkfs.%s -f -i size=512 %s" % (fsType, device) - else: - command = "/sbin/mkfs.%s %s" % (fsType, device) - - status = Utils.runCommand(command, output=True, root=True) - if status["Status"] != 0: - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatLockFile) - writeStatus(deviceFormatStatusFile, "Device format failed\n") - sys.exit(3) - - if Utils.runCommand("udevadm trigger") != 0: - Utils.log("failed running udevadm trigger") - - if Utils.runCommand("/usr/bin/lshal") != 0: - Utils.log("failed running /usr/bin/lshal") - - deviceUuid = DiskUtils.getUuidByDiskPartition(device) - if not deviceUuid: - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatLockFile) - Utils.log("UUID not found after device %s formatted" % device) - writeStatus(deviceFormatStatusFile, "UUID not found after device %s formatted\n" % sys.argv[3]) - sys.exit(4) - - if DiskUtils.isDataDiskPartitionFormatted(device): - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatLockFile) - Utils.log("UUID device %s already has an entry in fstab" % device) - writeStatus(deviceFormatStatusFile, "UUID device %s already has an entry in fstab\n" % sys.argv[3]) - sys.exit(5) - - newFsTabEntry = {"Device" : "UUID=%s" % deviceUuid, - "MountPoint" : mountPoint, - "FsType" : fsType, - "Options" : "defaults", - "DumpOption" : "0", - "fsckOrder" : "2"} - if fsType in ['ext3', 'ext4', 'ext4dev']: - newFsTabEntry["Options"] = "defaults,user_xattr" - if not FsTabUtils.addFsTabEntry(newFsTabEntry): - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatLockFile) - writeStatus(deviceFormatStatusFile, "failed to update fstab") - sys.exit(6) - - status = Utils.runCommand("mount %s" % mountPoint, output=True, root=True) - if status["Status"] != 0: - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatLockFile) - Utils.log("Mounting device %s on %s failed" % (device, mountPoint)) - writeStatus(deviceFormatStatusFile, "Mounting device %s on %s failed\n" % (sys.argv[3], mountPoint)) - sys.exit(7) - - writeStatus(deviceFormatStatusFile, "Completed\n") - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatLockFile) - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py deleted file mode 100755 index b72321d7..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Console. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -def main(): - if len(sys.argv) != 3: - sys.stderr.write("usage: %s VOLUME_NAME BRICK_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - brickName = sys.argv[2] - pidFile = "/etc/glusterd/vols/%s/run/%s.pid" % (volumeName, brickName.replace(":", "").replace("/", "-")) - - if not os.path.exists(pidFile): - print "OFFLINE" - sys.exit(0) - - lines = Utils.readFile(pidFile) - if not lines: - print "UNKNOWN" - sys.exit(0) - try: - pidString = lines[0] - os.getpgid(int(pidString)) - print "ONLINE" - except ValueError, e: - Utils.log("invalid pid %s in file %s: %s" % (pidString, pidFile, str(e))) - print "UNKNOWN" - except OSError, e: - #Utils.log("failed to get process detail of pid %s: %s" % (pidString, str(e))) - print "OFFLINE" - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py deleted file mode 100755 index de4b4bb0..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -SUPPORTED_FSTYPE = ['ext3', 'ext4', 'ext4dev', 'xfs'] - -def main(): - print "\n".join(list(set(Utils.getFileSystemType()).intersection(set(SUPPORTED_FSTYPE)))) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py deleted file mode 100755 index 532f1585..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import time -import Utils -import DiskUtils -from XmlHandler import ResponseXml - -def main(): - if len(sys.argv) != 2: - sys.stderr.write("usage: %s DEVICE_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - device = DiskUtils.getDevice(sys.argv[1]) - - deviceFormatLockFile = Utils.getDeviceFormatLockFile(device) - deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) - deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) - - time.sleep(1) - if not os.path.exists(deviceFormatLockFile): - if not os.path.exists(deviceFormatStatusFile): - sys.stderr.write("Device format not initiated\n") - sys.exit(1) - - if os.path.exists(deviceFormatStatusFile): - line = Utils.readFile(deviceFormatStatusFile) - line = line.strip() - - Utils.removeFile(deviceFormatOutputFile) - Utils.removeFile(deviceFormatStatusFile) - - responseDom = ResponseXml() - responseDom.appendTagRoute("device", sys.argv[1]) - responseDom.appendTagRoute("completedBlocks", "0") - responseDom.appendTagRoute("totalBlocks", "0") - responseDom.appendTagRoute("message", line) - if line.upper() == "COMPLETED": - responseDom.appendTagRoute("formatStatus", "COMPLETED") - else: - responseDom.appendTagRoute("formatStatus", "NOT_RUNNING") - print responseDom.toxml() - sys.exit(0) - - content = Utils.readFile(deviceFormatOutputFile, lines=True) - if not content: - responseDom = ResponseXml() - responseDom.appendTagRoute("device", sys.argv[1]) - responseDom.appendTagRoute("completedBlocks", "0") - responseDom.appendTagRoute("totalBlocks", "0") - responseDom.appendTagRoute("message", None) - responseDom.appendTagRoute("formatStatus", "IN_PROGRESS") - print responseDom.toxml() - sys.exit(0) - - lines = [line for line in content - if "Writing inode tables" in line] - if not lines: - responseDom = ResponseXml() - responseDom.appendTagRoute("device", sys.argv[1]) - responseDom.appendTagRoute("completedBlocks", "0") - responseDom.appendTagRoute("totalBlocks", "0") - responseDom.appendTagRoute("message", content[-1]) - responseDom.appendTagRoute("formatStatus", "IN_PROGRESS") - print responseDom.toxml() - sys.exit(0) - - tokens = [token for token in lines[-1].split("\x08") if token] - if "done" in tokens[-1]: - values = tokens[-2].split(':')[-1].strip().split('/') - else: - values = tokens[-1].split(':')[-1].strip().split('/') - - responseDom.appendTagRoute("device", sys.argv[1]) - responseDom.appendTagRoute("completedBlocks", values[0]) - responseDom.appendTagRoute("totalBlocks", values[1]) - responseDom.appendTagRoute("message", lines[-1]) - responseDom.appendTagRoute("formatStatus", "IN_PROGRESS") - print responseDom.toxml() - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py deleted file mode 100755 index da08fde1..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -CPU_RRD_FILE = "/var/lib/rrd/cpu.rrd" - -def main(): - if len(sys.argv) != 2: - sys.stderr.write("usage: %s DURATION\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - period = sys.argv[1] - - command = "rrdtool xport --start -%s \ - DEF:cpuuser=%s:user:AVERAGE \ - DEF:cpusystem=%s:system:AVERAGE \ - DEF:cpuidle=%s:idle:AVERAGE \ - CDEF:total=cpuuser,cpusystem,cpuidle,+,+ \ - CDEF:userpct=100,cpuuser,total,/,* \ - CDEF:systempct=100,cpusystem,total,/,* \ - CDEF:idlepct=100,cpuidle,total,/,* \ - CDEF:totalpct=userpct,systempct,+ \ - XPORT:userpct:userpct \ - XPORT:systempct:systempct \ - XPORT:totalpct:totalpct" % (period, CPU_RRD_FILE, CPU_RRD_FILE, CPU_RRD_FILE) - - rv = Utils.runCommand(command, output=True, root=True) - if rv["Status"] != 0: - sys.stderr.write("Failed to get RRD data of CPU\n") - sys.exit(rv["Status"]) - - print rv["Stdout"] - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py deleted file mode 100755 index 07a9d7d0..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -MEMORY_RRD_FILE = "/var/lib/rrd/mem.rrd" - -def main(): - if len(sys.argv) != 2: - sys.stderr.write("usage: %s DURATION\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - period = sys.argv[1] - - command = "rrdtool xport --start -%s \ - DEF:free=%s:memfree:AVERAGE \ - DEF:used=%s:memused:AVERAGE \ - DEF:cache=%s:memcache:AVERAGE \ - DEF:buffer=%s:membuffer:AVERAGE \ - CDEF:total1=used,free,+ \ - CDEF:used1=used,buffer,cache,-,- \ - CDEF:total=total1,used1,+ \ - XPORT:used:memoryUsed \ - XPORT:free:memoryFree \ - XPORT:cache:memoryCache \ - XPORT:buffer:memoryBuffer \ - XPORT:total:totalMemory" % (period, MEMORY_RRD_FILE, MEMORY_RRD_FILE, MEMORY_RRD_FILE, MEMORY_RRD_FILE) - - rv = Utils.runCommand(command, output=True, root=True) - if rv["Status"] != 0: - sys.stderr.write("Failed to get RRD data of memory usage\n") - sys.exit(rv["Status"]) - - print rv["Stdout"] - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py deleted file mode 100755 index ee28ca13..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -def main(): - if len(sys.argv) != 3: - sys.stderr.write("usage: %s DEVICE DURATION\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - device = sys.argv[1] - period = sys.argv[2] - - command = "rrdtool xport --start -%s \ - DEF:received=/var/lib/rrd/network-%s.rrd:received:AVERAGE \ - DEF:transmitted=/var/lib/rrd/network-%s.rrd:transmitted:AVERAGE \ - CDEF:total=received,transmitted,+ \ - XPORT:received:received \ - XPORT:transmitted:transmitted \ - XPORT:total:total" % (period, device, device) - - rv = Utils.runCommand(command, output=True, root=True) - if rv["Status"] != 0: - sys.stderr.write("Failed to get RRD information of device %s\n" % device) - sys.exit(rv["Status"]) - - print rv["Stdout"] - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py deleted file mode 100755 index 26b9059a..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py +++ /dev/null @@ -1,267 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import socket -import re -import Utils -import DiskUtils -import NetworkUtils -import XmlHandler -from optparse import OptionParser - - -def getDiskDom(): - diskInfo = DiskUtils.getDiskInfo() - if not diskInfo: - return None - procMdstat = DiskUtils.getProcMdstat() - diskDom = XmlHandler.XDOM() - disksTag = diskDom.createTag("disks", None) - diskTagDict = {} - raidDisksTag = diskDom.createTag("raidDisks", None) # raid members tag - for raidDiskName, raidDisk in procMdstat.iteritems(): - raidDiskTag = diskDom.createTag("disk", None) - raidDiskTag.appendChild(diskDom.createTag("name", raidDiskName)) - raidDiskTag.appendChild(diskDom.createTag("description", diskInfo[raidDiskName]['Description'])) - raidDiskTag.appendChild(diskDom.createTag("uuid", diskInfo[raidDiskName]['Uuid'])) - raidDiskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) - raidDiskTag.appendChild(diskDom.createTag("mountPoint", diskInfo[raidDiskName]['MountPoint'])) - raidDiskTag.appendChild(diskDom.createTag("fsType", diskInfo[raidDiskName]['FsType'])) - if diskInfo[raidDiskName]['FsType']: - raidDiskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) - else: - raidDiskTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) - raidDiskTag.appendChild(diskDom.createTag("interface")) - raidDiskTag.appendChild(diskDom.createTag("fsVersion")) - raidDiskTag.appendChild(diskDom.createTag("size", diskInfo[raidDiskName]['Size'] / 1024.0)) - if not diskInfo[raidDiskName]['SpaceInUse']: - raidDiskTag.appendChild(diskDom.createTag("spaceInUse", None)) - else: - raidDiskTag.appendChild(diskDom.createTag("spaceInUse", diskInfo[raidDiskName]['SpaceInUse'] / 1024.0)) - raidDiskTag.appendChild(raidDisksTag) - disksTag.appendChild(raidDiskTag) - for raidMember in raidDisk['Member']: - # Case1: Raid array member is a disk. The following code will add the disk details under a disk tag - if diskInfo.has_key(raidMember): - diskTag = diskDom.createTag("disk", None) - diskTag.appendChild(diskDom.createTag("name", raidMember)) - diskTag.appendChild(diskDom.createTag("description", diskInfo[raidMember]["Description"])) - diskTag.appendChild(diskDom.createTag("uuid", diskInfo[raidMember]["Uuid"])) - if DiskUtils.isDiskInFormatting(raidMember): - diskTag.appendChild(diskDom.createTag("status", "INITIALIZING")) - else: - if diskInfo[raidMember]["FsType"]: - diskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) - else: - diskTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) - diskTag.appendChild(diskDom.createTag("interface", diskInfo[raidMember]["Interface"])) - diskTag.appendChild(diskDom.createTag("mountPoint", diskInfo[raidMember]["MountPoint"])) - if diskInfo[raidMember]["FsType"]: - diskTag.appendChild(diskDom.createTag("type", "DATA")) - else: - diskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) - diskTag.appendChild(diskDom.createTag("fsType", diskInfo[raidMember]["FsType"])) - diskTag.appendChild(diskDom.createTag("fsVersion", diskInfo[raidMember]["FsVersion"])) - diskTag.appendChild(diskDom.createTag("size", diskInfo[raidMember]["Size"] / 1024.0)) - if not diskInfo[raidMember]["SpaceInUse"]: - diskTag.appendChild(diskDom.createTag("spaceInUse", None)) - else: - diskTag.appendChild(diskDom.createTag("spaceInUse", diskInfo[raidMember]["SpaceInUse"] / 1024.0)) - raidDisksTag.appendChild(diskTag) - del diskInfo[raidMember] - continue - # Case2: Raid array member is a partition. The following code will add the partition and its corresponding disk its belong to. - for disk, item in diskInfo.iteritems(): - if not item['Partitions'].has_key(raidMember): - continue - if not diskTagDict.has_key(disk): - diskTag = diskDom.createTag("disk", None) - diskTag.appendChild(diskDom.createTag("name", disk)) - diskTag.appendChild(diskDom.createTag("description", item["Description"])) - diskTag.appendChild(diskDom.createTag("uuid", item["Uuid"])) - diskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) - diskTag.appendChild(diskDom.createTag("interface", item["Interface"])) - diskTag.appendChild(diskDom.createTag("mountPoint")) - diskTag.appendChild(diskDom.createTag("type", "DATA")) - diskTag.appendChild(diskDom.createTag("fsType", item["FsType"])) - diskTag.appendChild(diskDom.createTag("fsVersion", item["FsVersion"])) - diskTag.appendChild(diskDom.createTag("size", item["Size"] / 1024.0)) - if not item["SpaceInUse"]: - diskTag.appendChild(diskDom.createTag("spaceInUse", None)) - else: - diskTag.appendChild(diskDom.createTag("spaceInUse", item["SpaceInUse"] / 1024.0)) - partitionsTag = diskDom.createTag("partitions", None) - diskTag.appendChild(partitionsTag) - raidDisksTag.appendChild(diskTag) - # Constructed disk tag will be added to the dictonary. - # This will be used to keep add all the corresponding partitions tags of the disk to the disk tag. - diskTagDict[disk] = {'diskTag': diskTag, 'partitionsTag': partitionsTag} - # adding partition details under this disk tag - partitionTag = diskDom.createTag("partition", None) - partitionTag.appendChild(diskDom.createTag("name", raidMember)) - partitionTag.appendChild(diskDom.createTag("uuid", item['Partitions'][raidMember]["Uuid"])) - partitionTag.appendChild(diskDom.createTag("fsType", item['Partitions'][raidMember]["FsType"])) - if item['Partitions'][raidMember]["FsType"]: - partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) - partitionTag.appendChild(diskDom.createTag("type", "DATA")) - else: - partitionTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) - partitionTag.appendChild(diskDom.createTag("type", "UNKNOWN")) - partitionTag.appendChild(diskDom.createTag("mountPoint", item['Partitions'][raidMember]['MountPoint'])) - partitionTag.appendChild(diskDom.createTag("size", item['Partitions'][raidMember]["Size"] / 1024.0)) - if not item['Partitions'][raidMember]["SpaceInUse"]: - partitionTag.appendChild(diskDom.createTag("spaceInUse", None)) - else: - partitionTag.appendChild(diskDom.createTag("spaceInUse", item['Partitions'][raidMember]["SpaceInUse"] / 1024.0)) - diskTagDict[disk]['partitionsTag'].appendChild(partitionTag) - # deleting partition entry of a raid member from diskInfo (item['Partitions']) - del item['Partitions'][raidMember] - del diskInfo[raidDiskName] - disksTag.appendChild(raidDisksTag) - for diskName, value in diskInfo.iteritems(): - diskTag = diskDom.createTag("disk", None) - diskTag.appendChild(diskDom.createTag("name", diskName)) - diskTag.appendChild(diskDom.createTag("description", value["Description"])) - diskTag.appendChild(diskDom.createTag("uuid", value["Uuid"])) - if DiskUtils.isDiskInFormatting(diskName): - status = "INITIALIZING" - else: - if value["FsType"]: - status = "INITIALIZED" - else: - status = "UNINITIALIZED" - diskTag.appendChild(diskDom.createTag("status", status)) - diskTag.appendChild(diskDom.createTag("interface", value["Interface"])) - if value["MountPoint"] and value["MountPoint"] in ["/", "/boot"]: - diskTag.appendChild(diskDom.createTag("type", "BOOT")) - elif "UNINITIALIZED" == status: - diskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) - else: - diskTag.appendChild(diskDom.createTag("type", "DATA")) - diskTag.appendChild(diskDom.createTag("fsType", value["FsType"])) - diskTag.appendChild(diskDom.createTag("fsVersion", value["FsVersion"])) - diskTag.appendChild(diskDom.createTag("mountPoint", value["MountPoint"])) - diskTag.appendChild(diskDom.createTag("size", value["Size"] / 1024.0)) - if not value["SpaceInUse"]: - diskTag.appendChild(diskDom.createTag("spaceInUse", None)) - else: - diskTag.appendChild(diskDom.createTag("spaceInUse", value["SpaceInUse"] / 1024.0)) - partitionsTag = diskDom.createTag("partitions", None) - diskTag.appendChild(partitionsTag) - for partName, partValues in value['Partitions'].iteritems(): - partitionTag = diskDom.createTag("partition", None) - partitionTag.appendChild(diskDom.createTag("name", partName)) - partitionTag.appendChild(diskDom.createTag("uuid", partValues["Uuid"])) - partitionTag.appendChild(diskDom.createTag("fsType", partValues["FsType"])) - if partValues["MountPoint"] and partValues["MountPoint"] in ["/", "/boot"]: - partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) - partitionTag.appendChild(diskDom.createTag("type", "BOOT")) - elif partValues["FsType"]: - partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) - partitionTag.appendChild(diskDom.createTag("type", "DATA")) - else: - partitionTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) - partitionTag.appendChild(diskDom.createTag("type", "UNKNOWN")) - partitionTag.appendChild(diskDom.createTag("mountPoint", partValues['MountPoint'])) - partitionTag.appendChild(diskDom.createTag("size", partValues["Size"] / 1024.0)) - if not partValues["SpaceInUse"]: - partitionTag.appendChild(diskDom.createTag("spaceInUse", None)) - else: - partitionTag.appendChild(diskDom.createTag("spaceInUse", partValues["SpaceInUse"] / 1024.0)) - partitionsTag.appendChild(partitionTag) - continue - disksTag.appendChild(diskTag) - diskDom.addTag(disksTag) - return diskDom - - -def getServerDetails(listall): - serverName = socket.getfqdn() - meminfo = Utils.getMeminfo() - cpu = Utils.getCpuUsageAvg() - nameServerList, domain, searchDomain = NetworkUtils.readResolvConfFile() - if not domain: - domain = [None] - - responseDom = XmlHandler.ResponseXml() - serverTag = responseDom.appendTagRoute("server") - serverTag.appendChild(responseDom.createTag("name", serverName)) - serverTag.appendChild(responseDom.createTag("domainname", domain[0])) - if Utils.runCommand("pidof glusterd") == 0: - serverTag.appendChild(responseDom.createTag("status", "ONLINE")) - else: - serverTag.appendChild(responseDom.createTag("status", "OFFLINE")) - serverTag.appendChild(responseDom.createTag("glusterFsVersion", Utils.getGlusterVersion())) - serverTag.appendChild(responseDom.createTag("cpuUsage", str(cpu))) - serverTag.appendChild(responseDom.createTag("totalMemory", str(Utils.convertKbToMb(meminfo['MemTotal'])))) - serverTag.appendChild(responseDom.createTag("memoryInUse", str(Utils.convertKbToMb(meminfo['MemUsed'])))) - serverTag.appendChild(responseDom.createTag("uuid", None)) - - for dns in nameServerList: - serverTag.appendChild(responseDom.createTag("dns%s" % str(nameServerList.index(dns) +1) , dns)) - - #TODO: probe and retrieve timezone, ntp-server details and update the tags - - interfaces = responseDom.createTag("networkInterfaces", None) - for deviceName, values in NetworkUtils.getNetDeviceList().iteritems(): - if values["type"].upper() in ['LOCAL', 'IPV6-IN-IPV4']: - continue - interfaceTag = responseDom.createTag("networkInterface", None) - interfaceTag.appendChild(responseDom.createTag("name", deviceName)) - interfaceTag.appendChild(responseDom.createTag("hwAddr", values["hwaddr"])) - interfaceTag.appendChild(responseDom.createTag("speed", values["speed"])) - interfaceTag.appendChild(responseDom.createTag("model", values["type"])) - if values["onboot"]: - interfaceTag.appendChild(responseDom.createTag("onBoot", "yes")) - else: - interfaceTag.appendChild(responseDom.createTag("onBoot", "no")) - interfaceTag.appendChild(responseDom.createTag("bootProto", values["bootproto"])) - interfaceTag.appendChild(responseDom.createTag("ipAddress", values["ipaddr"])) - interfaceTag.appendChild(responseDom.createTag("netMask", values["netmask"])) - interfaceTag.appendChild(responseDom.createTag("defaultGateway", values["gateway"])) - if values["mode"]: - interfaceTag.appendChild(responseDom.createTag("mode", values["mode"])) - if values["master"]: - interfaceTag.appendChild(responseDom.createTag("bonding", "yes")) - spliter = re.compile(r'[\D]') - interfaceTag.appendChild(responseDom.createTag("bondid", spliter.split(values["master"])[-1])) - interfaces.appendChild(interfaceTag) - serverTag.appendChild(interfaces) - - responseDom.appendTag(serverTag) - serverTag.appendChild(responseDom.createTag("numOfCPUs", int(os.sysconf('SC_NPROCESSORS_ONLN')))) - - diskDom = getDiskDom() - if not diskDom: - sys.stderr.write("No disk found!") - Utils.log("Failed to get disk details") - sys.exit(2) - - serverTag.appendChild(diskDom.getElementsByTagRoute("disks")[0]) - return serverTag - -def main(): - parser = OptionParser() - parser.add_option("-N", "--only-data-disks", - action="store_false", dest="listall", default=True, - help="List only data disks") - - (options, args) = parser.parse_args() - responseXml = getServerDetails(options.listall) - if responseXml: - print responseXml.toxml() - - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py deleted file mode 100755 index 2814f10f..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Console. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - -def main(): - if len(sys.argv) != 1: - sys.stderr.write("usage: %s\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - if Utils.runCommand("pidof glusterd") == 0: - print "ONLINE" - else: - print "OFFLINE" - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py deleted file mode 100755 index 026c3c00..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -import re -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -from XmlHandler import XDOM -import Utils - -def enumLogType(logCode): - if "M" == logCode.upper(): - return "EMERGENCY" - elif "A" == logCode.upper(): - return "ALERT" - elif "C" == logCode.upper(): - return "CRITICAL" - elif "E" == logCode.upper(): - return "ERROR" - elif "W" == logCode.upper(): - return "WARNING" - elif "N" == logCode.upper(): - return "NOTICE" - elif "I" == logCode.upper(): - return "INFO" - elif "D" == logCode.upper(): - return "DEBUG" - elif "T" == logCode.upper(): - return "TRACE" - else: - return "UNKNOWN" -##--end of enumLogType() - -def addLog(responseDom, logMessagesTag, loginfo): - logMessageTag = responseDom.createTag("logMessage") - logMessageTag.appendChild(responseDom.createTag("timestamp", loginfo[0] + " " + loginfo[1])) - logMessageTag.appendChild(responseDom.createTag("severity", enumLogType(loginfo[2]))) - logMessageTag.appendChild(responseDom.createTag("message", loginfo[3])) - logMessagesTag.appendChild(logMessageTag); - return True -##--end of addLog() - -def logSplit(log): - loginfo = log.strip().split(None, 3) - loginfo[0] = loginfo[0][1:] #-- Remove '[' - loginfo[1] = loginfo[1][0:-1] #-- Remove ']' - return loginfo -##--end of logSplit() - -def getVolumeLog(logFilePath, tailCount): - rs = XDOM() - if not logFilePath: - sys.stderr.write("No log file path given\n") - sys.exit(-1) - - if not tailCount: - sys.stderr.write("No tail count given\n") - sys.exit(-1) - - pattern = '\[\d{4}-\d{2}-\d{2}\s{1}\d{2}:\d{2}:\d{2}.\d+\]\s{1}([MACEWNIDT]){1}\s+' - - content = Utils.readFile(logFilePath, lines=True) - if not content: - sys.stderr.write("volume log not found in file %s\n" % logFilePath) - sys.exit(-1) - - lines = [line for line in content if re.match(pattern, line)] - i = len(lines) - int(tailCount) - if i < 0: - i = 0 - logMessagesTag = rs.createTag("logMessages") - rs.addTag(logMessagesTag) - for log in lines[i:]: - loginfo = logSplit(log) - addLog(rs, logMessagesTag, loginfo) - return rs.toxml() -##--end of getVolumeLog() - -def main(): - if len(sys.argv) != 3: - sys.stderr.write("usage: %s LOG-FILE LINE-COUNT\n" % sys.argv[0]) - sys.exit(-1) - - logFilePath = sys.argv[1] - tailCount = sys.argv[2] - print getVolumeLog(logFilePath, tailCount) - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block b/src/com.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block deleted file mode 100755 index 0385b82c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash - -ME=$(basename $0); - -set -o pipefail; - -function show_help() -{ - usage_banner; - cat <> /etc/fstab || fail "Failed to update fstab"; - ;; - *) - echo "UUID=$uuid $mnt $fstype defaults 0 2" >> /etc/fstab || fail "Failed to update fstab"; - ;; - esac - - mount -v $mnt || fail "mounting $devblk on $mnt failed"; - -cat <&2 - exit 1 - fi - /usr/sbin/gluster_cifs_volume_startup - ;; -esac diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py deleted file mode 100644 index 9ea7e021..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -import glob -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import VolumeUtils - -def getGlusterVolumeInfo(volumeName=None): - volumeNameList = None - if Utils.isString(volumeName): - volumeNameList = [volumeName] - if type(volumeName) == type([]): - volumeNameList = volumeName - - status = Utils.runCommand("gluster volume info", output=True, root=True) - if status["Status"] != 0: - Utils.log("Failed to execute 'gluster volume info' command") - return None - - volumeInfoDict = {} - volumeInfo = {} - volumeName = None - brickList = [] - for line in status['Stdout'].split("\n"): - if not line: - if volumeName and volumeInfo: - volumeInfo["Bricks"] = brickList - volumeInfoDict[volumeName] = volumeInfo - volumeInfo = {} - volumeName = None - brickList = [] - continue - - tokens = line.split(":") - if tokens[0].strip().upper() == "BRICKS": - continue - elif tokens[0].strip().upper() == "VOLUME NAME": - volumeName = tokens[1].strip() - volumeInfo["VolumeName"] = volumeName - elif tokens[0].strip().upper() == "TYPE": - volumeInfo["VolumeType"] = tokens[1].strip() - elif tokens[0].strip().upper() == "STATUS": - volumeInfo["VolumeStatus"] = tokens[1].strip() - elif tokens[0].strip().upper() == "TRANSPORT-TYPE": - volumeInfo["TransportType"] = tokens[1].strip() - elif tokens[0].strip().upper().startswith("BRICK"): - brickList.append(":".join(tokens[1:]).strip()) - - if volumeName and volumeInfo: - volumeInfoDict[volumeName] = volumeInfo - - if not volumeNameList: - return volumeInfoDict - - # remove unwanted volume info - for volumeName in list(set(volumeInfoDict.keys()) - set(volumeNameList)): - del volumeInfoDict[volumeName] - - return volumeInfoDict - - -def main(): - volumeInfo = getGlusterVolumeInfo() - if not volumeInfo: - print "No volume present. Removing CIFS volume configuration if any" - Utils.runCommand("rm -fr %s/*" % Globals.VOLUME_CONF_DIR, root=True, shell=True) - Utils.runCommand("rm -fr %s/*" % Globals.REEXPORT_DIR, root=True, shell=True) - Utils.runCommand("rm -fr %s/*" % Globals.CIFS_EXPORT_DIR, root=True, shell=True) - sys.exit(0) - - lines = Utils.readFile(Globals.VOLUME_SMBCONF_FILE) - volumeSmbConfList = [line.strip() for line in lines] - for volumeName in volumeInfo.keys(): - if not "include = %s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) in volumeSmbConfList: - continue - if 'STOPPED' == volumeInfo[volumeName]['VolumeStatus'].upper(): - Utils.runCommand("rmdir %s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName), root=True) - if not VolumeUtils.excludeVolume(volumeName): - Utils.log("Failed to exclude %s volume for CIFS reexport" % volumeName) - continue - if 'STARTED' == volumeInfo[volumeName]['VolumeStatus'].upper(): - volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) - if Utils.runCommand("mount -t glusterfs 127.0.0.1:%s %s" % (volumeName, volumeMountDirName)) != 0: - Utils.log("Failed to mount volume %s" % (volumeName)) - - smbConfFileList = glob.glob("%s/*.smbconf" % Globals.VOLUME_CONF_DIR) - volumeList = [smbConfFileName.split(".smbconf")[0].split("/")[-1] for smbConfFileName in smbConfFileList] - danglingVolumeList = list(set(volumeList).difference(set(volumeInfo.keys()))) - if not danglingVolumeList: - sys.exit(0) - - print "Cleaning up dangling volume(s):", danglingVolumeList - for volumeName in danglingVolumeList: - Utils.runCommand("rmdir %s/%s" % (Globals.REEXPORT_DIR, volumeName), root=True) - Utils.runCommand("rm -f %s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName), root=True) - if not VolumeUtils.excludeVolume(volumeName): - Utils.log("Failed to exclude volume %s for CIFS reexport" % volumeName) - Utils.runCommand("rm -f %s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName), root=True) - - sys.exit(0) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py deleted file mode 100755 index d56b1f59..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils -import VolumeUtils - -def main(): - if len(sys.argv) <= 2: - sys.stderr.write("usage: %s VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - userList = sys.argv[2:] - - if not VolumeUtils.writeVolumeCifsConfiguration(volumeName, userList): - sys.stderr.write("Unable to write cifs configuration\n") - sys.exit(1) - if Utils.runCommand("service smb reload") != 0: - Utils.log("Failed to reload smb service") - sys.stderr.write("Failed to reload smb service\n") - sys.exit(2) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d b/src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d deleted file mode 100755 index 7cfbe44a..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# -# chkconfig: - 85 15 -# description: multicast discovery service -# processname: multicast-discoverd -# pidfile: /var/run/multicast-discoverd.pid - -# Source function library. - -. /etc/init.d/functions - -case "$1" in - start) - echo -n "Starting multicast-discoverd:" - daemon multicast-discoverd - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch /var/lock/subsys/multicast-discoverd - ;; - stop) - echo -n "Shutting down multicast-discoverd:" - killproc multicast-discoverd - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/multicast-discoverd - ;; - restart) - $0 stop - $0 start - RETVAL=$? - ;; - status) - status multicast-discoverd - RETVAL=$? - ;; - reload) - killproc multicast-discoverd -HUP - RETVAL=$? - echo - ;; - *) - echo $"Usage: $0 {start|stop|restart|status|reload}" - exit 1 -esac - -exit $RETVAL diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py deleted file mode 100755 index cb5de70c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import socket -import struct -import signal -import time -import Utils -import Globals - -PID_FILE = "/var/run/multicast-discoverd.pid" -GLUSTERD_UUID = "NA" - -def exitHandler(signum, frame): - try: - if os.path.exists(PID_FILE): - os.unlink(PID_FILE) - except OSError, e: - Utils.log("Failed to remove PID file %s: %s" % (PID_FILE, str(e))) - sys.exit(0) - - -def updateGlusterdUuid(signum, frame): - lines = Utils.readFile("/etc/glusterd/glusterd.info", lines=True) - for line in lines: - if line.strip().startswith("UUID="): - GLUSTERD_UUID = line.strip().split("=")[1] - return - GLUSTERD_UUID = "NA" - - -def isInPeer(): - status = Utils.runCommand("gluster peer status", output=True) - if status["Status"] == 0: - if status["Stdout"].strip().upper() != "NO PEERS PRESENT": - return True - return False - - -def main(): - if os.path.exists(PID_FILE): - sys.stderr.write("fatal: PID file %s exists\n" % PID_FILE) - sys.exit(-1) - if not Utils.daemonize(): - sys.stderr.write("fatal: unable to run as daemon\n") - sys.exit(-1) - try: - fp = open(PID_FILE, "w") - fp.write("%s\n" % os.getpid()) - fp.close() - except IOError, e: - Utils.log("failed to create PID file %s: %s" % (PID_FILE, str(e))) - sys.exit(1) - - updateGlusterdUuid(None, None) - - signal.signal(signal.SIGINT, exitHandler) - signal.signal(signal.SIGTERM, exitHandler) - signal.signal(signal.SIGHUP, exitHandler) - - multicastSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) - multicastSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - multicastSocket.bind(('', Globals.MULTICAST_PORT)) - multicastSocket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, - struct.pack("4sl", socket.inet_aton(Globals.MULTICAST_GROUP), - socket.INADDR_ANY)) - - while True: - request = multicastSocket.recvfrom(Globals.DEFAULT_BUFSIZE) - if not request: - continue - #print "received [%s] from %s" % (request[0], request[1]) - tokens = request[0].strip().split(",") - if len(tokens) != 3: - continue - if tokens[0] != Globals.GLUSTER_PROBE_STRING: - continue - if isInPeer(): - continue - - time.sleep(0.2) - try: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((request[1][0], Globals.SERVER_PORT)) - sock.send("%s,%s,%s,%s,%s,%s\n" % (tokens[0], tokens[1], tokens[2], socket.gethostname(), socket.getfqdn(), GLUSTERD_UUID)) - sock.close() - except socket.error, e: - Utils.log("failed to send reply to [%s:%s]: %s" % (request[1][0], Globals.SERVER_PORT, str(e))) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl b/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl deleted file mode 100755 index 30a66342..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/perl - -use RRDs; - -my $rrdlog = '/var/lib/rrd'; -my $graphs = '/var/lib/rrd'; - -updatecpudata(); -#updatecpugraph('day'); -#updatecpugraph('week'); -#updatecpugraph('month'); -#updatecpugraph('year'); - -sub updatecpugraph { - my $period = $_[0]; - - RRDs::graph ("$graphs/cpu-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", - "--alt-y-grid", "-w 300", "-h 50", "-l 0", "-u 100", "-r", - "--color", "SHADEA#FFFFFF", - "--color", "SHADEB#FFFFFF", - "--color", "BACK#FFFFFF", - "-t cpu usage per $period", - "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE", - "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE", - "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE", - - "CDEF:total=user,system,idle,+,+", - "CDEF:userpct=100,user,total,/,*", - "CDEF:systempct=100,system,total,/,*", - "CDEF:idlepct=100,idle,total,/,*", - - "AREA:userpct#0000FF:User cpu usage\\j", - "STACK:systempct#FF0000:system cpu usage\\j", - "STACK:idlepct#00FF00:idle cpu usage\\j"); - - # "GPRINT:userpct:MAX:maximal user cpu\\:%3.2lf%%", - # "GPRINT:userpct:AVERAGE:average user cpu\\:%3.2lf%%", - # "GPRINT:userpct:LAST:current user cpu\\:%3.2lf%%\\j", - # "GPRINT:systempct:MAX:maximal system cpu\\:%3.2lf%%", - # "GPRINT:systempct:AVERAGE:average system cpu\\:%3.2lf%%", - # "GPRINT:systempct:LAST:current system cpu\\:%3.2lf%%\\j", - # "GPRINT:idlepct:MAX:maximal idle cpu\\:%3.2lf%%", - # "GPRINT:idlepct:AVERAGE:average idle cpu\\:%3.2lf%%", - # "GPRINT:idlepct:LAST:current idle cpu\\:%3.2lf%%\\j"); - $ERROR = RRDs::error; - print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; -} - -sub updatecpudata { - if ( ! -e "$rrdlog/cpu.rrd") { - RRDs::create ("$rrdlog/cpu.rrd", "--step=300", - "DS:user:COUNTER:600:0:U", - "DS:system:COUNTER:600:0:U", - "DS:idle:COUNTER:600:0:U", - - "RRA:AVERAGE:0.5:1:576", - "RRA:AVERAGE:0.5:6:672", - "RRA:AVERAGE:0.5:24:732", - "RRA:AVERAGE:0.5:144:1460"); - $ERROR = RRDs::error; - print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; - } - - my ($cpu, $user, $nice, $system,$idle); - - open STAT, "/proc/stat"; - while() { - chomp; - /^cpu\s/ or next; - ($cpu, $user, $nice, $system, $idle) = split /\s+/; - last; - } - close STAT; - $user += $nice; - - RRDs::update ("$rrdlog/cpu.rrd", - "-t", "user:system:idle", - "N:$user:$system:$idle"); - $ERROR = RRDs::error; - print "Error in RRD::update for cpu: $ERROR\n" if $ERROR; - - #print "N:$user:$system:$idle\n"; -} diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl b/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl deleted file mode 100755 index 5c47cd81..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/perl - -use RRDs; - -my $rrdlog = '/var/lib/rrd'; -my $graphs = '/var/lib/rrd'; - -updatememdata (); -#updatememgraph ('day'); -#updatememgraph ('week'); -#updatememgraph ('month'); -#updatememgraph ('year'); - -sub updatememgraph { - my $period = $_[0]; - - RRDs::graph ("$graphs/memory-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", - "--alt-y-grid", "-w 300", "-h 50", "-l 0", "-u 100", "-r", - "--color", "SHADEA#FFFFFF", - "--color", "SHADEB#FFFFFF", - "--color", "BACK#FFFFFF", - "-t memory usage per $period", - "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE", - "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE", - "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE", - "CDEF:total=used,free,+", - "CDEF:used1=used,buffer,cache,-,-", - "CDEF:usedpct=100,used1,total,/,*", - "CDEF:free1=total,used1,-", - "CDEF:cachepct=100,cache,total,/,*", - "CDEF:freepct=100,free1,total,/,*", - "AREA:usedpct#0000FF:used memory\\j", - "STACK:cachepct#FFFF00:cached memory\\j", - "STACK:freepct#00FF00:free memory\\j"); - $ERROR = RRDs::error; - print "Error in RRD::graph for mem: $ERROR\n" if $ERROR; - - RRDs::graph ("$graphs/swap-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", - "--alt-y-grid", "-w 300", "-h 50", "-l 0", "-u 100", "-r", - "--color", "SHADEA#FFFFFF", - "--color", "SHADEB#FFFFFF", - "--color", "BACK#FFFFFF", - "-t swap usage per $period", - "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE", - "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE", - "CDEF:total=used,free,+", - "CDEF:usedpct=100,used,total,/,*", - "CDEF:freepct=100,free,total,/,*", - "AREA:usedpct#0000FF:used swap\\j", - "STACK:freepct#00FF00:free swap\\j"); - $ERROR = RRDs::error; - print "Error in RRD::graph for swap: $ERROR\n" if $ERROR; -} - -sub updatememdata { - my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree); - if ( ! -e "$rrdlog/mem.rrd") { - RRDs::create ("$rrdlog/mem.rrd", "--step=300", - "DS:memused:ABSOLUTE:600:0:U", - "DS:memfree:ABSOLUTE:600:0:U", - "DS:memcache:ABSOLUTE:600:0:U", - "DS:membuffer:ABSOLUTE:600:0:U", - "DS:swapused:ABSOLUTE:600:0:U", - "DS:swapfree:ABSOLUTE:600:0:U", - "RRA:AVERAGE:0.5:1:576", - "RRA:AVERAGE:0.5:6:672", - "RRA:AVERAGE:0.5:24:732", - "RRA:AVERAGE:0.5:144:1460"); - $ERROR = RRDs::error; - print "Error in RRD::create for mem: $ERROR\n" if $ERROR; - } - - my @memdata = `free -b -o`; - - my $temp = $memdata[1]; - - chomp( $temp ); - my @tempa = split (/\s+/, $temp); - $memused = $tempa [2]; - $memfree = $tempa [3]; - $memshared = $tempa [4]; - $membuffers = $tempa [5]; - $memcache = $tempa [6]; - - $temp = $memdata[2]; - chomp( $temp ); - @tempa = split (/\s+/, $temp); - $swapused = $tempa [2]; - $swapfree = $tempa [3]; - - - RRDs::update ("$rrdlog/mem.rrd", - "-t", "memused:memfree:memcache:membuffer:swapused:swapfree", - "N:$memused:$memfree:$memcache:$membuffers:$swapused:$swapfree"); - - $ERROR = RRDs::error; - print "Error in RRD::update for mem: $ERROR\n" if $ERROR; -} diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl b/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl deleted file mode 100755 index 6ae128fd..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl - -use RRDs; - -my $rrdlog = '/var/lib/rrd'; -my $graphs = '/var/lib/rrd'; - -updatenetdata(); -#updatenetgraph('hour'); -#updatenetgraph('day'); -#updatenetgraph('week'); -#updatenetgraph('month'); -#updatenetgraph('year'); - -sub updatenetgraph { - my $period = $_[0]; - - foreach $rrdfile (<$rrdlog/network-*.rrd>) { - RRDs::graph ("$graphs/network-$device-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", - "--alt-y-grid", "-w 800", "-h 400", "-l 0", "-u 10000000", "-r", - "--color", "SHADEA#FFFFFF", - "--color", "SHADEB#FFFFFF", - "--color", "BACK#FFFFFF", - "-t $device load per $period", - "DEF:received=$rrdfile:received:AVERAGE", - "DEF:transmitted=$rrdfile:transmitted:AVERAGE", - - "LINE2:received#FF0000:received load\\j", - "LINE1:transmitted#0000FF:transmitted load\\j"); - - $ERROR = RRDs::error; - print "Error in RRD::graph for network $device: $ERROR\n" if $ERROR; - } -} - -sub updatenetdata { - open NETDEV, "/proc/net/dev"; - while () { - chomp; - s/^\s+//; # remove left side whitespaces - /:.+/ or next; # if input line contains ':' else continue - next if /^lo:/; # continue if input line starts with 'lo:' - - @tokens1 = split /:/; # split with ':' - $tokens1[1]=~s/^\s+//; # remove left side whitespaces - @tokens2 = split(/\s+/, $tokens1[1]); # split with space - - $device = $tokens1[0]; - $received = $tokens2[0]; - $transmitted = $tokens2[8]; - - #print "$device, $received, $transmitted \n"; - - if ( ! -e "$rrdlog/network-$device.rrd") { - RRDs::create ("$rrdlog/network-$device.rrd", "--step=300", - "DS:received:COUNTER:600:0:U", - "DS:transmitted:COUNTER:600:0:U", - - "RRA:AVERAGE:0.5:1:576", - "RRA:AVERAGE:0.5:6:672", - "RRA:AVERAGE:0.5:24:732", - "RRA:AVERAGE:0.5:144:1460"); - $ERROR = RRDs::error; - print "Error in RRD::create for device $device: $ERROR\n" if $ERROR; - } - - RRDs::update ("$rrdlog/network-$device.rrd", - "-t", "received:transmitted", - "N:$received:$transmitted"); - $ERROR = RRDs::error; - print "Error in RRD::update for net: $ERROR\n" if $ERROR; - } - close NETDEV -} diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py deleted file mode 100755 index 5d5187f4..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import time -import Globals -import Utils - -def main(): - try: - if not os.path.exists(Globals.GLUSTER_BASE_DIR): - os.mkdir(Globals.GLUSTER_BASE_DIR) - if not os.path.exists(Globals.VOLUME_CONF_DIR): - os.mkdir(Globals.VOLUME_CONF_DIR) - if not os.path.exists(Globals.CIFS_EXPORT_DIR): - os.mkdir(Globals.CIFS_EXPORT_DIR) - if not os.path.exists(Globals.REEXPORT_DIR): - os.mkdir(Globals.REEXPORT_DIR) - except OSError, e: - Utils.log("failed to create directory: %s" % str(e)) - sys.stderr.write("Failed to create directory: %s\n" % str(e)) - sys.exit(1) - try: - if not os.path.exists(Globals.VOLUME_SMBCONF_FILE): - fp = open(Globals.VOLUME_SMBCONF_FILE, "w") - fp.close() - except IOError, e: - Utils.log("Failed to create file %s: %s" % (Globals.VOLUME_SMBCONF_FILE, str(e))) - sys.stderr.write("Failed to create file %s: %s\n" % (Globals.VOLUME_SMBCONF_FILE, str(e))) - sys.exit(2) - try: - backupFile = "%s.%s" % (Globals.SAMBA_CONF_FILE, time.time()) - os.rename(Globals.SAMBA_CONF_FILE, backupFile) - except IOError, e: - Utils.log("Ignoring rename %s to %s: %s" % (Globals.SAMBA_CONF_FILE, backupFile)) - sys.stderr.write("Ignoring rename %s to %s: %s\n" % (Globals.SAMBA_CONF_FILE, backupFile)) - try: - fp = open(Globals.SAMBA_CONF_FILE, "w") - fp.write("##\n") - fp.write("## THIS FILE SHOULD NOT BE MODIFIED. IF YOU WANT TO MODIFY SAMBA\n") - fp.write("## CONFIGURATIONS, USE /etc/samba/real.smb.conf FILE\n") - fp.write("##\n") - fp.write("include = %s\n\n" % Globals.REAL_SAMBA_CONF_FILE) - fp.write("## CAUTION: DO NOT REMOVE BELOW LINE. REMOVAL OF THE LINE DISABLES\n") - fp.write("## CIFS REEXPORT OF GLUSTER VOLUMES\n") - fp.write("include = %s\n" % Globals.VOLUME_SMBCONF_FILE) - fp.close() - except IOError, e: - Utils.log("Failed to create samba configuration file %s: %s" % (Globals.SAMBA_CONF_FILE, str(e))) - sys.stderr.write("Failed to create samba configuration file %s: %s\n" % (Globals.SAMBA_CONF_FILE, str(e))) - sys.exit(3) - try: - if not os.path.exists(Globals.REAL_SAMBA_CONF_FILE): - fp = open(Globals.REAL_SAMBA_CONF_FILE, "w") - fp.write("[global]\n") - fp.write("## CAUTION: DO NOT REMOVE BELOW INCLUDE LINE. REMOVAL OF THE LINE\n") - fp.write("## DISABLES SERVER/CIFS HIGH AVAILABILITY\n") - #fp.write("include = %s\n" % Globals.CTDB_SAMBA_CONF_FILE) - fp.write("##\n") - fp.write("socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=131072 SO_RCVBUF=131072\n") - fp.write("read raw = yes\n") - fp.write("server string = %h\n") - fp.write("write raw = yes\n") - fp.write("oplocks = yes\n") - fp.write("max xmit = 131072\n") - fp.write("dead time = 15\n") - fp.write("getwd cache = yes\n") - fp.write("#read size = 131072\n") - fp.write("use sendfile=yes\n") - fp.write("block size = 131072\n") - fp.write("printcap name = /etc/printcap\n") - fp.write("load printers = no\n") - fp.close() - except IOError, e: - Utils.log("Failed to create samba configuration file %s: %s" % (Globals.REAL_SAMBA_CONF_FILE, str(e))) - sys.stderr.write("Failed to create samba configuration file %s: %s\n" % (Globals.REAL_SAMBA_CONF_FILE, str(e))) - sys.exit(4) - - if Utils.runCommand("/usr/sbin/selinuxenabled") == 0: - if Utils.runCommand("setsebool -P samba_share_fusefs on") != 0: - Utils.log("failed to set SELinux samba_share_fusefs") - sys.stderr.write("failed to set SELinux samba_share_fusefs\n") - sys.exit(5) - - if Utils.runCommand("service smb status") != 0: - if Utils.runCommand("service smb start") != 0: - Utils.log("failed to start smb service") - sys.stderr.write("Failed to start smb service\n") - sys.exit(6) - - if Utils.runCommand("service smb reload") != 0: - Utils.log("failed to reload smb configuration") - sys.stderr.write("Failed to reload smb configuration\n") - sys.exit(7) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py deleted file mode 100755 index e16c87c2..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import VolumeUtils - -def main(): - if len(sys.argv) != 2: - sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - - volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) - cifsDirName = "%s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName) - - if Utils.runCommand("mount -t glusterfs 127.0.0.1:%s %s" % (volumeName, volumeMountDirName)) != 0: - Utils.log("Failed to mount volume %s" % (volumeName)) - sys.stderr.write("Failed to mount volume %s\n" % (volumeName)) - sys.exit(1) - if Utils.runCommand("ln -fTs %s %s" % (volumeMountDirName, cifsDirName)) != 0: - Utils.log("Failed to create reexport link %s" % cifsDirName) - sys.stderr.write("Failed to create reexport link %s\n" % cifsDirName) - sys.exit(2) - if Utils.runCommand("/usr/sbin/selinuxenabled") == 0: - if Utils.runCommand("chcon -t samba_share_t %s -h" % cifsDirName) != 0: - Utils.log("Failed to change security context for the link %s" % cifsDirName) - sys.stderr.write("Failed to change security context for the link %s\n" % cifsDirName) - sys.exit(2) - if not VolumeUtils.includeVolume(volumeName): - Utils.log("Failed to include volume for CIFS reexport") - sys.stderr.write("Failed to include volume for CIFS reexport\n") - sys.exit(3) - if Utils.runCommand("service smb reload") != 0: - Utils.log("Failed to reload smb service") - sys.stderr.write("Failed to reload smb service\n") - sys.exit(4) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py deleted file mode 100755 index d67d9061..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import VolumeUtils - -def main(): - if len(sys.argv) != 2: - sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - - volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) - cifsDirName = "%s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName) - - if not Utils.removeFile(cifsDirName): - Utils.log("Failed to remove reexport link %s" % cifsDirName) - sys.stderr.write("Failed to remove reexport link %s\n" % cifsDirName) - sys.exit(1) - if not VolumeUtils.excludeVolume(volumeName): - Utils.log("Failed to exclude volume for CIFS reexport") - sys.stderr.write("Failed to exclude volume for CIFS reexport\n") - sys.exit(2) - if Utils.runCommand("service smb reload") != 0: - Utils.log("Failed to reload smb service") - sys.stderr.write("Failed to reload smb service\n") - sys.exit(3) - if Utils.runCommand("umount %s" % (volumeMountDirName)) != 0: - Utils.log("Failed to unmount volume %s" % (volumeName)) - sys.stderr.write("Failed to unmount volume %s\n" % (volumeName)) - sys.exit(4) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh b/src/com.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh deleted file mode 100755 index b081d6db..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -/usr/bin/rrd_cpu.pl & -/usr/bin/rrd_mem.pl & -/usr/bin/rrd_net.pl & -wait diff --git a/src/com.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py deleted file mode 100755 index 64297a87..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils -import VolumeUtils - -def main(): - if len(sys.argv) < 3: - sys.stderr.write("usage: %s VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - userList = sys.argv[2:] - - if not VolumeUtils.writeVolumeCifsConfiguration(volumeName, userList): - sys.stderr.write("Failed to update volume cifs configuration\n") - sys.exit(1) - if Utils.runCommand("service smb reload") != 0: - Utils.log("Failed to reload smb service") - sys.stderr.write("Failed to reload smb service\n") - sys.exit(2) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py b/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py deleted file mode 100644 index 49a12b69..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/Globals.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Storage Platform. -# - -MULTICAST_GROUP = '224.224.1.1' -MULTICAST_PORT = 24729 -GLUSTER_PROBE_STRING = "GLUSTERPROBE" -GLUSTER_PROBE_VERSION = "1.0.0" -DEFAULT_BUFSIZE = 1024 -SERVER_PORT = 24731 -DEFAULT_BACKLOG = 5 -DEFAULT_TIMEOUT = 3 -DEFAULT_ID_LENGTH = 16 -GLUSTER_PLATFORM_VERSION = "3.2" - -## System configuration constants -SYSCONFIG_NETWORK_DIR = "/etc/sysconfig/network-scripts" -FSTAB_FILE = "/etc/fstab" -SAMBA_CONF_FILE = "/etc/samba/smb.conf" -REAL_SAMBA_CONF_FILE = "/etc/samba/real.smb.conf" -MODPROBE_CONF_FILE = "/etc/modprobe.d/bonding.conf" -RESOLV_CONF_FILE = "/etc/resolv.conf" -VOLUME_USER_DESCRIPTION = "Gluster Volume User" -GLUSTER_BASE_DIR = "/etc/glustermg" -REEXPORT_DIR = "/reexport" -CIFS_EXPORT_DIR = "/cifs" - -## Derived constants -VOLUME_CONF_DIR = GLUSTER_BASE_DIR + "/volumes" -VOLUME_SMBCONF_FILE = VOLUME_CONF_DIR + "/volumes.smbconf.list" - -AWS_WEB_SERVICE_URL = "http://169.254.169.254/latest" -DEFAULT_UID = 1024000 -CIFS_USER_FILE = "/opt/glustermg/etc/users.cifs" -CIFS_VOLUME_FILE = "/opt/glustermg/etc/volumes.cifs" diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py b/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py deleted file mode 100644 index 3c90c533..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/Utils.py +++ /dev/null @@ -1,329 +0,0 @@ -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import re -import syslog -import subprocess -import time -import tempfile -import glob - -import Globals - -RUN_COMMAND_ERROR = -1024 -LOG_SYSLOG = 1 -SYSLOG_REQUIRED = False -LOG_FILE_NAME = None -LOG_FILE_OBJ = None -logOpened = False -sshCommandPrefix = "ssh -l root -q -i /opt/glustermg/keys/gluster.pem -o BatchMode=yes -o GSSAPIAuthentication=no -o PasswordAuthentication=no -o StrictHostKeyChecking=no".split() -try: - commandPath = "/opt/glustermg/%s/backend" % os.environ['GMG_VERSION'] -except KeyError, e: - commandPath = "/opt/glustermg/1.0.0/backend" - -def log(priority, message=None): - global logOpened - if not logOpened: - syslog.openlog(os.path.basename(sys.argv[0])) - logOpened = True - - if type(priority) == type(""): - logPriority = syslog.LOG_INFO - logMessage = priority - else: - logPriority = priority - logMessage = message - if not logMessage: - return - #if Globals.DEBUG: - # sys.stderr.write(logMessage) - else: - syslog.syslog(logPriority, logMessage) - return - - -def isString(value): - return (type(value) == type("") or type(value) == type(u"")) - - -def getTempFileName(): - filedesc, filename = tempfile.mkstemp(prefix="GSP_") - os.close(filedesc) - return filename - - -def readFile(fileName, lines=False): - content = None - try: - fp = open(fileName) - if lines: - content = fp.readlines() - else: - content = fp.read() - fp.close() - return content - except IOError, e: - log("failed to read file %s: %s" % (fileName, str(e))) - if lines: - return [] - else: - return "" - - -def writeFile(fileName, content): - try: - fp = open(fileName, "w") - if isString(content): - fp.write(content) - elif type(content) == type([]): - fp.writelines(content) - fp.close() - return True - except IOError, e: - log("failed to write file %s: %s" % (fileName, str(e))) - return False - - -def removeFile(fileName, root=False): - if root: - if runCommand("rm %s" % fileName, root=True) == 0: - return True - return False - try: - os.remove(fileName) - return True - except OSError, e: - log("Failed to remove file %s: %s" % (fileName, str(e))) - return False - - -def runCommandBG(command, stdinFileObj=None, stdoutFileObj=None, stderrFileObj=None, - shell=False, root=None): - if shell: - if not isString(command): - return None - else: - if isString(command): - command = command.split() - - if root == True: - if shell: - command = "sudo " + command - else: - command = ['sudo'] + command - elif isString(root): - if shell: - command = "sudo -u " + root + " " + command - else: - command = ['sudo', '-u', root] + command - - if not stdinFileObj: - stdinFileObj=subprocess.PIPE - if not stdoutFileObj: - stdoutFileObj=subprocess.PIPE - if not stderrFileObj: - stderrFileObj=subprocess.PIPE - - try: - process = subprocess.Popen(command, - bufsize=-1, - stdin=stdinFileObj, - stdout=stdoutFileObj, - stderr=stderrFileObj, - shell=shell) - return process - except OSError, e: - log("runCommandBG(): Failed to run command [%s]: %s" % (command, e)) - return None - - -def runCommand(command, - input='', output=False, - shell=False, root=None): - rv = {} - rv["Status"] = RUN_COMMAND_ERROR - rv["Stdout"] = None - rv["Stderr"] = None - - try: - stdinFileName = getTempFileName() - stdinFileObj = open(stdinFileName, "w") - stdinFileObj.write(input) - stdinFileObj.close() - stdinFileObj = open(stdinFileName, "r") - - stdoutFileName = getTempFileName() - stdoutFileObj = open(stdoutFileName, "w") - - stderrFileName = getTempFileName() - stderrFileObj = open(stderrFileName, "w") - except IOError, e: - log("Failed to create temporary file for executing command [%s]: %s" % (command, e)) - if output: - return rv - return rv["Status"] - - stdoutContent = None - stderrContent = None - - process = runCommandBG(command, - stdinFileObj=stdinFileObj, - stdoutFileObj=stdoutFileObj, - stderrFileObj=stderrFileObj, - shell=shell, root=root) - if process: - rv['Status'] = process.wait() - rv['Stdout'] = readFile(stdoutFileName) - rv['Stderr'] = readFile(stderrFileName) - - os.remove(stdinFileName) - os.remove(stdoutFileName) - os.remove(stderrFileName) - - if output: - return rv - return rv["Status"] - - -def daemonize(): - try: - pid = os.fork() - if pid > 0: - # exit first parent - sys.exit(0) - except OSError, e: - #sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror)) - return False - - # decouple from parent environment - os.chdir("/") - os.setsid() - os.umask(0) - - # do second fork - try: - pid = os.fork() - if pid > 0: - # exit from second parent - sys.exit(0) - except OSError, e: - #sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror)) - return False - - # redirect standard file descriptors - sys.stdout.flush() - sys.stderr.flush() - si = file("/dev/null", 'r') - so = file("/dev/null", 'a+') - se = file("/dev/null", 'a+', 0) - os.dup2(si.fileno(), sys.stdin.fileno()) - os.dup2(so.fileno(), sys.stdout.fileno()) - os.dup2(se.fileno(), sys.stderr.fileno()) - return True - - -def getMeminfo(): - lines = readFile("/proc/meminfo", lines=True) - re_parser = re.compile(r'^(?P\S*):\s*(?P\d*)\s*kB' ) - result = {} - for line in lines: - match = re_parser.match(line) - if not match: - continue # skip lines that don't parse - key, value = match.groups(['key', 'value']) - result[key] = int(value) - result['MemUsed'] = (result['MemTotal'] - result['MemFree'] - result['Buffers'] - result['Cached']) - return result - - -def _getCpuStatList(): - lines = readFile("/proc/stat", lines=True) - if not lines: - return None - return map(float, lines[0].split()[1:5]) - - -def getCpuUsageAvg(): - st1 = _getCpuStatList() - #time1 = time.time() - time.sleep(1) - st2 = _getCpuStatList() - #time2 = time.time() - if not (st1 and st2): - return None - usageTime = (st2[0] - st1[0]) + (st2[1] - st1[1]) + (st2[2] - st1[2]) - try: - return (100.0 * usageTime) / (usageTime + (st2[3] - st1[3])) - except ZeroDivisionError, e: - return 0 - - -def convertKbToMb(kb): - return kb / 1024.0 - - -def getDeviceFormatStatusFile(device): - return "/var/tmp/format_%s.status" % device.replace('/', '_') - - -def getDeviceFormatLockFile(device): - return "/var/lock/format_%s.lock" % device.replace('/', '_') - - -def getDeviceFormatOutputFile(device): - return "/var/tmp/format_%s.out" % device.replace('/', '_') - - -def getGlusterVersion(): - rv = runCommand("/usr/sbin/gluster --version", output=True) - if rv["Stderr"]: - return None - if rv["Status"] != 0: - return None - if not rv["Stdout"]: - return None - return rv["Stdout"].strip().split()[1] - - -def getCifsUserUid(userName): - lines = readFile(Globals.CIFS_USER_FILE, lines=True) - for line in lines: - if not line.strip(): - continue - tokens = line.strip().split(":") - if tokens[1] == userName: - return int(tokens[0]) - return None - -def grun(serverFile, command, argumentList=[]): - commandList = ["%s/%s" % (commandPath, command)] + argumentList - serverNameList = readFile(serverFile, lines=True) - if not serverNameList: - return 1 - status = True - for serverName in serverNameList: - rv = runCommand(sshCommandPrefix + [serverName.strip()] + commandList, output=True) - if rv["Status"] != 0: - sys.stderr.write("%s: %s\n" % (serverName.strip(), rv["Status"])) - sys.stderr.write("Stdout:\n%s\n" % rv["Stdout"]) - sys.stderr.write("Stderr:\n%s\n" % rv["Stderr"]) - sys.stderr.write("---\n") - status = False - - if status: - return 0 - else: - return 2 - -def getFileSystemType(): - return [os.path.basename(i).split('.')[1] for i in glob.glob("/sbin/mkfs.*")] diff --git a/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py b/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py deleted file mode 100644 index d55ef07a..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py +++ /dev/null @@ -1,332 +0,0 @@ -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import xml -import xml.parsers.expat -import xml.dom.minidom as MDOM -import os -import Globals -import Utils - -XML_STRING = 0 -XML_FILE = 1 - -class XDOM: - _domObj = None - - def __init__(self): - self._domObj = MDOM.Document() - return - - @classmethod - def getText(self, nodeList): - rc = "" - for node in nodeList: - if node.nodeType == node.TEXT_NODE: - rc = rc + node.data - return rc - - def parseString(self, requestString): - try: - self._domObj = MDOM.parseString(requestString) - except xml.parsers.expat.ExpatError, e: - Utils.log("XML string parse error: %s" % str(e)) - return False - return True - - def parseFile(self, fileName): - try: - self._domObj = MDOM.parse(fileName) - except IOError, e: - Utils.log("error reading file: %s" % str(e)) - return False - except xml.parsers.expat.ExpatError, e: - Utils.log("XML file %s parse error: %s" % (fileName, str(e))) - return False - return True - - def setDomObj(self, dom): - if dom and type(dom) != type([]): - self._domObj = dom - return True - return False - - def createTag(self, tag, text=None): - if not self._domObj: - return None - if tag == None: - return None - - tagE = self._domObj.createElement(str(tag)) - if text: - tagEText = self._domObj.createTextNode(str(text)) - tagE.appendChild(tagEText) - return tagE - - def addTag(self, tag): - if not self._domObj: - return False - if not tag: - return False - - self._domObj.appendChild(tag) - return True - - def createTagRoute(self, tagRoute, text=None): - if not tagRoute: - return False - - tagList = tagRoute.split(".") - tag = None - previousTag = None - for tagName in tagList[:-1]: - newTag = self.createTag(tagName, None) - if not tag: - tag = newTag - previousTag = newTag - continue - previousTag.appendChild(newTag) - previousTag = newTag - - if previousTag: - previousTag.appendChild(self.createTag(tagList[-1], text)) - else: - tag = self.createTag(tagList[-1], text) - return tag - - def appendTagRoute(self, tagRoute, value=None): - if not self._domObj: - return False - if not tagRoute: - return False - - parentTagE = self._domObj - - tagNameList = tagRoute.split(".") - newTagRoute = tagNameList.pop(-1) - - for i in range(len(tagNameList), 0, -1): - tagE = self.getElementsByTagRoute(".".join(tagNameList[:i])) - if tagE: - parentTagE = tagE[0] - break - newTagRoute = tagNameList[i-1] + "." + newTagRoute - - newTagE = self.createTagRoute(newTagRoute, value) - if not newTagE: - return False - try: - parentTagE.appendChild(newTagE) - except xml.dom.HierarchyRequestErr, e: - Utils.log("error occured. %s" + str(e)) - return False - return True - - def setTextByTagRoute(self, tagRoute, tagValue): - if not self._domObj: - return None - - if not tagRoute: - return None - - tagE = self.getElementsByTagRoute(tagRoute) - if not tagE: - return False - - parentTagE = self.getElementsByTagRoute(".".join(tagRoute.split(".")[:-1])) - if not parentTagE: - return False - - parentTagE[0].childNodes.remove(tagE[0]) - parentTagE[0].appendChild(self.createTag(tagRoute.split(".")[-1], tagValue)) - return True - - def getElementsByTagRoute(self, tagRoute): - if not self._domObj: - return None - - if not tagRoute: - return None - - x = None - for tag in tagRoute.split("."): - if x is None: - x = self._domObj.getElementsByTagName(tag) - continue - if x == []: - break - x = x[0].getElementsByTagName(tag) - return x - - def getTextByTagRoute(self, tagRoute): - if not self._domObj: - return None - - x = self.getElementsByTagRoute(tagRoute) - if x: - return self.getText(x[0].childNodes) - return None - - def getElementsByTagName(self, name): - if not self._domObj: - return None - return self._domObj.getElementsByTagName(name) - - def writexml(self, fileName, indent="", addindent="", newl=""): - if not self._domObj: - return None - try: - fp = open(fileName, "w") - self._domObj.writexml(fp, indent, addindent, newl) - fp.close() - return True - except IOError, e: - return False - - def toString(self, indent=" ", newl="\n", encoding = None): - if not self._domObj: - return None - return self._domObj.toprettyxml(indent, newl, encoding) - - def toxml(self, encoding = None): - if not self._domObj: - return None - return self._domObj.toxml(encoding) - - def toprettyxml(self, indent=" ", newl="\n", encoding = None): - return self.toString(indent, newl, encoding) - - def createResponseTag(self): - responseTag = self._domObj.createElement("response") - return responseTag -##--end of XDOM - -class RequestXml(XDOM): - def __init__(self, requestString, type=None): - if None == requestString: - XDOM.__init__(self) - return - try: - if None == type: - if os.path.isfile(requestString): - self._domObj = MDOM.parse(requestString) - else: - self._domObj = MDOM.parseString(requestString) - elif XML_FILE == type: - self._domObj = MDOM.parse(requestString) - elif XML_STRING == type: - self._domObj = MDOM.parseString(requestString) - except IOError, e: - XDOM.__init__(self) - except xml.parsers.expat.ExpatError, e: - XDOM.__init__(self) - -##--end of RequestXML - - -class ResponseXml(XDOM): - _responseTag = None - def __init__(self): - XDOM.__init__(self) - self._responseTag = self.createResponseTag() - self._domObj.appendChild(self._responseTag) - - @classmethod - def errorResponse(self, message): - if not self.responseTag: - return False - self.appendTagRoute("status.code", "-1"); - self.appendTagRoute("status.message", message) - - def append(self, tagName, tagValue=None): - if not self._responseTag: - return False - tag = self.createTag(tagName, tagValue) - if tag: - self._responseTag.appendChild(tag) - return True - return False - - def appendTag(self, tag): - if not tag: - return False - if not self._responseTag: - return False - self._responseTag.appendChild(tag) - return True - - def appendTagRoute(self, tagRoute, value=None): - if not self._responseTag: - return None - if not tagRoute: - return None - - parentTagE = self._responseTag - - tagNameList = tagRoute.split(".") - newTagRoute = tagNameList.pop(-1) - - for i in range(len(tagNameList), 0, -1): - tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) - if tagE: - parentTagE = tagE[0] - break - newTagRoute = tagNameList[i-1] + "." + newTagRoute - - newTagE = self.createTagRoute(newTagRoute, value) - if not newTagE: - return None - try: - parentTagE.appendChild(newTagE) - except xml.dom.HierarchyRequestErr, e: - Utils.log("error occured. %s" + str(e)) - return None - return newTagE - - def appendTagRouteOld(self, tagRoute, value=None): - if not self._responseTag: - return False - if not tagRoute: - return False - - parentTagE = self._responseTag - - tagNameList = tagRoute.split(".") - newTagRoute = tagNameList.pop(-1) - - for i in range(len(tagNameList), 0, -1): - tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) - if tagE: - parentTagE = tagE[0] - break - newTagRoute = tagNameList[i-1] + "." + newTagRoute - - newTagE = self.createTagRoute(newTagRoute, value) - if not newTagE: - return False - try: - parentTagE.appendChild(newTagE) - except xml.dom.HierarchyRequestErr, e: - Utils.log("error occured. %s" + str(e)) - return False - return True -##--end of ResponseXml - -def test(): - rs = ResponseXml() - rs.appendTagRoute("status.code", "0"); - rs.appendTagRoute("status.message", "SUCCESS") - serverTag = rs.appendTagRoute("server.name", "Server1") - networkInterfaces = rs.appendTagRoute("server.networkInterfaces", None) - networkTag = rs.createTag("networkInterface", None) - networkTag.appendChild(rs.createTag("name", "interface1")) - networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.40")) - networkInterfaces.appendChild(networkTag) - networkTag = rs.createTag("networkInterface", None) - networkTag.appendChild(rs.createTag("name", "interface2")) - networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.41")) - networkInterfaces.appendChild(networkTag) - print rs.toprettyxml() - -#test() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py deleted file mode 100755 index adfd031c..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def getUid(userName): - lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) - for line in lines: - tokens = line.strip().split(":") - if tokens[1] == userName: - return int(tokens[0]) - return None - - -def getLastUid(): - lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) - if not lines: - return Globals.DEFAULT_UID - return int([line.strip().split(':')[0] for line in lines if line.strip()][-1]) - - -def setUid(uid, userName): - try: - fp = open(Globals.CIFS_USER_FILE, "a") - fp.write("%s:%s\n" % (uid, userName)) - fp.close() - return True - except IOError, e: - Utils.log("failed to write file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) - return False - - -def main(): - if len(sys.argv) < 4: - sys.stderr.write("usage: %s SERVER_FILE USERNAME PASSWORD\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverFile = sys.argv[1] - userName = sys.argv[2] - password = sys.argv[3] - - existingUser = False - uid = getUid(userName) - if not uid: - uid = getLastUid() - if not uid: - sys.stderr.write("Unable to read file %s\n" % Globals.CIFS_USER_FILE) - sys.exit(10) - uid += 1 - else: - existingUser = True - - print (serverFile, uid, userName, password) - rv = Utils.grun(serverFile, "add_user_cifs.py", [uid, userName, password]) - if existingUser: - sys.exit(rv) - - if rv == 0: - if not setUid(uid, userName): - sys.stderr.write("Failed to add the user\n") - sys.exit(11) - sys.exit(rv) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py deleted file mode 100755 index 8a43e7dc..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def addVolumeCifsConf(volumeName, userList): - lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) - try: - fp = open(Globals.CIFS_VOLUME_FILE, "w") - for line in lines: - if not line.strip(): - continue - if line.strip().split(":")[0] != volumeName: - fp.write("%s\n" % line) - fp.write("%s:%s\n" % (volumeName, ":".join(userList))) - fp.close() - except IOError, e: - Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) - return False - return True - - -def main(): - if len(sys.argv) < 4: - sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverFile = sys.argv[1] - volumeName = sys.argv[2] - userList = sys.argv[3:] - - missingUserList = [] - for userName in userList: - if not Utils.getCifsUserUid(userName): - missingUserList.append(userName) - - if missingUserList: - sys.stderr.write("User %s does not exists\n" % missingUserList) - sys.exit(1) - - rv = Utils.grun(serverFile, "create_volume_cifs.py", [volumeName] + userList) - if rv == 0: - if not addVolumeCifsConf(volumeName, userList): - sys.stderr.write("Failed to add volume %s and user-list %s in cifs volume configuration\n" % (volumeName, userList)) - sys.exit(11) - sys.exit(rv) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py deleted file mode 100755 index a86e7264..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def removeUser(userName): - lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) - try: - fp = open(Globals.CIFS_USER_FILE, "w") - for line in lines: - if not line.strip(): - continue - if line.split(":")[1] == userName: - continue - fp.write("%s\n" % line) - fp.close() - except IOError, e: - Utils.log("failed to write file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) - return False - return True - - -def main(): - if len(sys.argv) < 3: - sys.stderr.write("usage: %s SERVER_FILE USERNAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverFile = sys.argv[1] - userName = sys.argv[2] - - rv = Utils.grun(serverFile, "delete_user_cifs.py", [userName]) - if rv == 0: - if not removeUser(userName): - Utils.log("Failed to remove the user:%s on gateway server\n" % userName) - sys.exit(0) - sys.exit(rv) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py deleted file mode 100755 index 925a3548..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def removeVolumeCifsConf(volumeName): - lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) - try: - fp = open(Globals.CIFS_VOLUME_FILE, "w") - for line in lines: - if not line.strip(): - continue - if line.strip().split(":")[0] != volumeName: - fp.write("%s\n" % line) - fp.close() - except IOError, e: - Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) - return False - return True - - -def main(): - if len(sys.argv) < 3: - sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverFile = sys.argv[1] - volumeName = sys.argv[2] - - rv = Utils.grun(serverFile, "delete_volume_cifs.py", [volumeName]) - if rv == 0: - if not removeVolumeCifsConf(volumeName): - sys.stderr.write("Failed to remove volume %s and user-list in cifs volume configuration\n" % volumeName) - sys.exit(11) - sys.exit(rv) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py deleted file mode 100755 index c072a556..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def main(): - if len(sys.argv) < 2: - sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - volumeName = sys.argv[1] - - lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) - for line in lines: - if not line.strip(): - continue - tokens = line.strip().split(":") - if tokens[0] == volumeName: - print "\n".join(tokens[1:]) - sys.exit(0) - # given volume is not configured for cifs export - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh b/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh deleted file mode 100755 index 6c7ac998..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh +++ /dev/null @@ -1,26 +0,0 @@ -#----------------------------------------------------------------------------------- -# gmg-reset-password.sh - script to reset password of given user to default password -#----------------------------------------------------------------------------------- - -USAGE_ERR=1 - -if [ $# -ne 1 ]; then - echo "Usage: ${0} " - echo - exit ${USAGE_ERR} -fi - -CURR_DIR=${PWD} -SCRIPT_PATH=`readlink -f ${0}` -GLUSTERMG_DIR=`dirname ${SCRIPT_PATH}` - -# Main action body -cd ${GLUSTERMG_DIR} -cd .. -for FILE in WEB-INF/lib/*.jar -do - export CLASSPATH=${CLASSPATH}:${PWD}/${FILE} -done -export CLASSPATH=${PWD}/WEB-INF/classes:${CLASSPATH} -cd ${CURR_DIR} -java com.gluster.storage.management.gateway.utils.PasswordManager reset ${1} diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/grun.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/grun.py deleted file mode 100755 index 6519d726..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/grun.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - - -if len(sys.argv) < 3: - sys.stderr.write("usage: %s SERVER_FILE COMMAND [ARGUMENTS]\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - -sys.exit(Utils.grun(sys.argv[1], sys.argv[2], sys.argv[3:])) diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py deleted file mode 100755 index ded207c0..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import socket -import select -import signal -import random -import string -import Utils -import Globals - -running = True - - -def exitHandler(signum, frame): - running = False - - -def sendMulticastRequest(idString): - multicastSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) - multicastSocket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) - multicastSocket.sendto("%s,%s,%s\n" % (Globals.GLUSTER_PROBE_STRING, Globals.GLUSTER_PROBE_VERSION, idString), - (Globals.MULTICAST_GROUP, Globals.MULTICAST_PORT)) - return multicastSocket - - -def openServerSocket(): - try: - server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server.setblocking(0) - server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - server.bind(('', Globals.SERVER_PORT)) - server.listen(Globals.DEFAULT_BACKLOG) - return server - except socket.error, e: - Utils.log("failed to open server socket on port %s: %s" % (Globals.SERVER_PORT, str(e))) - sys.stderr.write("failed to open server socket on port %s: %s\n" % (Globals.SERVER_PORT, str(e))) - sys.exit(1) - - -def main(): - signal.signal(signal.SIGINT, exitHandler) - signal.signal(signal.SIGTERM, exitHandler) - signal.signal(signal.SIGALRM, exitHandler) - - idString = ''.join(random.choice(string.ascii_lowercase + - string.ascii_uppercase + - string.digits) for x in range(Globals.DEFAULT_ID_LENGTH)) - - multicastSocket = sendMulticastRequest(idString) - - serverInfoDict = {} - serverSocket = openServerSocket() - rlist = [serverSocket] - signal.alarm(Globals.DEFAULT_TIMEOUT) - while running: - try: - ilist,olist,elist = select.select(rlist, [], [], 0.1) - except select.error, e: - Utils.log("failed to read from connections: %s" % str(e)) - break - for sock in ilist: - # handle new connection - if sock == serverSocket: - clientSocket, address = serverSocket.accept() - clientSocket.setblocking(0) - #print "connection from %s on %s" % (address, clientSocket) - rlist.append(clientSocket) - continue - - # handle all other sockets - data = sock.recv(Globals.DEFAULT_BUFSIZE) - if not data: - #print "closing socket %s" % sock - sock.close() - rlist.remove(sock) - tokens = data.strip().split(",") - if len(tokens) != 6: - continue - if not (tokens[0] == Globals.GLUSTER_PROBE_STRING and \ - tokens[1] == Globals.GLUSTER_PROBE_VERSION and \ - tokens[2] == idString): - continue - serverInfoDict[tokens[3]] = [tokens[4], tokens[5]] - #print "closing socket %s" % sock - sock.close() - rlist.remove(sock) - - for sock in rlist: - sock.close() - - for k, v in serverInfoDict.iteritems(): - if v[0]: - print v[0] - else: - print k - - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py deleted file mode 100755 index 27fb9b92..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def main(): - if len(sys.argv) < 3: - sys.stderr.write("usage: %s SERVER_NAME VOLUME_FILE\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverName = sys.argv[1] - volumeFile = sys.argv[2] - - lines = Utils.readFile(volumeFile, lines=True) - volumeNameList = [line.strip() for line in lines] - if not volumeNameList: - sys.exit(0) - - lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) - cifsVolumeList = [line.strip().split(":")[0] for line in lines if line.strip()] - runningCifsVolumeList = set(cifsVolumeList).intersection(set(volumeNameList)) - - if not runningCifsVolumeList: - sys.exit(0) - - tempFileName = Utils.getTempFileName() - try: - fp = open(tempFileName, "w") - fp.write("%s\n" % serverName) - fp.close() - except IOError, e: - Utils.log("Failed to write server name to file %s: %s" % (tempFileName, str(e))) - sys.stderr.write("Failed to write server name to file %s: %s\n" % (tempFileName, str(e))) - sys.exit(3) - - status = True - for volumeName in runningCifsVolumeList: - if Utils.grun(tempFileName, "stop_volume_cifs.py", [volumeName.strip()]) != 0: - status = False - if Utils.grun(tempFileName, "delete_volume_cifs.py", [volumeName.strip()]) != 0: - status = False - - try: - os.remove(tempFileName) - except OSError, e: - Utils.log("Failed to remove temporary file %s: %s" % (tempFileName, str(e))) - sys.stderr.write("Failed to remove temporary file %s: %s\n" % (tempFileName, str(e))) - pass - - if status: - sys.exit(0) - else: - sys.exit(2) - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py deleted file mode 100755 index e7e0a4a0..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Utils - - -def main(): - if len(sys.argv) < 2: - sys.stderr.write("usage: %s SERVER_FILE\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverFile = sys.argv[1] - - rv = Utils.grun(serverFile, "setup_cifs_config.py") - sys.exit(rv) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py b/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py deleted file mode 100755 index e5576c45..00000000 --- a/src/com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python -# Copyright (C) 2011 Gluster, Inc. -# This file is part of Gluster Management Gateway. -# - -import os -import sys -p1 = os.path.abspath(os.path.dirname(sys.argv[0])) -p2 = "%s/common" % os.path.dirname(p1) -if not p1 in sys.path: - sys.path.append(p1) -if not p2 in sys.path: - sys.path.append(p2) -import Globals -import Utils - - -def updateVolumeCifsConf(volumeName, userList): - lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) - try: - fp = open(Globals.CIFS_VOLUME_FILE, "w") - for line in lines: - if not line.strip(): - continue - if line.strip().split(":")[0] == volumeName: - fp.write("%s:%s\n" % (volumeName, ":".join(userList))) - else: - fp.write("%s\n" % line.strip()) - fp.close() - except IOError, e: - Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) - return False - return True - - -def main(): - if len(sys.argv) < 4: - sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) - sys.exit(-1) - - serverFile = sys.argv[1] - volumeName = sys.argv[2] - userList = sys.argv[3:] - - missingUserList = [] - for userName in userList: - if not Utils.getCifsUserUid(userName): - missingUserList.append(userName) - - if missingUserList: - sys.stderr.write("User %s does not exists\n" % missingUserList) - sys.exit(1) - - rv = Utils.grun(serverFile, "update_volume_cifs.py", [volumeName] + userList) - if rv == 0: - if not updateVolumeCifsConf(volumeName, userList): - sys.stderr.write("Failed to update volume %s and user-list %s in cifs volume configuration\n" % (volumeName, userList)) - sys.exit(11) - sys.exit(rv) - - -if __name__ == "__main__": - main() diff --git a/src/com.gluster.storage.management.gateway/.classpath b/src/com.gluster.storage.management.gateway/.classpath deleted file mode 100644 index 107e139d..00000000 --- a/src/com.gluster.storage.management.gateway/.classpath +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/.project b/src/com.gluster.storage.management.gateway/.project deleted file mode 100644 index 83fea45d..00000000 --- a/src/com.gluster.storage.management.gateway/.project +++ /dev/null @@ -1,36 +0,0 @@ - - - com.gluster.storage.management.gateway - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.jdt.core.javanature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/src/com.gluster.storage.management.gateway/.settings/.jsdtscope b/src/com.gluster.storage.management.gateway/.settings/.jsdtscope deleted file mode 100644 index 3a28de0c..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/.jsdtscope +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index d159aeca..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Tue Sep 20 14:10:09 IST 2011 -eclipse.preferences.version=1 -encoding//src/rebel.xml=UTF-8 diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 476db350..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Dec 29 14:57:23 IST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs deleted file mode 100644 index 5d9c71b6..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Mon Jan 31 15:29:36 IST 2011 -eclipse.preferences.version=1 -org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 3d5a50bf..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 8f960f27..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a4..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b6..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs b/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs deleted file mode 100644 index e5ca6272..00000000 --- a/src/com.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Mon Jan 31 15:29:36 IST 2011 -eclipse.preferences.version=1 -org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/src/com.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF b/src/com.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF deleted file mode 100644 index 5e949512..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt deleted file mode 100644 index d24fbfdb..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt +++ /dev/null @@ -1,135 +0,0 @@ -The GNU General Public License (GPL) Version 2, June 1991 - - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification follow. - - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. - - c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - One line to give the program's name and a brief idea of what it does. - - Copyright (C) - - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. - - signature of Ty Coon, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. - - -"CLASSPATH" EXCEPTION TO THE GPL VERSION 2 - -Certain source files distributed by Oracle are subject to the following clarification and special exception to the GPL Version 2, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the License file that accompanied this code." - -Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination. - -As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt deleted file mode 100644 index b3acf520..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt +++ /dev/null @@ -1,188 +0,0 @@ - -DO NOT TRANSLATE OR LOCALIZE. - -%% The following software may be included in this product: ASM - Use of any of this software is governed by the terms of the license below: - -Copyright (c) 2000-2005 INRIA, France Telecom -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. - - -%% The following software may be included in this product: Jettison - Use of any of this software is governed by the terms of the license below: - - -Copyright 2006 Envoi Solutions LLC - -Licensed 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. - --------------------------------------------------------------------------- - -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and - - 2. You must cause any modified files to carry prominent notices stating that You changed the files; and - - 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. -Copyright [yyyy] [name of copyright owner] Licensed 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. - - - -%% The following software may be included in this product: Jackson - Use of any of this software is governed by the terms of the license below: - - -Jackson is dual-licensed under two alternative popular Open Source licenses: Apache (AL 2.0) and Gnu Lesser GPL (LGPL 2.1). You choose one or the other, as necessary (if you want to redistribute the code ¿ for use, you do not need license), and abide by the license rules as defined by the respective license agreement (and only that one). - --------------------------------------------------------------------------- - -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and - - 2. You must cause any modified files to carry prominent notices stating that You changed the files; and - - 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. -Copyright [yyyy] [name of copyright owner] Licensed 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. - - diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar deleted file mode 100644 index 3702b645..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar deleted file mode 100644 index 578b1a0c..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar deleted file mode 100644 index 8217cae0..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar deleted file mode 100644 index 41e230fe..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar deleted file mode 100644 index 8758a96b..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar deleted file mode 100644 index dc8ae8df..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar deleted file mode 100644 index ca367aae..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar deleted file mode 100644 index c8c4dbb9..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt deleted file mode 100644 index 3eddd42f..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt +++ /dev/null @@ -1,87 +0,0 @@ -Copyright (c) 2006 - 2010 Christian Plattner. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -a.) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -b.) Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -c.) Neither the name of Christian Plattner nor the names of its contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - - -This software includes work that was released under the following license: - -Copyright (c) 2005 - 2006 Swiss Federal Institute of Technology (ETH Zurich), - Department of Computer Science (http://www.inf.ethz.ch), - Christian Plattner. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -a.) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -b.) Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -c.) Neither the name of ETH Zurich nor the names of its contributors may - be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - - -The Java implementations of the AES, Blowfish and 3DES ciphers have been -taken (and slightly modified) from the cryptography package released by -"The Legion Of The Bouncy Castle". - -Their license states the following: - -Copyright (c) 2000 - 2004 The Legion Of The Bouncy Castle -(http://www.bouncycastle.org) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar deleted file mode 100644 index c0a9ac7b..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar deleted file mode 100644 index 4c9ac4e9..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar deleted file mode 100644 index c1c81141..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar deleted file mode 100644 index a3248188..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar deleted file mode 100644 index faf12cf6..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar deleted file mode 100644 index ca612580..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar deleted file mode 100644 index 57c2c670..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar deleted file mode 100644 index 8f692f4f..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar deleted file mode 100644 index 62f790fa..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar deleted file mode 100644 index 92b38466..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar deleted file mode 100644 index 01d8c83b..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar deleted file mode 100644 index 1c134f05..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar deleted file mode 100644 index a29d7409..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar deleted file mode 100644 index c79b4490..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar deleted file mode 100644 index e4e9c8c3..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar deleted file mode 100644 index 23782c02..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar deleted file mode 100644 index ec8bc818..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar deleted file mode 100644 index 6d225b76..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar deleted file mode 100644 index 3f9d8476..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar deleted file mode 100644 index 48cc9295..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar deleted file mode 100644 index a5d37aa1..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar deleted file mode 100644 index db6f529f..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar deleted file mode 100644 index 7cd3a626..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar deleted file mode 100644 index 11fc11b9..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar deleted file mode 100644 index f2e2e927..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar deleted file mode 100644 index bd1367d8..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar deleted file mode 100644 index e46f9eb8..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar deleted file mode 100644 index ea9500d6..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar deleted file mode 100644 index 6ef99d8d..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar deleted file mode 100644 index e149290e..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar deleted file mode 100644 index dcd1e4d9..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar deleted file mode 100644 index f7a3b837..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar deleted file mode 100644 index 9cea2aef..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar deleted file mode 100644 index d0550ccd..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar deleted file mode 100644 index 1688cf74..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd deleted file mode 100644 index b3aa6af8..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd +++ /dev/null @@ -1,21 +0,0 @@ -Library-SymbolicName: org.springframework.spring -Library-Version: 3.0.5.RELEASE -Library-Name: Spring Framework -Import-Bundle: - org.springframework.aop;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.asm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.aspects;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.beans;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.context;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.context.support;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.core;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.expression;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.jdbc;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.jms;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.orm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.oxm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.transaction;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.web;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.web.servlet;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - org.springframework.web.portlet;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", - com.springsource.org.aopalliance;version="[1.0.0, 1.0.0]" diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar deleted file mode 100644 index 237995c5..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar deleted file mode 100644 index 2f52122b..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar deleted file mode 100644 index 5a2381a0..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar deleted file mode 100644 index 6ec9d681..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar deleted file mode 100644 index 6d13bd40..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar deleted file mode 100644 index e351ae7b..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar deleted file mode 100644 index e5bc672b..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar deleted file mode 100644 index f1f4fdd2..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt deleted file mode 100644 index 261eeb9e..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt deleted file mode 100644 index 261eeb9e..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar deleted file mode 100644 index 78818fc5..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar deleted file mode 100644 index a8077d5d..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar deleted file mode 100644 index 26611b55..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml b/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml deleted file mode 100644 index 750ef171..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - glustermg - - index.html - index.htm - index.jsp - default.html - default.htm - default.jsp - - - contextConfigLocation - - classpath:spring/gluster-server-security.xml - classpath:spring/gluster-server-base.xml - - - - org.springframework.web.context.ContextLoaderListener - - - org.springframework.web.context.request.RequestContextListener - - - com.gluster.storage.management.gateway.listeners.ShutdownListener - - - gluster-resources-1.0 - com.sun.jersey.spi.spring.container.servlet.SpringServlet - - com.sun.jersey.config.property.packages - com.gluster.storage.management.gateway.resources.v1_0 - - - com.sun.jersey.spi.container.ResourceFilters - com.gluster.storage.management.gateway.filters.GlusterResourceFilterFactory - - 1 - - - gluster-resources-1.0 - /1.0.0/* - - - JnlpDownloadServlet - jnlp.sample.servlet.JnlpDownloadServlet - - - JnlpDownloadServlet - *.jnlp - - - JnlpDownloadServlet - *.jar - - - springSecurityFilterChain - - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - - - - Gluster Management Gateway - /* - - - CONFIDENTIAL - - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql b/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql deleted file mode 100644 index 4c3d81d1..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql +++ /dev/null @@ -1,2 +0,0 @@ -create table version (version varchar(16) not null primary key); -insert into version(version) values('1.0.0'); \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql b/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql deleted file mode 100644 index 4f61fc9d..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql +++ /dev/null @@ -1,26 +0,0 @@ -create table users( - username varchar(32) not null primary key, - password varchar(124) not null, - enabled smallint not null - ); - - create table authorities ( - username varchar(32) not null, - authority varchar(50) not null, - constraint fk_authorities_users foreign key(username) references users(username)); - create unique index ix_auth_username on authorities (username,authority); - -create table groups ( - id bigint generated by default as identity(start with 0) primary key, - group_name varchar(50) not null); - -create table group_authorities ( - group_id bigint not null, - authority varchar(50) not null, - constraint fk_group_authorities_group foreign key(group_id) references groups(id)); - -create table group_members ( - id bigint generated by default as identity(start with 0) primary key, - username varchar(32) not null, - group_id bigint not null, - constraint fk_group_members_group foreign key(group_id) references groups(id)); diff --git a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql b/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql deleted file mode 100644 index 5bd73813..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Create users -insert into users(username, password, enabled) values ('gluster','syst3m',1); - --- Assign authorities to users (to be removed after implementing user group functionality) -insert into authorities(username,authority) values ('gluster','ROLE_USER'); -insert into authorities(username,authority) values ('gluster','ROLE_ADMIN'); - --- Create user groups -insert into groups(group_name) values ('Users'); -insert into groups(group_name) values ('Administrators'); - --- Add authorities to groups (functionality not yet implemented in code) -insert into group_authorities(group_id, authority) select id,'ROLE_USER' from groups where group_name='Users'; -insert into group_authorities(group_id, authority) select id,'ROLE_USER' from groups where group_name='Administrators'; -insert into group_authorities(group_id, authority) select id,'ROLE_ADMIN' from groups where group_name='Administrators'; - --- Assign group members -insert into group_members(group_id, username) select id,'gluster' from groups where group_name='Administrators'; \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql b/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql deleted file mode 100644 index 17ca62d2..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql +++ /dev/null @@ -1,16 +0,0 @@ -create table cluster_info ( - id bigint generated by default as identity, - name varchar(255), - primary key (id)); - -create unique index ix_cluster_name on cluster_info (name); - -create table server_info ( - id bigint generated by default as identity, - name varchar(255), - cluster_id bigint, - primary key (id)); - -create unique index ix_cluster_server on server_info (name, cluster_id); - -alter table server_info add constraint FK_CLUSTER_ID foreign key (cluster_id) references cluster_info(id); \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/index.html b/src/com.gluster.storage.management.gateway/WebContent/index.html deleted file mode 100644 index 5947cf11..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/index.html +++ /dev/null @@ -1,158 +0,0 @@ - - - Gluster Management Console - - - - - -

    Gluster Management Console

    -
    - Identifying your Operating System and CPU architecture... -
    - - -
    - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/Globals.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/Globals.py deleted file mode 120000 index 7d230498..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/Globals.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/common/Globals.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/Protocol.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/Protocol.py deleted file mode 120000 index 7ecad84d..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/Protocol.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/common/Protocol.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py deleted file mode 120000 index df26ff44..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/Utils.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/common/Utils.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py deleted file mode 120000 index 880349a1..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py deleted file mode 120000 index fec57917..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py deleted file mode 120000 index 03752d57..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py deleted file mode 120000 index d517e46c..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py deleted file mode 120000 index be9e627c..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py deleted file mode 120000 index 3eff03fd..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh b/src/com.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh deleted file mode 120000 index 13b9a40b..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py deleted file mode 120000 index 5e56bfbb..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/grun.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/grun.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py deleted file mode 120000 index 6288f182..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py deleted file mode 120000 index 32d1dec4..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py deleted file mode 120000 index e3f44800..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py b/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py deleted file mode 120000 index 8496fae4..00000000 --- a/src/com.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py +++ /dev/null @@ -1 +0,0 @@ -../../../com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore b/src/com.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore deleted file mode 100644 index 2efe19b0..00000000 Binary files a/src/com.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore and /dev/null differ diff --git a/src/com.gluster.storage.management.gateway/buckminster.cspex b/src/com.gluster.storage.management.gateway/buckminster.cspex deleted file mode 100644 index 31eb9d67..00000000 --- a/src/com.gluster.storage.management.gateway/buckminster.cspex +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/build/glusterserver.ant b/src/com.gluster.storage.management.gateway/build/glusterserver.ant deleted file mode 100644 index 98120ba4..00000000 --- a/src/com.gluster.storage.management.gateway/build/glusterserver.ant +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - -------------------------------------------------- - compile - Compile - archive - Generate WAR file - -------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/src/META-INF/persistence.xml b/src/com.gluster.storage.management.gateway/src/META-INF/persistence.xml deleted file mode 100644 index 36b252ea..00000000 --- a/src/com.gluster.storage.management.gateway/src/META-INF/persistence.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ClusterInfo.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ClusterInfo.java deleted file mode 100644 index 3e5ea01a..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ClusterInfo.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.data; - -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.OneToMany; - -import org.hibernate.cfg.AnnotationConfiguration; -import org.hibernate.tool.hbm2ddl.SchemaExport; - -@Entity(name="cluster_info") -public class ClusterInfo { - @Id - @GeneratedValue - private Integer id; - - private String name; - - @OneToMany(mappedBy="cluster") - private List servers = new ArrayList(); - - public void setId(Integer id) { - this.id = id; - } - - public Integer getId() { - return id; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setServers(List servers) { - this.servers = servers; - } - - public List getServers() { - return servers; - } - - public void addServer(ServerInfo server) { - servers.add(server); - } - - public static void main(String args[]) { - AnnotationConfiguration config = new AnnotationConfiguration(); - config.addAnnotatedClass(ClusterInfo.class); - config.addAnnotatedClass(ServerInfo.class); - config.configure(); - new SchemaExport(config).create(true, true); - } - -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/GlusterDataSource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/GlusterDataSource.java deleted file mode 100644 index 0802fe93..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/GlusterDataSource.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * GlusterDataSource.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.data; - -import javax.servlet.ServletContext; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.stereotype.Component; - -@Component -public class GlusterDataSource extends DriverManagerDataSource { - @Autowired - ServletContext servletContext; - - public GlusterDataSource() { - setDriverClassName(org.apache.derby.jdbc.EmbeddedDriver.class.getName()); - - setUsername("gluster"); - // TODO: change to a stronger (encrypted) password - setPassword("gluster"); - } - - public DriverManagerDataSource getDataSource() { - // Database directory = work/data relative to context root - setUrl("jdbc:derby:" + servletContext.getRealPath("data") + ";create=true"); - - return this; - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/PersistenceDao.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/PersistenceDao.java deleted file mode 100644 index eb7d6514..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/PersistenceDao.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.data; - -import java.util.List; - -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.PersistenceUnit; -import javax.persistence.Query; - -/** - * - */ -public class PersistenceDao { - private Class type; - - private EntityManager entityManager; - - @PersistenceUnit - private EntityManagerFactory entityManagerFactory; - - public PersistenceDao(Class type) { - this.type = type; - } - - public EntityTransaction startTransaction() { - EntityTransaction txn = getEntityManager().getTransaction(); - txn.begin(); - return txn; - } - - private synchronized EntityManager getEntityManager() { - if (entityManager == null) { - entityManager = entityManagerFactory.createEntityManager(); - } - return entityManager; - } - - public Object getSingleResult(String query) { - return getEntityManager().createQuery(query).getSingleResult(); - } - - public Object getSingleResult(String queryString, String... params) { - return createQuery(queryString, params).getSingleResult(); - } - - private Query createQuery(String queryString, String... params) { - Query query = getEntityManager().createQuery(queryString); - for (int i = 0; i < params.length; i++) { - query.setParameter(i + 1, params[i]); - } - return query; - } - - public Object getSingleResultFromSQL(String sqlQuery) { - return getEntityManager().createNativeQuery(sqlQuery).getSingleResult(); - } - - @SuppressWarnings("rawtypes") - public List findBySQL(String sqlQuery) { - return getEntityManager().createNativeQuery(sqlQuery).getResultList(); - } - - public T findById(int id) { - return getEntityManager().find(type, id); - } - - @SuppressWarnings("unchecked") - public List findAll() { - return getEntityManager().createQuery("select t from " + type.getName() + " t").getResultList(); - } - - @SuppressWarnings("unchecked") - public List findBy(String whereClause) { - return getEntityManager().createQuery("select t from " + type.getName() + " t where " + whereClause) - .getResultList(); - } - - @SuppressWarnings("unchecked") - public List findBy(String whereClause, String... params) { - return createQuery("select t from " + type.getName() + " t where " + whereClause, params).getResultList(); - } - - public void save(Object obj) { - getEntityManager().persist(obj); - } - - public T update(T obj) { - return getEntityManager().merge(obj); - } - - public void delete(Object obj) { - getEntityManager().remove(obj); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ServerInfo.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ServerInfo.java deleted file mode 100644 index a3f8c920..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/data/ServerInfo.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.data; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; - -/** - * - */ -@Entity(name="server_info") -public class ServerInfo { - @Id - @GeneratedValue - private Integer id; - - private String name; - - @ManyToOne - @JoinColumn(name="cluster_id") - private ClusterInfo cluster; - - public ServerInfo() { - } - - public ServerInfo(String name) { - setName(name); - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getId() { - return id; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setCluster(ClusterInfo cluster) { - this.cluster = cluster; - } - - public ClusterInfo getCluster() { - return cluster; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuditFilter.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuditFilter.java deleted file mode 100644 index f6702238..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuditFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * - */ -package com.gluster.storage.management.gateway.filters; - -import java.security.Principal; - -import org.apache.log4j.Logger; - -import com.sun.jersey.spi.container.ContainerRequest; -import com.sun.jersey.spi.container.ContainerRequestFilter; -import com.sun.jersey.spi.container.ContainerResponse; -import com.sun.jersey.spi.container.ContainerResponseFilter; -import com.sun.jersey.spi.container.ResourceFilter; - -/** - * Resource filter for maintaining audit trail of resource access - */ -public class AuditFilter implements ResourceFilter, ContainerRequestFilter, ContainerResponseFilter { - private static final Logger logger = Logger.getLogger(AuditFilter.class); - - @Override - public ContainerRequestFilter getRequestFilter() { - return this; - } - - @Override - public ContainerResponseFilter getResponseFilter() { - return this; - } - - @Override - public ContainerRequest filter(ContainerRequest req) { - Principal principal = req.getUserPrincipal(); - if(principal != null) { - logger.info("REQUEST from [" + principal.getName() + "] : [" + req.getMethod() + "][" + req.getPath() + "]"); - } else { - logger.info("REQUEST [" + req.getMethod() + "][" + req.getPath() + "]"); - } - return req; - } - - @Override - public ContainerResponse filter(ContainerRequest req, ContainerResponse response) { - logger.info("RESPONSE: [" + req.getMethod() + "][" + req.getPath() + "]"); - return response; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java deleted file mode 100644 index 73a1085e..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.filters; - -import java.io.CharArrayWriter; -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; -import javax.ws.rs.core.Response; - -/** - * @author root - * - */ -public class AuthenticationFailureFilter implements Filter { - - /* - * (non-Javadoc) - * - * @see javax.servlet.Filter#destroy() - */ - @Override - public void destroy() { - // TODO Auto-generated method stub - - } - - public class CharResponseWrapper extends HttpServletResponseWrapper { - private CharArrayWriter output; - - public String toString() { - return output.toString(); - } - - public CharResponseWrapper(HttpServletResponse response) { - super(response); - output = new CharArrayWriter(); - } - - public PrintWriter getWriter() { - return new PrintWriter(output); - } - } - - /* - * (non-Javadoc) - * - * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, - * javax.servlet.FilterChain) - */ - @Override - public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, - ServletException { - HttpServletRequest request = (HttpServletRequest) req; - if (request.getRequestURI().contains("download")) { - chain.doFilter(req, res); - return; - } - - CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse) res); - chain.doFilter(req, wrapper); - - if(wrapper.getStatus() == Response.Status.UNAUTHORIZED.ordinal()) { - PrintWriter out = res.getWriter(); - out.println("1Authentication Failed!"); - } - } - - /* - * (non-Javadoc) - * - * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) - */ - @Override - public void init(FilterConfig arg0) throws ServletException { - // TODO Auto-generated method stub - - } - -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java deleted file mode 100644 index 1c480f3f..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - */ -package com.gluster.storage.management.gateway.filters; - -import java.util.ArrayList; -import java.util.List; - -import com.sun.jersey.api.model.AbstractMethod; -import com.sun.jersey.spi.container.ResourceFilter; -import com.sun.jersey.spi.container.ResourceFilterFactory; - -/** - * Gluster resource filter factory. As of now, this creates only one filter - the audit filter {@code AuditFilter} - */ -public class GlusterResourceFilterFactory implements ResourceFilterFactory { - - public GlusterResourceFilterFactory() { - } - - /* (non-Javadoc) - * @see com.sun.jersey.spi.container.ResourceFilterFactory#create(com.sun.jersey.api.model.AbstractMethod) - */ - @Override - public List create(AbstractMethod arg0) { - List filters = new ArrayList(); - filters.add(new AuditFilter()); - - return filters; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java deleted file mode 100644 index 44b72252..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/listeners/ShutdownListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.listeners; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -import com.gluster.storage.management.gateway.utils.DBUtil; - -/** - * Shuts down the Derby database when gateway is being stopped. - */ -public class ShutdownListener implements ServletContextListener { - - /* (non-Javadoc) - * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) - */ - @Override - public void contextDestroyed(ServletContextEvent arg0) { - // Embedded derby must be shut down when the gateway stops. - DBUtil.shutdownDerby(); - System.gc(); - } - - /* (non-Javadoc) - * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) - */ - @Override - public void contextInitialized(ServletContextEvent arg0) { - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java deleted file mode 100644 index 9fc4fceb..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.resources.v1_0; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.StreamingOutput; -import javax.ws.rs.core.UriInfo; - -/** - * - */ -public class AbstractResource { - @Context - protected UriInfo uriInfo; - - /** - * Creates a response with HTTP status code of 201 (created) and sets the "location" header to the URI created using - * the given path relative to current path. - * - * @param relativePath - * relative path of the created resource - will be set in the "location" header of response. - * @return the {@link Response} object - */ - protected Response createdResponse(String relativePath) { - return Response.created(createRelatriveURI(relativePath)).build(); - } - - /** - * Creates a response with HTTP status code of 204 (no content) - * @return the {@link Response} object - */ - protected Response noContentResponse() { - return Response.noContent().build(); - } - - /** - * Creates a response with HTTP status code of 202 (accepted), also setting the location header to given location. - * This is typically done while triggering long running tasks - * - * @param locationURI - * URI to be appended to the base URI - * @return the {@link Response} object - */ - protected Response acceptedResponse(String locationURI) { - return Response.status(Status.ACCEPTED).location(createAbsoluteURI(locationURI)).build(); - } - - /** - * Creates a response with HTTP status code of 404 (not found), also setting the given message in the response body - * - * @param message - * Message to be set in the response body - * @return the {@link Response} object - */ - protected Response notFoundResponse(String message) { - return Response.status(Status.NOT_FOUND).type(MediaType.TEXT_HTML).entity(message).build(); - } - - /** - * Creates a new URI that is relative to the base URI of the application - * @param uriString URI String to be appended to the base URI - * @return newly created URI - */ - private URI createAbsoluteURI(String uriString) { - return uriInfo.getBaseUriBuilder().path(uriString).build(); - } - - /** - * Creates a response with HTTP status code of 204 (no content), also setting the location header to given location - * @param location path of the location to be set relative to current path - * @return the {@link Response} object - */ - protected Response noContentResponse(String location) { - return Response.noContent().location(createRelatriveURI(location)).build(); - } - - /** - * Creates a URI relative to current URI - * @param location path relative to current URI - * @return newly created URI - */ - protected URI createRelatriveURI(String location) { - return uriInfo.getAbsolutePathBuilder().path(location).build(); - } - - /** - * Creates a response with HTTP status code of 500 (internal server error) and sets the error message in the - * response body - * - * @param errMessage - * Error message to be set in the response body - * @return the {@link Response} object - */ - protected Response errorResponse(String errMessage) { - return Response.serverError().type(MediaType.TEXT_HTML).entity(errMessage).build(); - } - - /** - * Creates a response with HTTP status code of 400 (bad request) and sets the error message in the - * response body - * - * @param errMessage - * Error message to be set in the response body - * @return the {@link Response} object - */ - protected Response badRequestResponse(String errMessage) { - return Response.status(Status.BAD_REQUEST).type(MediaType.TEXT_HTML).entity(errMessage).build(); - } - - /** - * Creates a response with HTTP status code of 401 (unauthorized) - * - * @return the {@link Response} object - */ - protected Response unauthorizedResponse() { - return Response.status(Status.UNAUTHORIZED).build(); - } - - /** - * Creates an OK response and sets the entity in the response body. - * - * @param entity - * Entity to be set in the response body - * @param mediaType - * Media type to be set on the response - * @return the {@link Response} object - */ - protected Response okResponse(Object entity, String mediaType) { - return Response.ok(entity).type(mediaType).build(); - } - - /** - * Creates a streaming output response and sets the given streaming output in the response. Typically used for - * "download" requests - * - * @param entity - * Entity to be set in the response body - * @param mediaType - * Media type to be set on the response - * @return the {@link Response} object - */ - protected Response streamingOutputResponse(StreamingOutput output) { - return Response.ok(output).type(MediaType.APPLICATION_OCTET_STREAM).build(); - } - - protected StreamingOutput createStreamingOutput(final byte[] data) { - return new StreamingOutput() { - @Override - public void write(OutputStream output) throws IOException { - output.write(data); - } - }; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java deleted file mode 100644 index d0da6696..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CLUSTER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.response.ClusterNameListResponse; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.sun.jersey.api.core.InjectParam; -import com.sun.jersey.spi.resource.Singleton; - -/** - * - */ -@Component -@Singleton -@Path(RESOURCE_PATH_CLUSTERS) -public class ClustersResource extends AbstractResource { - @InjectParam - private ClusterService clusterService; - private static final Logger logger = Logger.getLogger(ClustersResource.class); - - @GET - @Produces(MediaType.APPLICATION_XML) - public ClusterNameListResponse getClusters() { - List clusters = clusterService.getAllClusters(); - List clusterList = new ArrayList(); - for (ClusterInfo cluster : clusters) { - clusterList.add(cluster.getName()); - } - return new ClusterNameListResponse(clusterList); - } - - @POST - public Response createCluster(@FormParam(FORM_PARAM_CLUSTER_NAME) String clusterName) { - if(clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!"); - } - - if(clusterService.getCluster(clusterName) != null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] already exists!"); - } - - clusterService.createCluster(clusterName); - return createdResponse(clusterName); - } - - @PUT - public Response registerCluster(@FormParam(FORM_PARAM_CLUSTER_NAME) String clusterName, - @FormParam(FORM_PARAM_SERVER_NAME) String knownServer) { - if(clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!"); - } - - if(knownServer == null || knownServer.isEmpty()) { - throw new GlusterValidationException("Parameter [" + FORM_PARAM_SERVER_NAME + "] is missing in request!"); - } - - if(clusterService.getCluster(clusterName) != null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] already exists!"); - } - - ClusterInfo mappedCluster = clusterService.getClusterForServer(knownServer); - if(mappedCluster != null) { - throw new GlusterValidationException("Server [" + knownServer + "] is already present in cluster [" - + mappedCluster.getName() + "]!"); - } - - clusterService.registerCluster(clusterName, knownServer); - return noContentResponse(clusterName); - } - - @Path("{" + PATH_PARAM_CLUSTER_NAME + "}") - @DELETE - public Response unregisterCluster(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { - if(clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if(cluster == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] does not exist!"); - } - - clusterService.unregisterCluster(cluster); - return noContentResponse(); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java deleted file mode 100644 index f47675d8..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_SERVER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_DISCOVERED_SERVERS; - -import java.util.List; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.response.ServerListResponse; -import com.gluster.storage.management.core.response.ServerNameListResponse; -import com.gluster.storage.management.gateway.services.DiscoveredServerService; -import com.sun.jersey.api.core.InjectParam; -import com.sun.jersey.spi.resource.Singleton; - -@Component -@Singleton -@Path(RESOURCE_PATH_DISCOVERED_SERVERS) -public class DiscoveredServersResource extends AbstractResource { - @InjectParam - private DiscoveredServerService discoveredServerService; - - @GET - @Produces(MediaType.APPLICATION_XML) - public Response getDiscoveredServersXML(@QueryParam(QUERY_PARAM_DETAILS) Boolean details) { - return getDiscoveredServersResponse(details, MediaType.APPLICATION_XML); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getDiscoveredServersJSON(@QueryParam(QUERY_PARAM_DETAILS) Boolean details) { - return getDiscoveredServersResponse(details, MediaType.APPLICATION_JSON); - } - - private Response getDiscoveredServersResponse(Boolean details, String mediaType) { - if(details != null && details == true) { - try { - List discoveredServers = discoveredServerService.getDiscoveredServerDetails(); - return okResponse(new ServerListResponse(discoveredServers), mediaType); - } catch(Exception e) { - return errorResponse(e.getMessage()); - } - } else { - return okResponse(new ServerNameListResponse(discoveredServerService.getDiscoveredServerNames()), mediaType); - } - } - - @Path("{" + PATH_PARAM_SERVER_NAME + "}") - @GET - @Produces(MediaType.APPLICATION_XML) - public Response getDiscoveredServerXML(@PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - return getDiscoveredServerResponse(serverName, MediaType.APPLICATION_XML); - } - - @Path("{" + PATH_PARAM_SERVER_NAME + "}") - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getDiscoveredServerJSON(@PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - return getDiscoveredServerResponse(serverName, MediaType.APPLICATION_JSON); - } - - private Response getDiscoveredServerResponse(String serverName, String mediaType) { - if(serverName == null || serverName.isEmpty()) { - return badRequestResponse("Server name must not be empty!"); - } - try { - return okResponse(discoveredServerService.getDiscoveredServer(serverName), mediaType); - } catch (Exception e) { - // TODO: Log the exception - return errorResponse(e.getMessage()); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java deleted file mode 100644 index fc9115da..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.resources.v1_0; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.apache.log4j.Logger; - -import com.gluster.storage.management.core.exceptions.GlusterValidationException; - -@Provider -public class GenericExceptionMapper implements ExceptionMapper { - private static final Logger logger = Logger.getLogger(GenericExceptionMapper.class); - - /* (non-Javadoc) - * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable) - */ - @Override - public Response toResponse(Exception exception) { - ResponseBuilder builder; - if (exception instanceof GlusterValidationException) { - builder = Response.status(Response.Status.BAD_REQUEST); - } else { - builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR); - } - - String errMsg = exception.getMessage(); - if(errMsg == null) { - errMsg = "Following exception occurred : " + exception.getClass().getName(); - StackTraceElement[] stackTrace = exception.getStackTrace(); - if(stackTrace.length > 0) { - errMsg += " at [" + stackTrace[0].getClassName() + "][" + stackTrace[0].getLineNumber() + "]"; - } - } - - logger.error(errMsg, exception); - - return builder.entity(errMsg).type(MediaType.TEXT_PLAIN).build(); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java deleted file mode 100644 index 3c6910fd..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java +++ /dev/null @@ -1,343 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FSTYPE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_MOUNTPOINT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_DISK_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_SERVER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_INTERFACE; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_MAX_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_NEXT_TO; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_PERIOD; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TYPE; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DISKS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_FSTYPES; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_SERVERS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_STATISTICS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS; -import static com.gluster.storage.management.core.constants.RESTConstants.STATISTICS_TYPE_CPU; -import static com.gluster.storage.management.core.constants.RESTConstants.STATISTICS_TYPE_MEMORY; -import static com.gluster.storage.management.core.constants.RESTConstants.STATISTICS_TYPE_NETWORK; - -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.response.FsTypeListResponse; -import com.gluster.storage.management.core.response.GlusterServerListResponse; -import com.gluster.storage.management.core.response.ServerNameListResponse; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.services.GlusterServerService; -import com.gluster.storage.management.gateway.tasks.InitializeDiskTask; -import com.gluster.storage.management.gateway.utils.CpuStatsFactory; -import com.gluster.storage.management.gateway.utils.MemoryStatsFactory; -import com.gluster.storage.management.gateway.utils.NetworkStatsFactory; -import com.gluster.storage.management.gateway.utils.StatsFactory; -import com.sun.jersey.api.core.InjectParam; -import com.sun.jersey.spi.resource.Singleton; - -@Component -@Singleton -@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_SERVERS) -public class GlusterServersResource extends AbstractResource { - - public static final String HOSTNAMETAG = "hostname:"; - - @InjectParam - private TasksResource taskResource; - - @InjectParam - private ClusterService clusterService; - - @InjectParam - private CpuStatsFactory cpuStatsFactory; - - @InjectParam - private MemoryStatsFactory memoryStatsFactory; - - @InjectParam - private NetworkStatsFactory networkStatsFactory; - - @InjectParam - private GlusterServerService glusterServerService; - - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response getGlusterServersJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @QueryParam(QUERY_PARAM_DETAILS) Boolean details, @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, - @QueryParam(QUERY_PARAM_NEXT_TO) String previousServerName) { - return getGlusterServers(clusterName, MediaType.APPLICATION_JSON, details, maxCount, previousServerName); - } - - @GET - @Produces(MediaType.APPLICATION_XML) - public Response getGlusterServersXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @QueryParam(QUERY_PARAM_DETAILS) Boolean details, @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, - @QueryParam(QUERY_PARAM_NEXT_TO) String previousServerName) { - return getGlusterServers(clusterName, MediaType.APPLICATION_XML, details, maxCount, previousServerName); - } - - private Response getGlusterServers(String clusterName, String mediaType, Boolean fetchDetails, Integer maxCount, - String previousServerName) { - if(fetchDetails == null) { - // by default, fetch the server list - fetchDetails = false; - } - - List glusterServers = new ArrayList(); - - if (clusterName == null || clusterName.isEmpty()) { - return badRequestResponse("Cluster name must not be empty!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - return notFoundResponse("Cluster [" + clusterName + "] not found!"); - } - - if (cluster.getServers().size() == 0) { - return okResponse(new GlusterServerListResponse(glusterServers), mediaType); - } - - try { - glusterServers = glusterServerService.getGlusterServers(clusterName, fetchDetails, maxCount, previousServerName); - } catch (Exception e) { - return errorResponse(e.getMessage()); - } - - if(fetchDetails) { - return okResponse(new GlusterServerListResponse(glusterServers), mediaType); - } else { - // no details to be fetched. Return list of server names. - return okResponse(new ServerNameListResponse(getServerNames(glusterServers)), mediaType); - } - } - - private List getServerNames(List glusterServers) { - List serverNames = new ArrayList(); - for(GlusterServer server : glusterServers) { - serverNames.add(server.getName()); - } - return serverNames; - } - - @GET - @Path("{" + PATH_PARAM_SERVER_NAME + "}") - @Produces(MediaType.APPLICATION_XML) - public Response getGlusterServerXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - return getGlusterServerResponse(clusterName, serverName, MediaType.APPLICATION_XML); - } - - @GET - @Path("{" + PATH_PARAM_SERVER_NAME + "}") - @Produces(MediaType.APPLICATION_JSON) - public Response getGlusterServerJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - return getGlusterServerResponse(clusterName, serverName, MediaType.APPLICATION_JSON); - } - - private Response getGlusterServerResponse(String clusterName, String serverName, String mediaType) { - try { - return okResponse(glusterServerService.getGlusterServer(clusterName, serverName, true), mediaType); - } catch (Exception e) { - return errorResponse(e.getMessage()); - } - } - - @POST - public Response addServer(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @FormParam(FORM_PARAM_SERVER_NAME) String serverName) { - return createdResponse(glusterServerService.addServerToCluster(clusterName, serverName)); - } - - @DELETE - @Path("{" + PATH_PARAM_SERVER_NAME + "}") - public Response removeServer(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - glusterServerService.removeServerFromCluster(clusterName, serverName); - return noContentResponse(); - } - - @GET - @Produces(MediaType.APPLICATION_XML) - @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_FSTYPES) - public FsTypeListResponse getFsTypes(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { - List fsTypes = glusterServerService.getFsTypes(clusterName, serverName); - return new FsTypeListResponse(fsTypes); - } - - @PUT - @Produces(MediaType.APPLICATION_XML) - @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_DISKS + "/{" + PATH_PARAM_DISK_NAME + "}") - public Response initializeDisk(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_SERVER_NAME) String serverName, @PathParam(PATH_PARAM_DISK_NAME) String diskName, - @FormParam(FORM_PARAM_FSTYPE) String fsType, @FormParam(FORM_PARAM_MOUNTPOINT) String mountPoint) { - - if (clusterName == null || clusterName.isEmpty()) { - return badRequestResponse("Cluster name must not be empty!"); - } - - if (serverName == null || serverName.isEmpty()) { - return badRequestResponse("Server name must not be empty!"); - } - - if (diskName == null || diskName.isEmpty()) { - return badRequestResponse("Disk name must not be empty!"); - } - - if (fsType == null || fsType.isEmpty()) { - fsType = GlusterConstants.FSTYPE_DEFAULT; - // return badRequestResponse("Parameter [" + FORM_PARAM_FSTYPE + "] is missing in request!"); - } - - InitializeDiskTask initializeTask = new InitializeDiskTask(clusterService, clusterName, serverName, diskName, fsType, mountPoint); - try { - initializeTask.start(); - // Check the initialize disk status - TaskStatus taskStatus = initializeTask.checkStatus(); - initializeTask.getTaskInfo().setStatus(taskStatus); - taskResource.addTask(clusterName, initializeTask); - - return acceptedResponse(RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_TASKS + "/" - + initializeTask.getId()); - } catch (Exception e) { - return errorResponse(e.getMessage()); - } - } - - @GET - @Produces(MediaType.APPLICATION_XML) - @Path(RESOURCE_STATISTICS) - public Response getAggregatedPerformanceDataXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period) { - return getAggregaredPerformanceData(clusterName, type, period, MediaType.APPLICATION_XML); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path(RESOURCE_STATISTICS) - public Response getAggregaredPerformanceDataJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period) { - return getAggregaredPerformanceData(clusterName, type, period, MediaType.APPLICATION_JSON); - } - - @GET - @Produces(MediaType.APPLICATION_XML) - @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_STATISTICS) - public Response getPerformanceDataXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName, - @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period, - @QueryParam(QUERY_PARAM_INTERFACE) String networkInterface) { - return getPerformanceData(clusterName, serverName, type, period, networkInterface, MediaType.APPLICATION_XML); - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_STATISTICS) - public Response getPerformanceDataJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName, - @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period, - @QueryParam(QUERY_PARAM_INTERFACE) String networkInterface) { - return getPerformanceData(clusterName, serverName, type, period, networkInterface, MediaType.APPLICATION_JSON); - } - - private Response getAggregaredPerformanceData(String clusterName, String type, String period, String mediaType) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (type == null || type.isEmpty()) { - throw new GlusterValidationException("Statistics type name must not be empty!"); - } - - if (period == null || period.isEmpty()) { - throw new GlusterValidationException("Statistics period name must not be empty! Valid values are 1d/1w/1m/1y"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - return notFoundResponse("Cluster [" + clusterName + "] not found!"); - } - - if (cluster.getServers().isEmpty()) { - // cluster is empty. return empty stats. - return okResponse(new ServerStats(), mediaType); - } - - List serverNames = getServerNames(glusterServerService.getGlusterServers(clusterName, false, null, null)); - return okResponse(getStatsFactory(type).fetchAggregatedStats(serverNames, period), mediaType); - } - - private Response getPerformanceData(String clusterName, String serverName, String type, String period, String networkInterface, String mediaType) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (serverName == null || serverName.isEmpty()) { - throw new GlusterValidationException("Server name must not be empty!"); - } - - if (type == null || type.isEmpty()) { - throw new GlusterValidationException("Statistics type name must not be empty!"); - } - - if (period == null || period.isEmpty()) { - throw new GlusterValidationException("Statistics period name must not be empty! Valid values are 1d/1w/1m/1y"); - } - - return okResponse(getStatsFactory(type).fetchStats(serverName, period, networkInterface), mediaType); - } - - private StatsFactory getStatsFactory(String type) { - if(type.equals(STATISTICS_TYPE_CPU)) { - return cpuStatsFactory; - } else if(type.equals(STATISTICS_TYPE_MEMORY)) { - return memoryStatsFactory; - } else if(type.equals(STATISTICS_TYPE_NETWORK)) { - return networkStatsFactory; - } else { - throw new GlusterValidationException("Invalid server statistics type [" + type + "]. Valid values are [" - + STATISTICS_TYPE_CPU + ", " + STATISTICS_TYPE_NETWORK + ", " + STATISTICS_TYPE_MEMORY + "]"); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java deleted file mode 100644 index 186fa59f..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/KeysResource.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * KeysResource.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_KEYS; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.log4j.Logger; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.utils.FileUtil; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.core.utils.ProcessUtil; -import com.gluster.storage.management.gateway.utils.SshUtil; -import com.sun.jersey.multipart.FormDataParam; - -@Path(RESOURCE_PATH_KEYS) -public class KeysResource extends AbstractResource { - private static final Logger logger = Logger.getLogger(KeysResource.class); - private ProcessUtil processUtil = new ProcessUtil(); - - @GET - @Produces(MediaType.APPLICATION_OCTET_STREAM) - public Response exportSshkeys() { - File archiveFile = new File(createSskKeyZipFile()); - byte[] data = FileUtil.readFileAsByteArray(archiveFile); - archiveFile.delete(); - return streamingOutputResponse(createStreamingOutput(data)); - } - - private String createSskKeyZipFile() { - String targetDir = FileUtil.getTempDirName(); - String zipFile = targetDir + File.separator + "ssh-keys.tar"; - String sourcePrivateKeyFile = SshUtil.PRIVATE_KEY_FILE.getAbsolutePath(); - String sourcePublicKeyFile = SshUtil.PUBLIC_KEY_FILE.getAbsolutePath(); - String targetPrivateKeyFile = targetDir + File.separator + SshUtil.PRIVATE_KEY_FILE.getName(); - String targetPubKeyFile = targetDir + File.separator + SshUtil.PUBLIC_KEY_FILE.getName(); - - if (!SshUtil.PRIVATE_KEY_FILE.isFile()) { - throw new GlusterRuntimeException("No private key file [" + SshUtil.PRIVATE_KEY_FILE.getName() + "] found!"); - } - - if (!SshUtil.PUBLIC_KEY_FILE.isFile()) { - throw new GlusterRuntimeException("No public key file [" + SshUtil.PUBLIC_KEY_FILE.getName() + "] found!"); - } - - // Copy keys to temp folder - ProcessResult result = processUtil.executeCommand("cp", sourcePrivateKeyFile, targetPrivateKeyFile); - if (!result.isSuccess()) { - throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]"); - } - result = processUtil.executeCommand("cp", sourcePublicKeyFile, targetPubKeyFile); - if (!result.isSuccess()) { - throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]"); - } - - // To compress the key files - result = processUtil.executeCommand("tar", "cvf", zipFile, "-C", targetDir, SshUtil.PRIVATE_KEY_FILE.getName(), - SshUtil.PUBLIC_KEY_FILE.getName()); - if (!result.isSuccess()) { - throw new GlusterRuntimeException("Failed to compress key files! [" + result.getOutput() + "]"); - } - - // To remove the copied key files - try { - processUtil.executeCommand("rm", "-f", targetPrivateKeyFile, targetPubKeyFile); // Ignore the errors if any - } catch (Exception e) { - logger.warn(e.toString()); - } - return zipFile; - } - - @POST - @Consumes(MediaType.MULTIPART_FORM_DATA) - public Response importSshKeys(@FormDataParam("file") InputStream uploadedInputStream) { - File uploadedFile = new File(System.getProperty("java.io.tmpdir") + File.separator + "keys.tar"); - String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); - - writeToFile(uploadedInputStream, uploadedFile.getAbsolutePath()); - - // To backup existing SSH private and public keys, if exist. - if (SshUtil.PRIVATE_KEY_FILE.isFile()) { - if (!SshUtil.PRIVATE_KEY_FILE.renameTo(new File(SshUtil.PRIVATE_KEY_FILE.getAbsolutePath() + "-" + timestamp))) { - throw new GlusterRuntimeException("Unable to backup private key!"); - } - } - - if (SshUtil.PUBLIC_KEY_FILE.isFile()) { - if (!SshUtil.PUBLIC_KEY_FILE - .renameTo(new File(SshUtil.PUBLIC_KEY_FILE.getAbsolutePath() + "-" + timestamp))) { - throw new GlusterRuntimeException("Unable to backup public key!"); - } - } - // Extract SSH private and public key files. - ProcessResult output = processUtil.executeCommand("tar", "xvf", uploadedFile.getAbsolutePath(), "-C", - SshUtil.SSH_AUTHORIZED_KEYS_DIR_LOCAL); - uploadedFile.delete(); - if (!output.isSuccess()) { - String errMsg = "Error in importing SSH keys: [" + output.toString() + "]"; - logger.error(errMsg); - throw new GlusterRuntimeException(errMsg); - } - return createdResponse("SSH Key imported successfully"); - } - - // save uploaded file to the file (with path) - private void writeToFile(InputStream inputStream, String toFile) { - try { - int read = 0; - byte[] bytes = new byte[1024]; - - OutputStream out = new FileOutputStream(new File(toFile)); - while ((read = inputStream.read(bytes)) != -1) { - out.write(bytes, 0, read); - } - out.flush(); - out.close(); - } catch (IOException e) { - throw new GlusterRuntimeException(e.getMessage()); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/TasksResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/TasksResource.java deleted file mode 100644 index 16faf7de..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/TasksResource.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * TaskResource.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OPERATION; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_TASK_ID; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.response.TaskInfoListResponse; -import com.gluster.storage.management.gateway.tasks.Task; -import com.sun.jersey.spi.resource.Singleton; - -@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_TASKS) -@Singleton -@Component - -public class TasksResource extends AbstractResource { - private Map> tasksMap = new HashMap>(); - - public TasksResource() { - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - public void addTask(String clusterName, Task task) { - Map clusterTaskMap = tasksMap.get(clusterName); - if(clusterTaskMap == null) { - clusterTaskMap = new HashMap(); - tasksMap.put(clusterName, clusterTaskMap); - } - // Remove the task if already exist - if (clusterTaskMap.containsKey(task.getId())) { - removeTask(clusterName, task); - } - clusterTaskMap.put(task.getId(), task); - } - - @SuppressWarnings("rawtypes") - public void removeTask(String clusterName, Task task) { - Map clusterTaskMap = tasksMap.get(clusterName); - if (clusterTaskMap != null) { - clusterTaskMap.remove(task.getId()); - } - } - - public List getAllTasksInfo(String clusterName) { - Map clusterTasksMap = tasksMap.get(clusterName); - List allTasksInfo = new ArrayList(); - if ( clusterTasksMap == null) { - return allTasksInfo; - } - for (Map.Entry entry : clusterTasksMap.entrySet()) { - checkTaskStatus(clusterName, entry.getKey()); - allTasksInfo.add(entry.getValue().getTaskInfo()); // TaskInfo with latest status - } - return allTasksInfo; - } - - public Task getTask(String clusterName, String taskId) { - Map clusterTasksMap = tasksMap.get(clusterName); - for (Map.Entry entry : clusterTasksMap.entrySet()) { - if (entry.getValue().getId().equals(taskId)) { - return entry.getValue(); - } - } - return null; - } - - public List getAllTasks(String clusterName) { - Map clusterTasksMap = tasksMap.get(clusterName); - List tasks = new ArrayList(); - for (Map.Entry entry : clusterTasksMap.entrySet()) { - checkTaskStatus(clusterName, entry.getKey()); - tasks.add( (Task) entry.getValue()); - } - return tasks; - } - - @GET - @Produces(MediaType.APPLICATION_XML) - public Response getTasks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { - try { - return okResponse(new TaskInfoListResponse(getAllTasksInfo(clusterName)), MediaType.APPLICATION_XML); - } catch (GlusterRuntimeException e) { - return errorResponse(e.getMessage()); - } - } - - @GET - @Path("/{" + PATH_PARAM_TASK_ID + "}") - @Produces(MediaType.APPLICATION_XML) - public Response getTaskStatus(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_TASK_ID) String taskId) { - try { - Task task = checkTaskStatus(clusterName, taskId); - return okResponse(task.getTaskInfo(), MediaType.APPLICATION_XML); - } catch (GlusterRuntimeException e) { - return errorResponse(e.getMessage()); - } - } - - private Task checkTaskStatus(String clusterName, String taskId) { - Task task = getTask(clusterName, taskId); - // No status check required if the task already complete or failure - if (task.getTaskInfo().getStatus().getCode() == Status.STATUS_CODE_FAILURE - || task.getTaskInfo().getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { - return task; - } - task.getTaskInfo().setStatus(task.checkStatus()); - return task; - } - - @PUT - @Path("/{" + PATH_PARAM_TASK_ID + "}") - @Produces(MediaType.APPLICATION_XML) - public Response performTask(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_TASK_ID) String taskId, @FormParam(FORM_PARAM_OPERATION) String taskOperation) { - Task task = getTask(clusterName, taskId); - - try { - if (taskOperation.equals(RESTConstants.TASK_RESUME)) { - task.resume(); - } else if (taskOperation.equals(RESTConstants.TASK_PAUSE)) { - task.pause(); - } else if (taskOperation.equals(RESTConstants.TASK_STOP)) { - // task.stop(); - clearTask(clusterName, taskId, taskOperation); // Stop and remove from the task list - } else if (taskOperation.equals(RESTConstants.TASK_COMMIT)) { - task.commit(); - } - return (Response) noContentResponse(); - } catch(GlusterValidationException ve) { - return badRequestResponse(ve.getMessage()); - } catch (GlusterRuntimeException e) { - return errorResponse(e.getMessage()); - } - } - - @DELETE - @Path("/{" + PATH_PARAM_TASK_ID + "}") - @Produces(MediaType.APPLICATION_XML) - public Response clearTask(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_TASK_ID) String taskId, @QueryParam(FORM_PARAM_OPERATION) String taskOperation) { - Task task = getTask(clusterName, taskId); - if (task == null) { - return notFoundResponse("Requested task not found!"); - } - - if(clusterName == null || clusterName.isEmpty()) { - return badRequestResponse("Parameter [" + PATH_PARAM_CLUSTER_NAME + "] is missing in request!"); - } - - if(taskOperation == null || taskOperation.isEmpty()) { - int taskStatus = task.getTaskInfo().getStatus().getCode(); - if (taskStatus == Status.STATUS_CODE_SUCCESS || taskStatus == Status.STATUS_CODE_FAILURE) { - taskOperation = RESTConstants.TASK_DELETE; - } else { - taskOperation = RESTConstants.TASK_STOP; - } -// return badRequestResponse("Parameter [" + FORM_PARAM_OPERATION + "] is missing in request!"); - } - - if(!taskOperation.equals(RESTConstants.TASK_STOP) && !taskOperation.equals(RESTConstants.TASK_DELETE)) { - return badRequestResponse("Invalid value [" + taskOperation + "] for parameter [" + FORM_PARAM_OPERATION - + "]"); - } - - try { - if (taskOperation.equals(RESTConstants.TASK_STOP)) { - task.stop(); - // On successful, intentionally stopped task can be removed from task list also - taskOperation = RESTConstants.TASK_DELETE; - } - - if (taskOperation.equals(RESTConstants.TASK_DELETE)) { - removeTask(clusterName, task); - } - - return noContentResponse(); - } catch (Exception e) { - return errorResponse(e.getMessage()); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/UsersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/UsersResource.java deleted file mode 100644 index 6914e505..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/UsersResource.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_NEW_PASSWORD; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OLD_PASSWORD; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_USER; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_USERS; - -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.authentication.dao.SaltSource; -import org.springframework.security.authentication.encoding.PasswordEncoder; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.provisioning.JdbcUserDetailsManager; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.model.Status; -import com.sun.jersey.spi.resource.Singleton; - -@Singleton -@Component -@Path(RESOURCE_PATH_USERS) -public class UsersResource extends AbstractResource { - @Autowired - private JdbcUserDetailsManager jdbcUserService; - - @Autowired - private PasswordEncoder passwordEncoder; - - @Autowired - private SaltSource saltSource; - - @Autowired - private UserDetailsService userDetailsService; - - private static final Logger logger = Logger.getLogger(UsersResource.class); - - @Path("{" + PATH_PARAM_USER + "}") - @GET - @Produces(MediaType.APPLICATION_XML) - public Response authenticateXML(@PathParam("user") String user) { - // success only if the user passed in query is same as the one passed in security header - // spring security would have already authenticated the user credentials - return getAuthenticationResponse(user, MediaType.APPLICATION_XML); - } - - @Path("{" + PATH_PARAM_USER + "}") - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response authenticateJSON(@PathParam("user") String user) { - // success only if the user passed in query is same as the one passed in security header - // spring security would have already authenticated the user credentials - return getAuthenticationResponse(user, MediaType.APPLICATION_JSON); - } - - public Response getAuthenticationResponse(String user, String mediaType) { - return (SecurityContextHolder.getContext().getAuthentication().getName().equals(user) ? okResponse( - Status.STATUS_SUCCESS, mediaType) : unauthorizedResponse()); - } - - @Path("{" + PATH_PARAM_USER + "}") - @PUT - public Response changePassword(@PathParam(PATH_PARAM_USER) String username, - @FormParam(FORM_PARAM_OLD_PASSWORD) String oldPassword, - @FormParam(FORM_PARAM_NEW_PASSWORD) String newPassword) { - try { - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - String loggedInUser = ((UserDetails)auth.getPrincipal()).getUsername(); - if(!loggedInUser.equals(username)) { - // Temporary check as we currently have only one user. - throw new GlusterValidationException("User [" + loggedInUser - + "] is not allowed to change password of user [" + username + "]!"); - } - - UserDetails user = userDetailsService.loadUserByUsername(username); - Object salt = saltSource.getSalt(user); - - String actualOldPasswordEncoded = ((UserDetails)auth.getPrincipal()).getPassword(); - String oldPasswordEncoded = passwordEncoder.encodePassword(oldPassword, salt); - if(!oldPasswordEncoded.equals(actualOldPasswordEncoded)) { - throw new GlusterValidationException("Invalid old password!"); - } - - String encodedNewPassword = passwordEncoder.encodePassword(newPassword, salt); - jdbcUserService.changePassword(oldPassword, encodedNewPassword); - } catch (Exception ex) { - String errMsg = "Could not change password. Error: [" + ex.getMessage() + "]"; - logger.error(errMsg, ex); - throw new GlusterRuntimeException(errMsg); - } - return noContentResponse(); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java deleted file mode 100644 index 14e7be8c..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java +++ /dev/null @@ -1,383 +0,0 @@ -/** - * VolumesResource.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.resources.v1_0; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_ACCESS_PROTOCOLS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_AUTO_COMMIT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_ENABLE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_USERS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FIX_LAYOUT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FORCED_DATA_MIGRATE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_MIGRATE_DATA; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OPERATION; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_REPLICA_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SOURCE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_STRIPE_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TARGET; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TRANSPORT_TYPE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_OPTIONS; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_TYPE; -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FORCE; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_VOLUME_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICKS; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICK_NAME; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DELETE_OPTION; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DOWNLOAD; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_FROM_TIMESTAMP; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_LINE_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_LOG_SEVERITY; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_MAX_COUNT; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_NEXT_TO; -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TO_TIMESTAMP; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_BRICKS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DEFAULT_OPTIONS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DOWNLOAD; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_LOGS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_OPTIONS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS; -import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_VOLUMES; - -import java.io.File; -import java.util.Arrays; -import java.util.List; - -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.log4j.Logger; - -import com.gluster.storage.management.core.constants.RESTConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.model.VolumeLogMessage; -import com.gluster.storage.management.core.response.LogMessageListResponse; -import com.gluster.storage.management.core.response.VolumeListResponse; -import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; -import com.gluster.storage.management.core.utils.FileUtil; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.services.VolumeService; -import com.sun.jersey.api.core.InjectParam; -import com.sun.jersey.spi.resource.Singleton; - -@Singleton -@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_VOLUMES) -public class VolumesResource extends AbstractResource { - private static final Logger logger = Logger.getLogger(VolumesResource.class); - - @InjectParam - private ClusterService clusterService; - - @InjectParam - private VolumeService volumeService; - - @GET - @Produces({ MediaType.APPLICATION_XML }) - public Response getVolumesXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, - @QueryParam(QUERY_PARAM_NEXT_TO) String previousVolumeName) { - return okResponse(new VolumeListResponse(volumeService.getVolumes(clusterName, maxCount, previousVolumeName)), - MediaType.APPLICATION_XML); - } - - @GET - @Produces({ MediaType.APPLICATION_JSON }) - public Response getVolumesJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, - @QueryParam(QUERY_PARAM_NEXT_TO) String previousVolumeName) { - return okResponse(new VolumeListResponse(volumeService.getVolumes(clusterName, maxCount, previousVolumeName)), - MediaType.APPLICATION_JSON); - } - - @POST - @Produces(MediaType.APPLICATION_XML) - public Response createVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @FormParam(FORM_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_VOLUME_TYPE) String volumeType, - @FormParam(FORM_PARAM_TRANSPORT_TYPE) String transportType, - @FormParam(FORM_PARAM_REPLICA_COUNT) Integer replicaCount, - @FormParam(FORM_PARAM_STRIPE_COUNT) Integer stripeCount, @FormParam(FORM_PARAM_BRICKS) String bricks, - @FormParam(FORM_PARAM_ACCESS_PROTOCOLS) String accessProtocols, - @FormParam(FORM_PARAM_VOLUME_OPTIONS) String options, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers) { - int count = 0; - if (clusterName == null || clusterName.isEmpty()) { - return badRequestResponse("Cluster name must not be empty!"); - } - - String missingParam = checkMissingParamsForCreateVolume(volumeName, volumeType, transportType, bricks, - accessProtocols, options); - if (missingParam != null) { - throw new GlusterValidationException("Parameter [" + missingParam + "] is missing in request!"); - } - - // For missing parameter, let default value - if (volumeType.equals(VOLUME_TYPE.REPLICATE.toString()) - || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE.toString())) { - count = (replicaCount == null) ? Volume.DEFAULT_REPLICA_COUNT : replicaCount; - } else if (volumeType.equals(VOLUME_TYPE.STRIPE.toString()) - || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE.toString())) { - count = (stripeCount == null) ? Volume.DEFAULT_STRIPE_COUNT : stripeCount; - } - - volumeService.createVolume(clusterName, volumeName, volumeType, transportType, count, bricks, accessProtocols, - options, cifsUsers); - return createdResponse(volumeName); - } - - /** - * Returns name of the missing parameter if any. If all parameters are present, - */ - private String checkMissingParamsForCreateVolume(String volumeName, String volumeType, - String transportType, String bricks, String accessProtocols, - String options) { - - return (volumeName == null || volumeName.isEmpty()) ? FORM_PARAM_VOLUME_NAME : - (volumeType == null || volumeType.isEmpty()) ? FORM_PARAM_VOLUME_TYPE : - (transportType == null || transportType.isEmpty()) ? FORM_PARAM_TRANSPORT_TYPE : - (bricks == null || bricks.isEmpty()) ? FORM_PARAM_BRICKS : - (accessProtocols == null || accessProtocols.isEmpty()) ? FORM_PARAM_ACCESS_PROTOCOLS : - (options == null || options.isEmpty()) ? FORM_PARAM_VOLUME_OPTIONS : - null; - } - - @GET - @Path("{" + PATH_PARAM_VOLUME_NAME + "}") - @Produces(MediaType.APPLICATION_XML) - public Response getVolumeXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { - return okResponse(volumeService.getVolume(clusterName, volumeName), MediaType.APPLICATION_XML); - } - - @GET - @Path("{" + PATH_PARAM_VOLUME_NAME + "}") - @Produces(MediaType.APPLICATION_JSON) - public Response getVolumeJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { - return okResponse(volumeService.getVolume(clusterName, volumeName), MediaType.APPLICATION_JSON); - } - - @PUT - @Path("{" + PATH_PARAM_VOLUME_NAME + "}") - public Response performOperation(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_OPERATION) String operation, - @FormParam(FORM_PARAM_FIX_LAYOUT) Boolean isFixLayout, - @FormParam(FORM_PARAM_MIGRATE_DATA) Boolean isMigrateData, - @FormParam(FORM_PARAM_FORCED_DATA_MIGRATE) Boolean isForcedDataMigrate, - @FormParam(FORM_PARAM_CIFS_ENABLE) Boolean enableCifs, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers, - @FormParam(FORM_PARAM_BRICKS) String bricks, @FormParam(FORM_PARAM_FORCE) Boolean force) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - try { - if (operation.equals(RESTConstants.TASK_REBALANCE_START)) { - String taskId = volumeService.rebalanceStart(clusterName, volumeName, isFixLayout, isMigrateData, isForcedDataMigrate); - return acceptedResponse(RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_TASKS - + "/" + taskId); - } else if (operation.equals(RESTConstants.TASK_REBALANCE_STOP)) { - volumeService.rebalanceStop(clusterName, volumeName); - } else if (operation.equals(RESTConstants.FORM_PARAM_CIFS_CONFIG)) { - Volume newVolume = volumeService.getVolume(clusterName, volumeName); - if (enableCifs) { - // After add/modify volume cifs users, start/restart the cifs service - volumeService.createCIFSUsers(clusterName, volumeName, cifsUsers); - if (newVolume.getStatus() == VOLUME_STATUS.ONLINE) { - volumeService.startCifsReExport(clusterName, volumeName); - } - } else { - // Stop the Cifs service and delete the users (!important) - if (newVolume.getStatus() == VOLUME_STATUS.ONLINE) { - volumeService.stopCifsReExport(clusterName, volumeName); - } - volumeService.deleteCifsUsers(clusterName, volumeName); - } - } else if (operation.equals(RESTConstants.TASK_LOG_ROTATE)) { - List brickList = Arrays.asList(bricks.split(",")); - volumeService.logRotate(clusterName, volumeName, brickList); - } else { - if (force == null) { - force = false; - } - volumeService.performVolumeOperation(clusterName, volumeName, operation, force); - } - return noContentResponse(); - } catch(Exception e) { - return errorResponse(e.getMessage()); - } - } - - @DELETE - @Path("{" + PATH_PARAM_VOLUME_NAME + "}") - public Response deleteVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, - @QueryParam(QUERY_PARAM_DELETE_OPTION) Boolean deleteFlag) { - volumeService.deleteVolume(clusterName, volumeName, deleteFlag); - - return noContentResponse(); - } - - @DELETE - @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS) - public Response removeBricks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICKS) String bricks, - @QueryParam(QUERY_PARAM_DELETE_OPTION) Boolean deleteFlag) { - volumeService.removeBricksFromVolume(clusterName, volumeName, bricks, deleteFlag); - return noContentResponse(); - } - - @POST - @Path("{" + PATH_PARAM_VOLUME_NAME + " }/" + RESOURCE_OPTIONS) - public Response setOption(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, - @FormParam(RESTConstants.FORM_PARAM_OPTION_KEY) String key, - @FormParam(RESTConstants.FORM_PARAM_OPTION_VALUE) String value) { - volumeService.setVolumeOption(clusterName, volumeName, key, value); - - return createdResponse(key); - } - - @PUT - @Path("{" + PATH_PARAM_VOLUME_NAME + " }/" + RESOURCE_OPTIONS) - public Response resetOptions(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { - volumeService.resetVolumeOptions(clusterName, volumeName); - return noContentResponse(); - } - - @GET - @Path(RESOURCE_DEFAULT_OPTIONS) - @Produces(MediaType.APPLICATION_XML) - public VolumeOptionInfoListResponse getOptionsInfoXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { - return volumeService.getVolumeOptionsInfo(clusterName); - } - - @GET - @Path(RESOURCE_DEFAULT_OPTIONS) - @Produces(MediaType.APPLICATION_JSON) - public VolumeOptionInfoListResponse getOptionsInfoJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { - return volumeService.getVolumeOptionsInfo(clusterName); - } - - @GET - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS + "/" + RESOURCE_DOWNLOAD) - public Response downloadLogs(@PathParam(PATH_PARAM_CLUSTER_NAME) final String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) final String volumeName) { - if (clusterName == null || clusterName.isEmpty()) { - return badRequestResponse("Cluster name must not be empty!"); - } - - if (volumeName == null || volumeName.isEmpty()) { - return badRequestResponse("Volume name must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - return notFoundResponse("Cluster [" + clusterName + "] not found!"); - } - - try { - final Volume volume = volumeService.getVolume(clusterName, volumeName); - File archiveFile = new File(volumeService.downloadLogs(volume)); - byte[] data = FileUtil.readFileAsByteArray(archiveFile); - archiveFile.delete(); - return streamingOutputResponse(createStreamingOutput(data)); - } catch (Exception e) { - logger.error("Volume [" + volumeName + "] doesn't exist in cluster [" + clusterName + "]! [" - + e.getStackTrace() + "]"); - throw (GlusterRuntimeException) e; - } - } - - @GET - @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS) - @Produces(MediaType.APPLICATION_XML) - public Response getLogsXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICK_NAME) String brickName, - @QueryParam(QUERY_PARAM_LOG_SEVERITY) String severity, - @QueryParam(QUERY_PARAM_FROM_TIMESTAMP) String fromTimestamp, - @QueryParam(QUERY_PARAM_TO_TIMESTAMP) String toTimestamp, - @QueryParam(QUERY_PARAM_LINE_COUNT) Integer lineCount, @QueryParam(QUERY_PARAM_DOWNLOAD) Boolean download) { - return getLogs(clusterName, volumeName, brickName, severity, fromTimestamp, toTimestamp, lineCount, MediaType.APPLICATION_XML); - } - - @GET - @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS) - @Produces(MediaType.APPLICATION_JSON) - public Response getLogsJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICK_NAME) String brickName, - @QueryParam(QUERY_PARAM_LOG_SEVERITY) String severity, - @QueryParam(QUERY_PARAM_FROM_TIMESTAMP) String fromTimestamp, - @QueryParam(QUERY_PARAM_TO_TIMESTAMP) String toTimestamp, - @QueryParam(QUERY_PARAM_LINE_COUNT) Integer lineCount, @QueryParam(QUERY_PARAM_DOWNLOAD) Boolean download) { - return getLogs(clusterName, volumeName, brickName, severity, fromTimestamp, toTimestamp, lineCount, MediaType.APPLICATION_JSON); - } - - private Response getLogs(String clusterName, String volumeName, String brickName, String severity, - String fromTimestamp, String toTimestamp, Integer lineCount, String mediaType) { - List logMessages = volumeService.getLogs(clusterName, volumeName, brickName, severity, - fromTimestamp, toTimestamp, lineCount); - - return okResponse(new LogMessageListResponse(logMessages), mediaType); - } - - @POST - @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS) - public Response addBricks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_BRICKS) String bricks) { - volumeService.addBricksToVolume(clusterName, volumeName, bricks); - - return createdResponse(volumeName + "/" + RESOURCE_BRICKS); - } - - @PUT - @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS) - public Response migrateBrick(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, - @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_SOURCE) String fromBrick, - @FormParam(FORM_PARAM_TARGET) String toBrick, @FormParam(FORM_PARAM_AUTO_COMMIT) Boolean autoCommit) { - - String taskId = volumeService.migrateBrickStart(clusterName, volumeName, fromBrick, toBrick, autoCommit); - - return acceptedResponse(RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_TASKS + "/" - + taskId); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/GlusterUserDetailsService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/GlusterUserDetailsService.java deleted file mode 100644 index e806051c..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/GlusterUserDetailsService.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * GlusterUserDetailsService.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.security; - -import org.springframework.security.core.userdetails.UserDetailsService; - -/** - * - */ -public interface GlusterUserDetailsService extends UserDetailsService { - void changePassword(String username, String password); -} - diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/UserAuthDao.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/UserAuthDao.java deleted file mode 100644 index cb2ecb24..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/security/UserAuthDao.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * UserAuthDao.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.security; - -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.DefaultTransactionDefinition; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; - -/** - * - */ -public class UserAuthDao extends JdbcDaoImpl implements GlusterUserDetailsService { - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.gateway.security.GlusterUserDetailsService#changePassword(java.lang.String, - * java.lang.String) - */ - @Override - public void changePassword(String username, String password) { - DataSourceTransactionManager txnManager = new DataSourceTransactionManager(); - txnManager.setDataSource(getDataSource()); - - TransactionDefinition def = new DefaultTransactionDefinition(); - TransactionStatus status = txnManager.getTransaction(def); - try { - getJdbcTemplate().update("UPDATE USERS SET PASSWORD = ? WHERE USERNAME = ?", password, username); - txnManager.commit(status); - } catch(Exception e) { - txnManager.rollback(status); - throw new GlusterRuntimeException("Exception while changing password of user [" + username + "]. Error: " + e.getMessage()); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java deleted file mode 100644 index 93db0267..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/AbstractGlusterInterface.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.services; - -import org.springframework.beans.factory.annotation.Autowired; - -import com.gluster.storage.management.gateway.utils.ServerUtil; - -/** - * Abstract Gluster Interface - provides functionality common across all versions of GlusterFS e.g. version check. - */ -public abstract class AbstractGlusterInterface implements GlusterInterface { - - @Autowired - protected ServerUtil serverUtil; - - @Override - public String getVersion(String serverName) { - return serverUtil.executeOnServer(serverName, "gluster --version").split("\n")[0].replaceAll("glusterfs ", "") - .replaceAll(" built.*", ""); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java deleted file mode 100644 index 4bc68c5e..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/ClusterService.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.services; - -import java.util.ArrayList; -import java.util.List; - -import javax.persistence.EntityTransaction; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.utils.LRUCache; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.data.PersistenceDao; -import com.gluster.storage.management.gateway.data.ServerInfo; -import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.gluster.storage.management.gateway.utils.SshUtil; - -/** - * Service class for functionality related to clusters - */ -@Component -public class ClusterService { - @Autowired - private PersistenceDao clusterDao; - - @Autowired - private PersistenceDao serverDao; - - @Autowired - private GlusterServerService glusterServerService; - - @Autowired - private SshUtil sshUtil; - - @Autowired - private ServerUtil serverUtil; - - private LRUCache onlineServerCache = new LRUCache(3); - - private static final Logger logger = Logger.getLogger(ClusterService.class); - - public void addOnlineServer(String clusterName, GlusterServer server) { - onlineServerCache.put(clusterName, server); - } - - public void removeOnlineServer(String clusterName) { - onlineServerCache.remove(clusterName); - } - - // uses cache - public GlusterServer getOnlineServer(String clusterName, String exceptServerName) { - GlusterServer server = onlineServerCache.get(clusterName); - if (server != null && !server.getName().equalsIgnoreCase(exceptServerName)) { - return server; - } - - return getNewOnlineServer(clusterName, exceptServerName); - } - - public GlusterServer getNewOnlineServer(String clusterName) { - return getNewOnlineServer(clusterName, ""); - } - - public GlusterServer getOnlineServer(String clusterName) { - return getOnlineServer(clusterName, ""); - } - - // Doesn't use cache - public GlusterServer getNewOnlineServer(String clusterName, String exceptServerName) { - ClusterInfo cluster = getCluster(clusterName); - if (cluster == null) { - throw new GlusterRuntimeException("Cluster [" + clusterName + "] is not found!"); - } - - for (ServerInfo serverInfo : cluster.getServers()) { - GlusterServer server = new GlusterServer(serverInfo.getName()); - try { - serverUtil.fetchServerDetails(server); // Online status come with server details - // server is online. add it to cache and return - if (server.isOnline() && !server.getName().equalsIgnoreCase(exceptServerName)) { - addOnlineServer(clusterName, server); - return server; - } - } catch (ConnectionException e) { - // server is offline. continue checking next one. - continue; - } - } - - // no online server found. - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - - public List getAllClusters() { - return clusterDao.findAll(); - } - - public ClusterInfo getCluster(String clusterName) { - List clusters = clusterDao.findBy("UPPER(name) = ?1", clusterName.toUpperCase()); - if(clusters.size() == 0) { - return null; - } - - return clusters.get(0); - } - - public ClusterInfo getClusterForServer(String serverName) { - List servers = serverDao.findBy("UPPER(name) = ?1", serverName.toUpperCase()); - if(servers.size() == 0) { - return null; - } - - return servers.get(0).getCluster(); - } - - public void createCluster(String clusterName) { - EntityTransaction txn = clusterDao.startTransaction(); - ClusterInfo cluster = new ClusterInfo(); - cluster.setName(clusterName); - - try { - clusterDao.save(cluster); - txn.commit(); - } catch (RuntimeException e) { - txn.rollback(); - logger.error("Exception while trying to save cluster [" + clusterName + "] : [" + e.getMessage() + "]", e); - throw e; - } - } - - public void registerCluster(String clusterName, String knownServer) { - EntityTransaction txn = clusterDao.startTransaction(); - ClusterInfo cluster = new ClusterInfo(); - cluster.setName(clusterName); - - GlusterServer server = new GlusterServer(knownServer); - try { - List glusterServers = glusterServerService.getGlusterServers(server.getName()); - List servers = new ArrayList(); - for(GlusterServer glusterServer : glusterServers) { - String serverName = glusterServer.getName(); - - serverUtil.fetchServerDetails(glusterServer); - if(glusterServer.isOnline()) { - checkAndSetupPublicKey(serverName); - } - - ServerInfo serverInfo = new ServerInfo(serverName); - serverInfo.setCluster(cluster); - clusterDao.save(serverInfo); - servers.add(serverInfo); - } - cluster.setServers(servers); - clusterDao.save(cluster); - txn.commit(); - } catch(RuntimeException e) { - logger.error("Error in registering cluster [" + clusterName + "] : " + e.getMessage(), e); - txn.rollback(); - logger.error("Error in registering cluster [" + clusterName + "] : " + e.getMessage(), e); - throw e; - } - } - - private void checkAndSetupPublicKey(String serverName) { - if(sshUtil.isPublicKeyInstalled(serverName)) { - return; - } - - if(!sshUtil.hasDefaultPassword(serverName)) { - // public key not installed, default password doesn't work. can't install public key - throw new GlusterRuntimeException( - "Gluster Management Gateway uses the default password to set up keys on the server." - + CoreConstants.NEWLINE + "However it seems that the password on server [" + serverName - + "] has been changed manually." + CoreConstants.NEWLINE - + "Please reset it back to the standard default password and try again."); - } - - // install public key (this will also disable password based ssh login) - sshUtil.installPublicKey(serverName); - } - - public void unregisterCluster(String clusterName) { - ClusterInfo cluster = getCluster(clusterName); - - if (cluster == null) { - throw new GlusterRuntimeException("Cluster [" + clusterName + "] doesn't exist!"); - } - - unregisterCluster(cluster); - } - - public void unregisterCluster(ClusterInfo cluster) { - EntityTransaction txn = clusterDao.startTransaction(); - try { - for(ServerInfo server : cluster.getServers()) { - clusterDao.delete(server); - } - cluster.getServers().clear(); - clusterDao.update(cluster); - clusterDao.delete(cluster); - txn.commit(); - } catch (RuntimeException e) { - logger.error("Error in unregistering cluster [" + cluster.getName() + "] : " + e.getMessage(), e); - txn.rollback(); - throw e; - } - } - - public void mapServerToCluster(String clusterName, String serverName) { - EntityTransaction txn = clusterDao.startTransaction(); - ClusterInfo cluster = getCluster(clusterName); - ServerInfo server = new ServerInfo(serverName); - server.setCluster(cluster); - try { - clusterDao.save(server); - cluster.addServer(server); - clusterDao.update(cluster); - txn.commit(); - } catch (Exception e) { - txn.rollback(); - throw new GlusterRuntimeException("Couldn't create cluster-server mapping [" + clusterName + "][" - + serverName + "]! Error: " + e.getMessage(), e); - } - } - - public void unmapServerFromCluster(String clusterName, String serverName) { - EntityTransaction txn = clusterDao.startTransaction(); - ClusterInfo cluster = getCluster(clusterName); - List servers = cluster.getServers(); - for(ServerInfo server : servers) { - if(server.getName().equalsIgnoreCase(serverName)) { - servers.remove(server); - clusterDao.delete(server); - break; - } - } - try { - clusterDao.update(cluster); - txn.commit(); - } catch(Exception e) { - txn.rollback(); - throw new GlusterRuntimeException("Couldn't unmap server [" + serverName + "] from cluster [" + clusterName - + "]! Error: " + e.getMessage(), e); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/DiscoveredServerService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/DiscoveredServerService.java deleted file mode 100644 index 6fad758c..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/DiscoveredServerService.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.services; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.utils.ProcessUtil; -import com.gluster.storage.management.gateway.utils.ServerUtil; - -/** - * - */ -@Component -public class DiscoveredServerService { - @Autowired - protected ServerUtil serverUtil; - - private List discoveredServerNames = new ArrayList(); - private static final Logger logger = Logger.getLogger(DiscoveredServerService.class); - - public List getDiscoveredServerDetails() { - try { - List discoveredServers = Collections.synchronizedList(new ArrayList()); - List threads = createThreads(discoveredServers); - ProcessUtil.waitForThreads(threads); - return discoveredServers; - } catch (Exception e) { - String errMsg = "Exception while fetching details of discovered servers! Error: [" + e.getMessage() + "]"; - logger.error(errMsg, e); - throw new GlusterRuntimeException(errMsg, e); - } - } - - /** - * Creates threads that will run in parallel and fetch details of all discovered servers - * @param discoveredServers The list to be populated with details of discovered servers - * @return - * @throws InterruptedException - */ - private List createThreads(List discoveredServers) throws InterruptedException { - List discoveredServerNames = getDiscoveredServerNames(); - List threads = new ArrayList(); - for (int i = discoveredServerNames.size() - 1; i >= 0; i--) { - Thread thread = new DiscoveredServerDetailsThread(discoveredServers, discoveredServerNames.get(i)); - threads.add(thread); - thread.start(); - if (i >= 5 && i % 5 == 0) { - // After every 5 servers, wait for 1 second so that we don't end up with too many running threads - Thread.sleep(1000); - } - } - return threads; - } - - public List getDiscoveredServerNames() { - return discoveredServerNames; - } - - public void setDiscoveredServerNames(List discoveredServerNames) { - synchronized (discoveredServerNames) { - this.discoveredServerNames = discoveredServerNames; - } - } - - public void removeDiscoveredServer(String serverName) { - discoveredServerNames.remove(serverName); - } - - public void addDiscoveredServer(String serverName) { - discoveredServerNames.add(serverName); - } - - public Server getDiscoveredServer(String serverName) { - Server server = new Server(serverName); - serverUtil.fetchServerDetails(server); - return server; - } - - public class DiscoveredServerDetailsThread extends Thread { - private List servers; - private String serverName; - private final Logger logger = Logger.getLogger(DiscoveredServerDetailsThread.class); - - /** - * Private constructor called on each thread - * @param servers The list to be populated with fetched server details - * @param serverName Name of the server whose details should be fetched by this thread - */ - private DiscoveredServerDetailsThread(List servers, String serverName) { - this.servers = servers; - this.serverName = serverName; - } - - @Override - public void run() { - try { - logger.info("fetching details of discovered server [" + serverName + "] - start"); - servers.add(getDiscoveredServer(serverName)); - logger.info("fetching details of discovered server [" + serverName + "] - end"); - } catch(Exception e) { - logger.warn("fetching details of discovered server [" + serverName + "] - error", e); - // eat the exception as we can't consider this server as a discovered server any more - } - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java deleted file mode 100644 index a4cc5575..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java +++ /dev/null @@ -1,598 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.services; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.log4j.Logger; -import org.springframework.context.annotation.Lazy; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; -import com.gluster.storage.management.core.utils.StringUtil; - -/** - * Gluster Interface for GlusterFS version 3.2.3 - */ -@Component -@Lazy(value=true) -public class Gluster323InterfaceService extends AbstractGlusterInterface { - - private static final String VOLUME_NAME_PFX = "Volume Name:"; - private static final String VOLUME_TYPE_PFX = "Type:"; - private static final String VOLUME_STATUS_PFX = "Status:"; - private static final String VOLUME_NUMBER_OF_BRICKS = "Number of Bricks:"; - private static final String VOLUME_TRANSPORT_TYPE_PFX = "Transport-type:"; - private static final String VOLUME_BRICKS_GROUP_PFX = "Bricks"; - private static final String VOLUME_OPTIONS_RECONFIG_PFX = "Options Reconfigured"; - private static final String VOLUME_LOG_LOCATION_PFX = "log file location:"; - private static final String VOLUME_TYPE_DISTRIBUTE = "Distribute"; - private static final String VOLUME_TYPE_REPLICATE = "Replicate"; - private static final String VOLUME_TYPE_DISTRIBUTED_REPLICATTE = "Distributed-Replicate"; - private static final String VOLUME_TYPE_STRIPE = "Stripe"; - private static final String VOLUME_TYPE_DISTRIBUTED_STRIPE = "Distributed-Stripe"; - - private static final String BRICK_STATUS_SCRIPT = "get_brick_status.py"; - private static final Logger logger = Logger.getLogger(Gluster323InterfaceService.class); - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addServer(java.lang.String, java.lang.String) - */ - @Override - public void addServer(String existingServer, String newServer) { - serverUtil.executeOnServer(existingServer, "gluster peer probe " + newServer); - // reverse peer probe to ensure that host names appear in peer status on both sides - serverUtil.executeOnServer(newServer, "gluster peer probe " + existingServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) - */ - @Override - public void startVolume(String volumeName, String knownServer, Boolean force) { - serverUtil.executeOnServer(knownServer, "gluster volume start " + volumeName + ((force) ? " force" : "")); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) - */ - @Override - public void stopVolume(String volumeName, String knownServer, Boolean force) { - serverUtil.executeOnServer(knownServer, "gluster --mode=script volume stop " + volumeName - + ((force) ? " force" : "")); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#resetOptions(java.lang.String, java.lang.String) - */ - @Override - public void resetOptions(String volumeName, String knownServer) { - serverUtil.executeOnServer(knownServer, "gluster volume reset " + volumeName); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createVolume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr, - Integer count, String bricks, String accessProtocols, String options) { - - // TODO: Disable NFS if required depending on value of accessProtocols - VOLUME_TYPE volType = Volume.getVolumeTypeByStr(volumeTypeStr); - String volTypeArg = null; - if (volType == VOLUME_TYPE.REPLICATE || volType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { - volTypeArg = "replica"; - } else if (volType == VOLUME_TYPE.STRIPE || volType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - volTypeArg = "stripe"; - } - - String transportTypeArg = null; - TRANSPORT_TYPE transportType = Volume.getTransportTypeByStr(transportTypeStr); - transportTypeArg = (transportType == TRANSPORT_TYPE.ETHERNET) ? "tcp" : "rdma"; - - String command = prepareVolumeCreateCommand(volumeName, StringUtil.extractList(bricks, ","), count, - volTypeArg, transportTypeArg); - - serverUtil.executeOnServer(knownServer, command); - - try { - createOptions(volumeName, StringUtil.extractMap(options, ",", "="), knownServer); - } catch(Exception e) { - throw new GlusterRuntimeException( - "Volume created successfully, however following errors occurred while setting options: " - + CoreConstants.NEWLINE + e.getMessage()); - } - } - - private String prepareVolumeCreateCommand(String volumeName, List brickDirectories, int count, - String volumeType, String transportTypeStr) { - StringBuilder command = new StringBuilder("gluster volume create " + volumeName + " "); - if (volumeType != null) { - command.append(volumeType + " " + count + " "); - } - command.append("transport " + transportTypeStr); - for (String brickDir : brickDirectories) { - command.append(" " + brickDir); - } - return command.toString(); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createOptions(java.lang.String, java.util.Map, java.lang.String) - */ - @Override - public void createOptions(String volumeName, Map options, String knownServer) { - String errors = ""; - if (options != null) { - for (Entry option : options.entrySet()) { - String key = option.getKey(); - String value = option.getValue(); - - try { - setOption(volumeName, key, value, knownServer); - } catch(Exception e) { - // append error - errors += e.getMessage() + CoreConstants.NEWLINE; - } - } - } - if (!errors.trim().isEmpty()) { - throw new GlusterRuntimeException("Errors while setting option(s) on volume [" + volumeName + "] : " - + errors.trim()); - } - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#setOption(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void setOption(String volumeName, String key, String value, String knownServer) { - serverUtil.executeOnServer(knownServer, "gluster volume set " + volumeName + " " + key + " " + "\"" - + value + "\""); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#deleteVolume(java.lang.String, java.lang.String) - */ - @Override - public void deleteVolume(String volumeName, String knownServer) { - serverUtil.executeOnServer(knownServer, "gluster --mode=script volume delete " + volumeName); - } - - private String getVolumeInfo(String volumeName, String knownServer) { - return serverUtil.executeOnServer(knownServer, "gluster volume info " + volumeName, String.class); - } - - private String getVolumeInfo(String knownServer) { - return serverUtil.executeOnServer(knownServer, "gluster volume info", String.class); - } - - private boolean readVolumeType(Volume volume, String line) { - String volumeType = StringUtil.extractToken(line, VOLUME_TYPE_PFX); - if (volumeType != null) { - if (volumeType.equals(VOLUME_TYPE_DISTRIBUTE)) { - volume.setVolumeType(VOLUME_TYPE.DISTRIBUTE); - - } else if (volumeType.equals(VOLUME_TYPE_REPLICATE)) { - volume.setVolumeType(VOLUME_TYPE.REPLICATE); - volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); - - } else if ( volumeType.equals(VOLUME_TYPE_DISTRIBUTED_REPLICATTE) ){ - volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); - volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); - - } else if ( volumeType.equals(VOLUME_TYPE_STRIPE) ){ - volume.setVolumeType(VOLUME_TYPE.STRIPE); - volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); - - } else if ( volumeType.equals(VOLUME_TYPE_DISTRIBUTED_STRIPE) ){ - volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); - volume.setReplicaCount(Volume.DEFAULT_STRIPE_COUNT); - } - return true; - } - return false; - } - - private void readReplicaOrStripeCount(Volume volume, String line) { - if (StringUtil.extractToken(line, "x") != null) { - // expected formated of line is "Number of Bricks: 3 x 2 = 6" - int count = Integer.parseInt(line.split("x")[1].split("=")[0].trim()); - if (volume.getVolumeType() == VOLUME_TYPE.STRIPE - || volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_STRIPE) { - volume.setStripeCount(count); - } else if (volume.getVolumeType() == VOLUME_TYPE.REPLICATE - || volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { - volume.setReplicaCount(count); - volume.setStripeCount(0); - } - } - return; - } - - private boolean readVolumeStatus(Volume volume, String line) { - String volumeStatus = StringUtil.extractToken(line, VOLUME_STATUS_PFX); - if (volumeStatus != null) { - volume.setStatus(volumeStatus.equals("Started") ? VOLUME_STATUS.ONLINE : VOLUME_STATUS.OFFLINE); - return true; - } - return false; - } - - private boolean readTransportType(Volume volume, String line) { - String transportType = StringUtil.extractToken(line, VOLUME_TRANSPORT_TYPE_PFX); - if (transportType != null) { - volume.setTransportType(transportType.equals("tcp") ? TRANSPORT_TYPE.ETHERNET : TRANSPORT_TYPE.INFINIBAND); - return true; - } - return false; - } - - private boolean readBrick(Volume volume, String brickLine) { - BRICK_STATUS brickStatus; - if (brickLine.matches("Brick[0-9]+:.*")) { - // line: "Brick1: server1:/export/md0/volume-name" - String brickName = brickLine.split(": ")[1]; - String[] brickParts = brickLine.split(":"); - String serverName = brickParts[1].trim(); - String brickDir = brickParts[2].trim(); - //To get the brick status - brickStatus = getBrickStatus(serverName, volume.getName(), brickName); - - addBrickToVolume(volume, serverName, brickDir, brickStatus); - return true; - } - return false; - } - - private void addBrickToVolume(Volume volume, String serverName, String brickDir, BRICK_STATUS status) { - volume.addBrick(new Brick(serverName, status, brickDir)); - } - - // Do not throw exception, Gracefully handle as Offline brick. - private BRICK_STATUS getBrickStatus(String serverName, String volumeName, String brick){ - try { - String output = serverUtil.executeScriptOnServer(serverName, BRICK_STATUS_SCRIPT + " " + volumeName - + " " + brick, String.class); - if (output.equals(CoreConstants.ONLINE)) { - return BRICK_STATUS.ONLINE; - } else { - return BRICK_STATUS.OFFLINE; - } - } catch(Exception e) { // Particularly interested on ConnectionExecption, if the server is offline - logger.warn("Exception while fetching brick status for [" + volumeName + "][" + brick - + "]. Marking it as offline!", e); - return BRICK_STATUS.OFFLINE; - } - } - - private boolean readBrickGroup(String line) { - return StringUtil.extractToken(line, VOLUME_BRICKS_GROUP_PFX) != null; - } - - private boolean readOptionReconfigGroup(String line) { - return StringUtil.extractToken(line, VOLUME_OPTIONS_RECONFIG_PFX) != null; - } - - private boolean readOption(Volume volume, String line) { - if (line.matches("^[^:]*:.*$")) { - int index = line.indexOf(':'); - volume.setOption(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim()); - - if (line.substring(0, index).trim().equals(Volume.OPTION_NFS_DISABLE)) { - if (line.substring(index + 1, line.length()).trim().equals(GlusterConstants.ON)) { - volume.disableNFS(); - } else { - volume.enableNFS(); - } - } - - return true; - } - return false; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolume(java.lang.String, java.lang.String) - */ - @Override - public Volume getVolume(String volumeName, String knownServer) { - return parseVolumeInfo(getVolumeInfo(volumeName, knownServer)).get(0); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getAllVolumes(java.lang.String) - */ - @Override - public List getAllVolumes(String knownServer) { - return parseVolumeInfo(getVolumeInfo(knownServer)); - } - - private List parseVolumeInfo(String volumeInfoText) { - List volumes = new ArrayList(); - boolean isBricksGroupFound = false; - boolean isOptionReconfigFound = false; - Volume volume = null; - - for (String line : volumeInfoText.split(CoreConstants.NEWLINE)) { - String volumeName = StringUtil.extractToken(line, VOLUME_NAME_PFX); - if (volumeName != null) { - if (volume != null) { - volumes.add(volume); - } - - // prepare next volume to be read - volume = new Volume(); - volume.setName(volumeName); - isBricksGroupFound = isOptionReconfigFound = false; - continue; - } - - if (readVolumeType(volume, line)) - continue; - if (StringUtil.extractToken(line, VOLUME_NUMBER_OF_BRICKS) != null) { - readReplicaOrStripeCount(volume, line); - } - if (readVolumeStatus(volume, line)) - continue; - if (readTransportType(volume, line)) - continue; - if (readBrickGroup(line)) { - isBricksGroupFound = true; - continue; - } - - if (isBricksGroupFound) { - if (readBrick(volume, line)) { - continue; - } else { - isBricksGroupFound = false; - } - } - - if (readOptionReconfigGroup(line)) { - isOptionReconfigFound = true; - continue; - } - - if (isOptionReconfigFound) { - if (readOption(volume, line)) { - continue; - } else { - isOptionReconfigFound = false; - } - } - } - - // add the last read volume - if (volume != null) { - volumes.add(volume); - } - - return volumes; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addBricks(java.lang.String, java.util.List, java.lang.String) - */ - @Override - public void addBricks(String volumeName, List bricks, String knownServer) { - StringBuilder command = new StringBuilder("gluster volume add-brick " + volumeName); - for (String brickDir : bricks) { - command.append(" " + brickDir); - } - - serverUtil.executeOnServer(knownServer, command.toString()); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogLocation(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public String getLogLocation(String volumeName, String brickName, String knownServer) { - String command = "gluster volume log locate " + volumeName + " " + brickName; - String output = serverUtil.executeOnServer(knownServer, command, String.class); - if (output.startsWith(VOLUME_LOG_LOCATION_PFX)) { - return output.substring(VOLUME_LOG_LOCATION_PFX.length()).trim(); - } - - throw new GlusterRuntimeException("Couldn't parse output of command [" + command + "]. Output [" + output - + "] doesn't start with prefix [" + VOLUME_LOG_LOCATION_PFX + "]"); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogFileNameForBrickDir(java.lang.String) - */ - @Override - public String getLogFileNameForBrickDir(String serverName, String brickDir) { - String logFileName = brickDir; - if (logFileName.length() > 0 && logFileName.charAt(0) == '/') { - logFileName = logFileName.replaceFirst("/", ""); - } - logFileName = logFileName.replaceAll("/", "-") + ".log"; - return logFileName; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeBricks(java.lang.String, java.util.List, java.lang.String) - */ - @Override - public void removeBricks(String volumeName, List bricks, String knownServer) { - StringBuilder command = new StringBuilder("gluster --mode=script volume remove-brick " + volumeName); - for (String brickDir : bricks) { - command.append(" " + brickDir); - } - serverUtil.executeOnServer(knownServer, command.toString()); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeServer(java.lang.String, java.lang.String) - */ - @Override - public void removeServer(String existingServer, String serverName) { - serverUtil.executeOnServer(existingServer, "gluster --mode=script peer detach " + serverName); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#checkRebalanceStatus(java.lang.String, java.lang.String) - */ - @Override - public TaskStatus checkRebalanceStatus(String serverName, String volumeName) { - String command = "gluster volume rebalance " + volumeName + " status"; - String output = serverUtil.executeOnServer(serverName, command, String.class).trim(); - TaskStatus taskStatus = new TaskStatus(); - if (output.matches("^rebalance completed.*")) { - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - } else if (output.matches(".*in progress.*")) { - taskStatus.setCode(Status.STATUS_CODE_RUNNING); - } else { - taskStatus.setCode(Status.STATUS_CODE_FAILURE); - } - taskStatus.setMessage(output); - return taskStatus; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopRebalance(java.lang.String, java.lang.String) - */ - @Override - public void stopRebalance(String serverName, String volumeName) { - String command = "gluster volume rebalance " + volumeName + " stop"; - serverUtil.executeOnServer(serverName, command); - } - - /** - * Performs given Brick Migration (replace-brick) Operation on given volume - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume on which the Brick Migration Operation is to be executed - * @param fromBrick - * The source Brick (being replaced) - * @param toBrick - * The destination Brick (which is replacing the source Brick) - * @param operation - * @return - */ - private String performBrickMigrationOperation(String serverName, String volumeName, String fromBrick, - String toBrick, String operation) { - String command = "gluster volume replace-brick " + volumeName + " " + fromBrick + " " + toBrick + " " - + operation; - return serverUtil.executeOnServer(serverName, command, String.class); - } - - /* - * (non-Javadoc) - * - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#executeBrickMigration(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void startBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "start"); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#pauseBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "pause"); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#stopBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "abort"); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#commitBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "commit"); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#checkBrickMigrationStatus(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, String toBrick) { - String output = performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "status"); - - TaskStatus taskStatus = new TaskStatus(); - if (output.matches("^Number of files migrated.*Migration complete$") - || output.matches("^Number of files migrated = 0 .*Current file=")) { - // Note: Workaround - if no file in the volume brick to migrate, - // Gluster CLI is not giving proper (complete) status - taskStatus.setCode(Status.STATUS_CODE_COMMIT_PENDING); - taskStatus.setMessage(output.replaceAll("Migration complete", "Commit pending")); - } else if (output.matches("^Number of files migrated.*Current file=.*")) { - taskStatus.setCode(Status.STATUS_CODE_RUNNING); - } else if (output.matches("^replace brick has been paused.*")) { - taskStatus.setCode(Status.STATUS_CODE_PAUSE); - } else { - taskStatus.setCode(Status.STATUS_CODE_FAILURE); - } - - taskStatus.setMessage(output); - return taskStatus; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolumeOptionsInfo(java.lang.String) - */ - @Override - public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { - return serverUtil.executeOnServer(serverName, "gluster volume set help-xml", VolumeOptionInfoListResponse.class); - } - - public void logRotate(String volumeName, List brickList, String knownServer) { - if (brickList == null || brickList.size() > 0) { - for (String brickDir : brickList) { - serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName + " " + brickDir); - } - } else { - serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java deleted file mode 100644 index a4641e07..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java +++ /dev/null @@ -1,368 +0,0 @@ -package com.gluster.storage.management.gateway.services; - -import java.util.List; -import java.util.Map; - -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; - -/** - * Interface for interacting with GlusterFS. Every version of GlusterFS supported by the Gluster Management Gateway will - * have a corresponding implementation of this interface. - */ -public interface GlusterInterface { - - /** - * Returns the GlusterFS version on given server. - * - * @param serverName - * Server on which Gluster version is to be checked. - * @return - */ - public abstract String getVersion(String serverName); - - /** - * Adds the new server to an existing cluster. - * - * @param existingServer - * Server part of the existing cluster. - * @param newServer - * Server to be added to the cluster. - */ - public abstract void addServer(String existingServer, String newServer); - - /** - * Removes given server from the cluster by executing appropriate Gluster command on given server. - * - * @param existingServer - * Server part of the existing cluster. - * @param serverName - * Server to be removed from the cluster. - */ - public abstract void removeServer(String existingServer, String serverName); - - /** - * Starts the given volume by executing appropriate Gluster command on given server. - * - * @param volumeName - * Volume to be started. - * @param serverName - * Server on which the Gluster command is to be executed. This server must be part of the cluster to - * which the volume belongs. - * @param force - * Flag indicating whether the "force" option should be used for starting the Volume. This is typically - * used when Volume is already started, but at least one of its bricks is offline, and results in - * bringing up the offline bricks. - */ - public abstract void startVolume(String volumeName, String serverName, Boolean force); - - /** - * Stops the given volume by executing appropriate Gluster command on given server. - * - * @param volumeName - * Volume to be stopped. - * @param serverName - * Server on which the Gluster command is to be executed. This server must be part of the cluster to - * which the volume belongs. - * @param force - * Flag indicating whether the Volume should be stopped forcefully. This is typically used if the regular - * stop option fails because of issues like rebalance / brick migration / geo-replication being in - * progress. This results in forcefully stopping the volume, leaving the other processes intact. - */ - public abstract void stopVolume(String volumeName, String serverName, Boolean force); - - /** - * Resets volume options on the given volume by executing appropriate Gluster command on given server. - * - * @param volumeName - * Volume on which options are to be reset. - * @param serverName - * Server on which the Gluster command is to be executed. This server must be part of the cluster to - * which the volume belongs. - */ - public abstract void resetOptions(String volumeName, String serverName); - - /** - * Creates a volume on given volume using given properties. - * - * @param serverName - * Server on which the Gluster command for creating the volume will be executed. This must be part of the - * cluster in which the volume is to be created. - * @param volumeName - * Name of the volume. - * @param volumeType - * Type of the volume e.g. DISTRIBUTE, REPLICATE, STRIPE, etc. See {@link VOLUME_TYPE} for full list of - * valid values. - * @param transportType - * Transport type of the volume e.g. ETHERNET. See {@link TRANSPORT_TYPE} for full list of valid values. - * @param replOrStripeCount - * Replica Count or Stripe count depending on the volume type. Ignored in case of pure distribute volumes - * (no replicate, no stripe). - * @param bricks - * Comma separated list of volume brick directories in following format:
    - * server1:dir1,server2:dir2,server3:dir3,...,servern:dirn - * @param accessProtocols - * Optional parameter indicating access protocols to be enabled for the volume. If empty/null, GLUSTERFS - * and NFS will be enabled. - * @param options - * A comma separated list of volume options to be set on the newly created volume in following format:
    - * key1=value1,key2=value2,key3=value3,...,keyn=valuen - */ - public abstract void createVolume(String serverName, String volumeName, String volumeType, String transportType, - Integer replOrStripeCount, String bricks, String accessProtocols, String options); - - /** - * Creates / Sets the given options on the given volume by executing appropriate Gluster command on the given - * server. - * - * @param volumeName - * Volume on which the options are to be set. - * @param options - * Map containing the volume options to be set. Key = option key, Value = option value. - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - */ - public abstract void createOptions(String volumeName, Map options, String serverName); - - /** - * Sets the given option on given volume by executing appropriate Gluster command on the given server. - * - * @param volumeName - * Volume on which the option is to be set. - * @param key - * Option key (name) - * @param value - * Option value - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - */ - public abstract void setOption(String volumeName, String key, String value, String serverName); - - /** - * Deletes the given volume by executing appropriate Gluster command on the given server. - * - * @param volumeName - * Volume to be deleted. - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - */ - public abstract void deleteVolume(String volumeName, String serverName); - - /** - * Fetches properties of the given Volume by executing appropriate Gluster command on the given server. - * - * @param volumeName - * Volume whose properties are to be fetched. - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @return A {@link Volume} object containing all properties of the given volume - */ - public abstract Volume getVolume(String volumeName, String serverName); - - /** - * Fetches the list of all volumes (along with their properties) by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @return A list of {@link Volume} objects representing every volume present in the cluster to which the given - * server belongs. - */ - public abstract List getAllVolumes(String serverName); - - /** - * Adds given list of bricks to given Volume by executing appropriate Gluster command on the - * given server. - * - * @param volumeName - * Volume to which the bricks are to be added. - * @param bricks - * List of bricks to be added, each in the format serverName:brickDirectory - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - */ - public abstract void addBricks(String volumeName, List bricks, String serverName); - - /** - * Removes given list of bricks from given volume by executing appropriate Gluster command on the - * given server. - * - * @param volumeName - * Volume from which the bricks are to be removed - * @param bricks - * List of bricks to be removed, each in the format serverName:brickDirectory - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - */ - public abstract void removeBricks(String volumeName, List bricks, String serverName); - - /** - * Returns the log location of given brick of given volume by executing appropriate Gluster command on the - * given server. - * - * @param volumeName - * Volume for which log location is to be fetched. - * @param brickName - * Brick of the volume for which log location is to be fetched. - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @return Full path of the log file location (directory) for the given Volume Brick. - */ - public abstract String getLogLocation(String volumeName, String brickName, String serverName); - - /** - * Returns the log file name for given brick directory. - * - * @param serverName - * Server to which the brick belongs - * @param brickDir - * Brick directory for which log file name is to be returned. - * @return The log file name (without path) for the given brick directory. - */ - public abstract String getLogFileNameForBrickDir(String serverName, String brickDir); - - /** - * Checks the status of "Rebalance" operation on given Volume by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose rebalance status is to be checked. - * @return Object of {@link TaskStatus} representing the status of Volume Rebalance. - */ - public abstract TaskStatus checkRebalanceStatus(String serverName, String volumeName); - - /** - * Stops "Rebalance" operation running on given Volume by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose Rebalance is to be stopped. - */ - public abstract void stopRebalance(String serverName, String volumeName); - - /** - * Starts Brick Migration (replace-brick) on given Volume by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose Brick is to be migrated/replaced. - * @param fromBrick - * The source Brick (to be replaced). - * @param toBrick - * The destination Brick (will replace the source Brick). - */ - public abstract void startBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); - - /** - * Pauses Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose Brick is being migrated/replaced. - * @param fromBrick - * The source Brick (being replaced). - * @param toBrick - * The destination Brick (which is replacing the source Brick). - */ - public abstract void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); - - /** - * Aborts Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose Brick is being migrated/replaced. - * @param fromBrick - * The source Brick (being replaced). - * @param toBrick - * The destination Brick (which is replacing the source Brick) - */ - public abstract void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); - - /** - * Commits Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the - * given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose Brick is being migrated/replaced. - * @param fromBrick - * The source Brick (being replaced). - * @param toBrick - * The destination Brick (which is replacing the source Brick) - */ - public abstract void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); - - /** - * Checks status of Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command - * on the given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @param volumeName - * Volume whose Brick is being migrated/replaced. - * @param fromBrick - * The source Brick (being replaced). - * @param toBrick - * The destination Brick (which is replacing the source Brick) - * @return A {@link TaskStatus} object representing the status of Brick Migration - */ - public abstract TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, - String toBrick); - - /** - * Returns information about all the supported Volume Options by executing appropriate Gluster command - * on the given server. - * - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - * @return A {@link VolumeOptionInfoListResponse} object containing information about each and every supported - * Volume Option - */ - public abstract VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName); - - /** - * Rotates the logs for given Bricks of given Volume by executing appropriate Gluster command - * on the given server. - * - * @param volumeName - * Volume whose logs are to be rotated. - * @param brickList - * List of bricks whose logs are to be rotated, each in the format serverName:brickDirectory
    - * This is an optional parameter. If null or empty, all logs of the Volume will be rotated. - * @param serverName - * The server on which the Gluster command will be executed. This must be part of the cluster to which - * the volume belongs. - */ - public abstract void logRotate(String volumeName, List brickList, String serverName); -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java deleted file mode 100644 index 584d5f50..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * GlusterInterfaceService.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.services; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; - -@Component -public class GlusterInterfaceService extends AbstractGlusterInterface { - private HashMap glusterInterfaces = new HashMap(); - - /** - * Returns an instance of the Gluster Interface for given version of GlusterFS - * @param glusterFsVersion - * @return - */ - private GlusterInterface getGlusterInterfaceForVersion(String glusterFsVersion) { - GlusterInterface glusterInterface = glusterInterfaces.get(glusterFsVersion); - if(glusterInterface != null) { - return glusterInterface; - } - - glusterInterface = serverUtil.getBean(Gluster323InterfaceService.class); - glusterInterfaces.put(glusterFsVersion, glusterInterface); - return glusterInterface; - } - - /** - * Returns an instance of Gluster Interface for the version of GlusterFS installed on given server. - * - * @param serverName - * @return - */ - private GlusterInterface getGlusterInterface(String serverName) { - return getGlusterInterfaceForVersion(getVersion(serverName)); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addServer(java.lang.String, java.lang.String) - */ - @Override - public void addServer(String existingServer, String newServer) { - getGlusterInterface(existingServer).addServer(existingServer, newServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) - */ - @Override - public void startVolume(String volumeName, String knownServer, Boolean force) { - getGlusterInterface(knownServer).startVolume(volumeName, knownServer, force); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) - */ - @Override - public void stopVolume(String volumeName, String knownServer, Boolean force) { - getGlusterInterface(knownServer).stopVolume(volumeName, knownServer, force); - } - - public void logRotate(String volumeName, List brickList, String knownServer) { - getGlusterInterface(knownServer).logRotate(volumeName, brickList, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#resetOptions(java.lang.String, java.lang.String) - */ - @Override - public void resetOptions(String volumeName, String knownServer) { - getGlusterInterface(knownServer).resetOptions(volumeName, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createVolume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr, - Integer count, String bricks, String accessProtocols, String options) { - getGlusterInterface(knownServer).createVolume(knownServer, volumeName, volumeTypeStr, transportTypeStr, count, - bricks, accessProtocols, options); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#createOptions(java.lang.String, java.util.Map, java.lang.String) - */ - @Override - public void createOptions(String volumeName, Map options, String knownServer) { - getGlusterInterface(knownServer).createOptions(volumeName, options, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#setOption(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void setOption(String volumeName, String key, String value, String knownServer) { - getGlusterInterface(knownServer).setOption(volumeName, key, value, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#deleteVolume(java.lang.String, java.lang.String) - */ - @Override - public void deleteVolume(String volumeName, String knownServer) { - getGlusterInterface(knownServer).deleteVolume(volumeName, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolume(java.lang.String, java.lang.String) - */ - @Override - public Volume getVolume(String volumeName, String knownServer) { - return getGlusterInterface(knownServer).getVolume(volumeName, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getAllVolumes(java.lang.String) - */ - @Override - public List getAllVolumes(String knownServer) { - return getGlusterInterface(knownServer).getAllVolumes(knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#addBricks(java.lang.String, java.util.List, java.lang.String) - */ - @Override - public void addBricks(String volumeName, List bricks, String knownServer) { - getGlusterInterface(knownServer).addBricks(volumeName, bricks, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogLocation(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public String getLogLocation(String volumeName, String brickName, String knownServer) { - return getGlusterInterface(knownServer).getLogLocation(volumeName, brickName, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getLogFileNameForBrickDir(java.lang.String) - */ - @Override - public String getLogFileNameForBrickDir(String serverName, String brickDir) { - return getGlusterInterface(serverName).getLogFileNameForBrickDir(serverName, brickDir); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeBricks(java.lang.String, java.util.List, java.lang.String) - */ - @Override - public void removeBricks(String volumeName, List bricks, String knownServer) { - getGlusterInterface(knownServer).removeBricks(volumeName, bricks, knownServer); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#removeServer(java.lang.String, java.lang.String) - */ - @Override - public void removeServer(String existingServer, String serverName) { - getGlusterInterface(serverName).removeServer(existingServer, serverName); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#checkRebalanceStatus(java.lang.String, java.lang.String) - */ - @Override - public TaskStatus checkRebalanceStatus(String serverName, String volumeName) { - return getGlusterInterface(serverName).checkRebalanceStatus(serverName, volumeName); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopRebalance(java.lang.String, java.lang.String) - */ - @Override - public void stopRebalance(String serverName, String volumeName) { - getGlusterInterface(serverName).stopRebalance(serverName, volumeName); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#executeBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void startBrickMigration(String onlineServerName, String volumeName, String fromBrick, String toBrick) { - getGlusterInterface(onlineServerName).startBrickMigration(onlineServerName, volumeName, fromBrick, toBrick); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#pauseBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - getGlusterInterface(serverName).pauseBrickMigration(serverName, volumeName, fromBrick, toBrick); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#stopBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - getGlusterInterface(serverName).stopBrickMigration(serverName, volumeName, fromBrick, toBrick); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#commitBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { - getGlusterInterface(serverName).commitBrickMigration(serverName, volumeName, fromBrick, toBrick); - } - - /* - * (non-Javadoc) - * @see com.gluster.storage.management.gateway.services.GlusterInterface#checkBrickMigrationStatus(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, String toBrick) { - return getGlusterInterface(serverName).checkBrickMigrationStatus(serverName, volumeName, fromBrick, toBrick); - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getVolumeOptionsInfo(java.lang.String) - */ - @Override - public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { - return getGlusterInterface(serverName).getVolumeOptionsInfo(serverName); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java deleted file mode 100644 index b20fb2fe..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterServerService.java +++ /dev/null @@ -1,530 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.services; - -import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.response.StringListResponse; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.ProcessUtil; -import com.gluster.storage.management.core.utils.StringUtil; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.data.ServerInfo; -import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.gluster.storage.management.gateway.utils.SshUtil; - -/** - * - */ -@Component -public class GlusterServerService { - private static final String HOSTNAME_PFX = "Hostname:"; - private static final String UUID_PFX = "Uuid:"; - private static final String STATE_PFX = "State:"; - private static final String GLUSTER_SERVER_STATUS_ONLINE = "Peer in Cluster (Connected)"; - private static final String GLUSTERD_INFO_FILE = "/etc/glusterd/glusterd.info"; - - @Autowired - protected ServerUtil serverUtil; - - @Autowired - private ClusterService clusterService; - - @Autowired - private GlusterInterfaceService glusterUtil; - - @Autowired - private SshUtil sshUtil; - - @Autowired - private VolumeService volumeService; - - @Autowired - private DiscoveredServerService discoveredServerService; - - private static final Logger logger = Logger.getLogger(GlusterServerService.class); - - public List getGlusterServers(String clusterName, boolean fetchDetails, Integer maxCount, - String previousServerName) { - List glusterServers; - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - try { - glusterServers = getGlusterServers(clusterName, onlineServer, fetchDetails, maxCount, previousServerName); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterServers = getGlusterServers(clusterName, onlineServer, fetchDetails, maxCount, previousServerName); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - - } - return glusterServers; - } - - private List getGlusterServers(String clusterName, GlusterServer onlineServer, boolean fetchDetails, - Integer maxCount, String previousServerName) { - List glusterServers; - try { - glusterServers = getGlusterServers(onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterServers = getGlusterServers(onlineServer.getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - - // skip the servers by maxCount / previousServerName - glusterServers = GlusterCoreUtil.skipEntities(glusterServers, maxCount, previousServerName); - - if (fetchDetails) { - String errMsg = fetchDetailsOfServers(Collections.synchronizedList(glusterServers)); - if (!errMsg.isEmpty()) { - throw new GlusterRuntimeException("Couldn't fetch details for server(s): " + errMsg); - } - } - return glusterServers; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getGlusterServer(com.gluster.storage.management.core.model.GlusterServer, java.lang.String) - */ - public GlusterServer getGlusterServer(String onlineServer, String serverName) { - List servers = getGlusterServers(onlineServer); - for (GlusterServer server : servers) { - if (server.getName().equalsIgnoreCase(serverName)) { - return server; - } - } - - // Server not found. It's possible that the server name returned by glusterfs is actually IP address - // Hence fetch details of all servers and then compare the host names again. - String errMsg = fetchDetailsOfServers(Collections.synchronizedList(servers)); - if (!errMsg.isEmpty()) { - throw new GlusterRuntimeException("Couldn't fetch details for server(s): " + errMsg); - } - for (GlusterServer server : servers) { - if (server.getName().equalsIgnoreCase(serverName)) { - return server; - } - } - - // still not found! - return null; - } - - private String getUuid(String serverName) { - return serverUtil.executeOnServer(serverName, "cat " + GLUSTERD_INFO_FILE, String.class).split("=")[1]; - } - - /* (non-Javadoc) - * @see com.gluster.storage.management.gateway.utils.GlusterInterface#getGlusterServers(com.gluster.storage.management.core.model.GlusterServer) - */ - public List getGlusterServers(String knownServerName) { - String output = getPeerStatus(knownServerName); - - GlusterServer knownServer = new GlusterServer(knownServerName); - knownServer.setUuid(getUuid(knownServerName)); - - List glusterServers = new ArrayList(); - glusterServers.add(knownServer); - - GlusterServer server = null; - boolean foundHost = false; - boolean foundUuid = false; - for (String line : output.split(CoreConstants.NEWLINE)) { - if (foundHost && foundUuid) { - // Host and UUID is found, we should look for state - String state = StringUtil.extractToken(line, STATE_PFX); - if (state != null) { - server.setStatus(state.contains(GLUSTER_SERVER_STATUS_ONLINE) ? SERVER_STATUS.ONLINE - : SERVER_STATUS.OFFLINE); - // Completed populating current server. Add it to the list - // and reset all related variables. - glusterServers.add(server); - - foundHost = false; - foundUuid = false; - server = null; - } - } else if (foundHost) { - // Host is found, look for UUID - String uuid = StringUtil.extractToken(line, UUID_PFX); - if (uuid != null) { - server.setUuid(uuid); - foundUuid = true; - } - } else { - // Look for the next host - if (server == null) { - server = new GlusterServer(); - } - String hostName = StringUtil.extractToken(line, HOSTNAME_PFX); - if (hostName != null) { - server.setName(hostName); - foundHost = true; - } - } - - } - return glusterServers; - } - - /** - * @param knownServer - * A known server on which the gluster command will be executed to fetch peer status - * @return Outout of the "gluster peer status" command - */ - private String getPeerStatus(String knownServer) { - return serverUtil.executeOnServer(knownServer, "gluster peer status", String.class); - } - - private String fetchDetailsOfServers(List glusterServers) { - try { - List errors = Collections.synchronizedList(new ArrayList()); - - List threads = createThreads(glusterServers, errors); - ProcessUtil.waitForThreads(threads); - - return prepareErrorMessage(errors); - } catch(InterruptedException e) { - String errMsg = "Exception while fetching details of servers! Error: [" + e.getMessage() + "]"; - logger.error(errMsg, e); - throw new GlusterRuntimeException(errMsg, e); - } - } - - private String prepareErrorMessage(List errors) { - String errMsg = ""; - for(String error : errors) { - if(!errMsg.isEmpty()) { - errMsg += CoreConstants.NEWLINE; - } - errMsg += error; - } - - return errMsg; - } - - /** - * Creates threads that will run in parallel and fetch details of given gluster servers - * @param discoveredServers The list to be populated with details of gluster servers - * @param errors List to be populated with errors if any - * @return - * @throws InterruptedException - */ - private List createThreads(List glusterServers, List errors) - throws InterruptedException { - List threads = new ArrayList(); - for (int i = glusterServers.size()-1; i >= 0 ; i--) { - Thread thread = new ServerDetailsThread(glusterServers.get(i), errors); - threads.add(thread); - thread.start(); - if(i >= 5 && i % 5 == 0) { - // After every 5 servers, wait for 1 second so that we don't end up with too many running threads - Thread.sleep(1000); - } - } - return threads; - } - - public class ServerDetailsThread extends Thread { - private List errors; - private GlusterServer server; - private final Logger logger = Logger.getLogger(ServerDetailsThread.class); - - /** - * Private constructor called on each thread - * @param server The server whose details are to be fetched by this thread - * @param errors - */ - private ServerDetailsThread(GlusterServer server, List errors) { - this.errors = errors; - this.server = server; - } - - @Override - public void run() { - try { - logger.info("fetching details of server [" + server.getName() + "] - start"); - serverUtil.fetchServerDetails(server); - logger.info("fetching details of server [" + server.getName() + "] - end"); - } catch (Exception e) { - logger.error("fetching details of server [" + server.getName() + "] - error", e); - errors.add(server.getName() + " : [" + e.getMessage() + "]"); - } - } - } - - public GlusterServer getGlusterServer(String clusterName, String serverName, Boolean fetchDetails) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (serverName == null || serverName.isEmpty()) { - throw new GlusterValidationException("Server name must not be empty!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - throw new GlusterRuntimeException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - return getGlusterServer(clusterName, serverName, onlineServer, fetchDetails); - } - - private GlusterServer getGlusterServer(String clusterName, String serverName, GlusterServer onlineServer, - Boolean fetchDetails) { - GlusterServer server = null; - try { - server = getGlusterServer(onlineServer.getName(), serverName); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - server = getGlusterServer(onlineServer.getName(), serverName); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - - if (fetchDetails && server.isOnline()) { - serverUtil.fetchServerDetails(server); - } - return server; - } - - public boolean isValidServer(String clusterName, String serverName) { - try { - GlusterServer server = getGlusterServer(clusterName, serverName, false); - return server != null; - } catch(Exception e) { - return false; - } - } - - public void removeServerFromCluster(String clusterName, String serverName) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (serverName == null || serverName.isEmpty()) { - throw new GlusterValidationException("Server name must not be empty!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - List servers = cluster.getServers(); - if (servers == null || servers.isEmpty() || !containsServer(servers, serverName)) { - throw new GlusterValidationException("Server [" + serverName + "] is not attached to cluster [" - + clusterName + "]!"); - } - - if (servers.size() == 1) { - // Only one server mapped to the cluster, no "peer detach" required. - // remove the cached online server for this cluster if present - clusterService.removeOnlineServer(clusterName); - } else { - // get an online server that is not same as the server being removed - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName, serverName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - - try { - glusterUtil.removeServer(onlineServer.getName(), serverName); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName, serverName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - glusterUtil.removeServer(onlineServer.getName(), serverName); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - - clusterService.unmapServerFromCluster(clusterName, serverName); - - // since the server is removed from the cluster, it is now available to be added to other clusters. - // Hence add it back to the discovered servers list. - discoveredServerService.addDiscoveredServer(serverName); - - try { - if (serverUtil.isServerOnline(new Server(serverName))) { - volumeService.clearCifsConfiguration(clusterName, onlineServer.getName(), serverName); - } - } catch (Exception e1) { - throw new GlusterRuntimeException( - "Server removed from cluster, however deleting cifs configuration failed ! [ " - + e1.getMessage() + "]"); - } - if (onlineServer.getName().equals(serverName)) { - // since the cached server has been removed from the cluster, remove it from the cache - clusterService.removeOnlineServer(clusterName); - } - } - } - - private boolean containsServer(List servers, String serverName) { - for (ServerInfo server : servers) { - if (server.getName().toUpperCase().equals(serverName.toUpperCase())) { - return true; - } - } - return false; - } - - /** - * Adds given server to cluster and returns its host name. e.g. If serverName passed is an IP address, this method - * will return the host name of the machine with given IP address. - * - * @param clusterName - * @param serverName - * @return - */ - public String addServerToCluster(String clusterName, String serverName) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (serverName == null || serverName.isEmpty()) { - throw new GlusterValidationException("Parameter [" + FORM_PARAM_SERVER_NAME + "] is missing in request!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - boolean publicKeyInstalled = sshUtil.isPublicKeyInstalled(serverName); - if (!publicKeyInstalled && !sshUtil.hasDefaultPassword(serverName)) { - // public key not installed, default password doesn't work. return with error. - throw new GlusterRuntimeException("Gluster Management Gateway uses the default password to set up keys on the server." - + CoreConstants.NEWLINE + "However it seems that the password on server [" + serverName - + "] has been changed manually." + CoreConstants.NEWLINE - + "Please reset it back to the standard default password and try again."); - } - - String hostName = serverUtil.fetchHostName(serverName); - List servers = cluster.getServers(); - if (servers != null && !servers.isEmpty()) { - // cluster has at least one existing server, so that peer probe can be performed - performAddServer(clusterName, hostName); - } else { - // this is the first server to be added to the cluster, which means no - // gluster CLI operation required. just add it to the cluster-server mapping - } - - // add the cluster-server mapping - clusterService.mapServerToCluster(clusterName, hostName); - - // since the server is added to a cluster, it should not more be considered as a - // discovered server available to other clusters - discoveredServerService.removeDiscoveredServer(hostName); - - if (!publicKeyInstalled) { - try { - // install public key (this will also disable password based ssh login) - sshUtil.installPublicKey(hostName); - } catch (Exception e) { - throw new GlusterRuntimeException("Public key could not be installed on [" + hostName + "]! Error: [" - + e.getMessage() + "]"); - } - } - return hostName; - } - - private void performAddServer(String clusterName, String serverName) { - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - - try { - glusterUtil.addServer(onlineServer.getName(), serverName); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); - } - glusterUtil.addServer(onlineServer.getName(), serverName); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - public List getFsTypes(String clusterName, String serverName) { - if (isValidServer(clusterName, serverName)) { - return serverUtil.getFsTypes(serverName); - } else { - throw new GlusterRuntimeException(serverName + " does not belong to the cluster [" + clusterName + "]"); - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java deleted file mode 100644 index 66f839d1..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java +++ /dev/null @@ -1,984 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.services; - -import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICKS; -import static com.gluster.storage.management.core.constants.RESTConstants.TASK_START; -import static com.gluster.storage.management.core.constants.RESTConstants.TASK_STOP; - -import java.io.File; -import java.io.FileOutputStream; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.exceptions.GlusterValidationException; -import com.gluster.storage.management.core.model.Brick; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Volume; -import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; -import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS; -import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE; -import com.gluster.storage.management.core.model.VolumeLogMessage; -import com.gluster.storage.management.core.response.LogMessageListResponse; -import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; -import com.gluster.storage.management.core.utils.DateUtil; -import com.gluster.storage.management.core.utils.FileUtil; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.core.utils.ProcessUtil; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.resources.v1_0.TasksResource; -import com.gluster.storage.management.gateway.tasks.MigrateBrickTask; -import com.gluster.storage.management.gateway.tasks.RebalanceVolumeTask; -import com.gluster.storage.management.gateway.utils.ServerUtil; - -/** - * - */ -@Component -public class VolumeService { - private static final String ALL_SERVERS_FILE_NAME = "servers"; - private static final String VOLUME_GET_CIFS_USERS_SCRIPT = "get_volume_user_cifs.py"; - private static final String VOLUME_CIFS_GRUN_SCRIPT = "grun.py"; - private static final String VOLUME_CREATE_CIFS_SCRIPT = "create_volume_cifs_all.py"; - private static final String VOLUME_MODIFY_CIFS_SCRIPT = "update_volume_cifs_all.py"; - private static final String VOLUME_START_CIFS_PEER_SCRIPT = "start_volume_cifs.py"; - private static final String VOLUME_STOP_CIFS_PEER_SCRIPT = "stop_volume_cifs.py"; - private static final String VOLUME_DELETE_CIFS_SCRIPT = "delete_volume_cifs_all.py"; - private static final String VOLUME_BRICK_LOG_SCRIPT = "get_volume_brick_log.py"; - private static final String VOLUME_DIRECTORY_CLEANUP_SCRIPT = "clear_volume_directory.py"; - private static final String REMOVE_SERVER_VOLUME_CIFS_CONFIG = "remove_server_volume_cifs_config.py"; - private static final String ALL_ONLINE_VOLUMES_FILE_NAME = "volumes"; - - @Autowired - private ClusterService clusterService; - - @Autowired - private GlusterInterfaceService glusterUtil; - - @Autowired - private GlusterServerService glusterServerService; - - @Autowired - protected ServerUtil serverUtil; - - // TODO: To be replaced with taskService - @Autowired - private TasksResource taskResource; - - private static final Logger logger = Logger.getLogger(VolumeService.class); - - public void addBricksToVolume(String clusterName, String volumeName, String bricks) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (bricks == null || bricks.isEmpty()) { - throw new GlusterValidationException("Bricks must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - List brickList = Arrays.asList(bricks.split(",")); - try { - glusterUtil.addBricks(volumeName, brickList, onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterUtil.addBricks(volumeName, brickList, onlineServer.getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - public Volume getVolume(String clusterName, String volumeName) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - Volume volume; - try { - volume = glusterUtil.getVolume(volumeName, onlineServer.getName()); - // Collect the CIFS users if CIFS Re-exported - fetchVolumeCifsUsers(clusterName, volume); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - volume = glusterUtil.getVolume(volumeName, onlineServer.getName()); - // Collect the CIFS users if CIFS Re-exported - fetchVolumeCifsUsers(clusterName, volume); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - return volume; - } - - public List getVolumes(String clusterName, Integer maxCount, String previousVolumeName) { - List volumes = getVolumes(clusterName); - // Skip the volumes by maxCount / previousServerName - volumes = GlusterCoreUtil.skipEntities(volumes, maxCount, previousVolumeName); - // fetch CIFS users of the volumes - fetchCifsUsers(clusterName, volumes); - - return volumes; - } - - private List getVolumes(String clusterName) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - if(cluster.getServers().size() == 0) { - // no server added yet. return an empty array. - return new ArrayList(); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - try { - return glusterUtil.getAllVolumes(onlineServer.getName()); - } catch (Exception e) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - return glusterUtil.getAllVolumes(onlineServer.getName()); - } - } - - private void fetchVolumeCifsUsers(String clusterName, Volume volume) { - List users = new ArrayList(); - try { - ProcessResult result = serverUtil - .executeGlusterScript(true, VOLUME_GET_CIFS_USERS_SCRIPT, volume.getName()); - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - String output = result.getOutput().trim(); - if (output.isEmpty()) { - volume.disableCifs(); - } else { - users = Arrays.asList(output.split(CoreConstants.NEWLINE)); - volume.enableCifs(); - volume.setCifsUsers(users); - } - } catch (Exception e) { - throw new GlusterRuntimeException("Error in fetching CIFS users [" + volume.getName() + "]: " - + e.getMessage()); - } - return; - } - - private void fetchCifsUsers(String clusterName, List volumes) { - for (Volume volume: volumes) { - fetchVolumeCifsUsers(clusterName, volume); - } - } - - private File createOnlineServerList(String clusterName) { - String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); - String clusterServersListFile = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR - + ALL_SERVERS_FILE_NAME + "_" + timestamp; - - try { - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - List glusterServers = glusterServerService.getGlusterServers(onlineServer.getName()); - File serversFile = new File(clusterServersListFile); - FileOutputStream fos = new FileOutputStream(serversFile); - for (GlusterServer server : glusterServers) { - if (server.getStatus() == SERVER_STATUS.ONLINE) { - fos.write((server.getName() + CoreConstants.NEWLINE).getBytes()); - } - } - fos.close(); - return serversFile; - } catch (Exception e) { - throw new GlusterRuntimeException("Error in preparing server list: [" + e.getMessage() + "]"); - } - } - - public void startCifsReExport(String clusterName, String volumeName) { - try { - File file = createOnlineServerList(clusterName); - ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_CIFS_GRUN_SCRIPT, - file.getAbsolutePath(), VOLUME_START_CIFS_PEER_SCRIPT, volumeName); - file.delete(); - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - } catch (Exception e) { - throw new GlusterRuntimeException("Error in starting CIFS services for volume [" + volumeName + "]: " - + e.getMessage()); - } - } - - public void stopCifsReExport(String clusterName, String volumeName) { - try { - File file = createOnlineServerList(clusterName); - ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_CIFS_GRUN_SCRIPT, - file.getAbsolutePath(), VOLUME_STOP_CIFS_PEER_SCRIPT, volumeName); - file.delete(); - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - } catch (Exception e) { - throw new GlusterRuntimeException("Error in stoping CIFS services for volume [" + volumeName + "]: " - + e.getMessage()); - } - } - - public void deleteCifsUsers(String clusterName, String volumeName) { - try { - File file = createOnlineServerList(clusterName); - ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_DELETE_CIFS_SCRIPT, - file.getAbsolutePath(), volumeName); - file.delete(); - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - } catch (Exception e) { - throw new GlusterRuntimeException("Error in deleting CIFS configuration [" + volumeName + "]: " - + e.getMessage()); - } - } - - public void createCIFSUsers(String clusterName, String volumeName, String cifsUsers) { - try { - File file = createOnlineServerList(clusterName); - List arguments = new ArrayList(); - arguments.add(file.getAbsolutePath()); - arguments.add(volumeName); - arguments.addAll( Arrays.asList(cifsUsers.replaceAll(" ", "").split(","))); - ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_CREATE_CIFS_SCRIPT, arguments); - file.delete(); - Volume volume = getVolume(clusterName, volumeName); - // If the volume service is already in running, create user may start CIFS re-export automatically. - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - startCifsReExport(clusterName, volumeName); - } - /* - * else { stopCifsReExport(clusterName, volumeName); } - */ - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - } catch (Exception e) { - throw new GlusterRuntimeException("Error in creating CIFS configuration [" + volumeName + "]: " - + e.getMessage()); - } - } - - @Deprecated - public void modifyCIFSUsers(String clusterName, String volumeName, String cifsUsers) { - try { - File file = createOnlineServerList(clusterName); - List arguments = new ArrayList(); - arguments.add(file.getAbsolutePath()); - arguments.add(volumeName); - arguments.addAll( Arrays.asList(cifsUsers.split(","))); - ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_MODIFY_CIFS_SCRIPT, arguments); - file.delete(); - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - } catch (Exception e) { - throw new GlusterRuntimeException("Error in updating CIFS configuration [" + volumeName + "]: " - + e.getMessage()); - } - } - - // To clear all the volume CIFS configurations from the server - public void clearCifsConfiguration(String clusterName, String onlineServerName, String serverName) { - File volumesFile = createOnlineVolumeList(clusterName, onlineServerName); - if (volumesFile == null) { - return; - } - try { - removeServerVolumeCifsConfig(serverName, volumesFile.getAbsolutePath()); - volumesFile.delete(); - } catch(Exception e) { - volumesFile.delete(); - throw new GlusterRuntimeException("Error in clearing volume CIFS configuration: [" + e.getMessage() + "]"); - } - } - - private File createOnlineVolumeList(String clusterName, String onlineServerName) { - String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); - String volumeListFileName = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR - + ALL_ONLINE_VOLUMES_FILE_NAME + "_" + timestamp; - try { - List volumes = getVolumes(clusterName); - if (volumes == null || volumes.size() == 0) { - return null; - } - File volumesFile = new File(volumeListFileName); - FileOutputStream fos = new FileOutputStream(volumesFile); - for (Volume volume : volumes) { - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - fos.write((volume.getName() + CoreConstants.NEWLINE).getBytes()); - } - } - fos.close(); - return volumesFile; - } catch (Exception e) { - throw new GlusterRuntimeException("Error in preparing volume list: [" + e.getMessage() + "]"); - } - } - - - public void removeServerVolumeCifsConfig(String serverName, String volumesFileName) { - ProcessResult result = serverUtil.executeGlusterScript(true, REMOVE_SERVER_VOLUME_CIFS_CONFIG, serverName, - volumesFileName); - if (!result.isSuccess()) { - throw new GlusterRuntimeException(result.toString()); - } - } - - public void createVolume(String clusterName, String volumeName, String volumeType, String transportType, - Integer count, String bricks, String accessProtocols, String options, - String cifsUsers) { - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - if ((volumeType.equals(VOLUME_TYPE.REPLICATE.toString()) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE - .toString())) && count <= 0) { - throw new GlusterValidationException("Replica count must be a positive integer"); - } - - if ((volumeType.equals(VOLUME_TYPE.STRIPE.toString()) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE - .toString())) && count <= 0) { - throw new GlusterValidationException("Stripe count must be a positive integer"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - try { - glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, count, - bricks, accessProtocols, options); - - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, count, - bricks, accessProtocols, options); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - - List nasProtocols = Arrays.asList(accessProtocols.split(",")); - // if cifs enabled - if (nasProtocols.contains(NAS_PROTOCOL.CIFS.toString())) { - try { - createCIFSUsers(clusterName, volumeName, cifsUsers); - } catch (Exception e) { - throw new GlusterRuntimeException(CoreConstants.NEWLINE + e.getMessage()); - } - } - } - - public String downloadLogs(Volume volume) { - // create temporary directory - File tempDir = FileUtil.createTempDir(); - String tempDirPath = tempDir.getPath(); - - for (Brick brick : volume.getBricks()) { - String logDir = glusterUtil.getLogLocation(volume.getName(), brick.getQualifiedName(), - brick.getServerName()); - String logFileName = glusterUtil.getLogFileNameForBrickDir(brick.getServerName(), brick.getBrickDirectory()); - String logFilePath = logDir + CoreConstants.FILE_SEPARATOR + logFileName; - - serverUtil.getFileFromServer(brick.getServerName(), logFilePath, tempDirPath); - - String fetchedLogFile = tempDirPath + File.separator + logFileName; - // append log file name with server name so that log files don't overwrite each other - // in cases where the brick log file names are same on multiple servers - String localLogFile = tempDirPath + File.separator + brick.getServerName() + "-" + logFileName; - - FileUtil.renameFile(fetchedLogFile, localLogFile); - } - - String gzipPath = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR + volume.getName() + "-logs.tar.gz"; - ProcessUtil.executeCommand("tar", "czvf", gzipPath, "-C", tempDir.getParent(), tempDir.getName()); - - // delete the temp directory - FileUtil.recursiveDelete(tempDir); - - return gzipPath; - } - - public List getLogs(String clusterName, String volumeName, String brickName, String severity, - String fromTimestamp, String toTimestamp, Integer lineCount) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - if (lineCount == null || lineCount == 0) { - lineCount = 100; - } - - List logMessages = null; - Volume volume = getVolume(clusterName, volumeName); - - if (brickName == null || brickName.isEmpty() || brickName.equals(CoreConstants.ALL)) { - logMessages = getLogsForAllBricks(volume, lineCount); - } else { - // fetch logs for given brick of the volume - for (Brick brick : volume.getBricks()) { - if (brick.getQualifiedName().equals(brickName)) { - logMessages = getBrickLogs(volume, brick, lineCount); - break; - } - } - } - - filterLogsBySeverity(logMessages, severity); - filterLogsByTime(logMessages, fromTimestamp, toTimestamp); - return logMessages; - } - - private void filterLogsByTime(List logMessages, String fromTimestamp, String toTimestamp) { - Date fromTime = null, toTime = null; - - if (fromTimestamp != null && !fromTimestamp.isEmpty()) { - fromTime = DateUtil.stringToDate(fromTimestamp); - } - - if (toTimestamp != null && !toTimestamp.isEmpty()) { - toTime = DateUtil.stringToDate(toTimestamp); - } - - List messagesToRemove = new ArrayList(); - for (VolumeLogMessage logMessage : logMessages) { - Date logTimestamp = logMessage.getTimestamp(); - if (fromTime != null && logTimestamp.before(fromTime)) { - messagesToRemove.add(logMessage); - continue; - } - - if (toTime != null && logTimestamp.after(toTime)) { - messagesToRemove.add(logMessage); - } - } - logMessages.removeAll(messagesToRemove); - } - - private void filterLogsBySeverity(List logMessages, String severity) { - if (severity == null || severity.isEmpty()) { - return; - } - - List messagesToRemove = new ArrayList(); - for (VolumeLogMessage logMessage : logMessages) { - if (!logMessage.getSeverity().equals(severity)) { - messagesToRemove.add(logMessage); - } - } - logMessages.removeAll(messagesToRemove); - } - - private List getLogsForAllBricks(Volume volume, Integer lineCount) { - List logMessages; - logMessages = new ArrayList(); - // fetch logs for every brick of the volume - for (Brick brick : volume.getBricks()) { - logMessages.addAll(getBrickLogs(volume, brick, lineCount)); - } - - // Sort the log messages based on log timestamp - Collections.sort(logMessages, new Comparator() { - @Override - public int compare(VolumeLogMessage message1, VolumeLogMessage message2) { - return message1.getTimestamp().compareTo(message2.getTimestamp()); - } - }); - - return logMessages; - } - - private List getBrickLogs(Volume volume, Brick brick, Integer lineCount) - throws GlusterRuntimeException { - String logDir = glusterUtil.getLogLocation(volume.getName(), brick.getQualifiedName(), brick.getServerName()); - String logFileName = glusterUtil.getLogFileNameForBrickDir(brick.getServerName(), brick.getBrickDirectory()); - String logFilePath = logDir + CoreConstants.FILE_SEPARATOR + logFileName; - - // Usage: get_volume_disk_log.py - LogMessageListResponse response = serverUtil.executeScriptOnServer(brick.getServerName(), - VOLUME_BRICK_LOG_SCRIPT + " " + logFilePath + " " + lineCount, LogMessageListResponse.class); - - // populate disk and trim other fields - List logMessages = response.getLogMessages(); - for (VolumeLogMessage logMessage : logMessages) { - logMessage.setBrick(brick.getQualifiedName()); - } - return logMessages; - } - - public String migrateBrickStart(String clusterName, String volumeName, String fromBrick, String toBrick, - Boolean autoCommit) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty!"); - } - - if (fromBrick == null || fromBrick.isEmpty()) { - throw new GlusterValidationException("From brick must not be empty!"); - } - - if (toBrick == null || toBrick.isEmpty()) { - throw new GlusterValidationException("To brick must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - if(autoCommit == null) { - autoCommit = false; - } - - MigrateBrickTask migrateDiskTask = new MigrateBrickTask(clusterService, clusterName, volumeName, fromBrick, - toBrick); - migrateDiskTask.setAutoCommit(autoCommit); - migrateDiskTask.start(); - taskResource.addTask(clusterName, migrateDiskTask); - return migrateDiskTask.getTaskInfo().getName(); // Return Task ID - } - - private String getLayout(Boolean isFixLayout, Boolean isMigrateData, - Boolean isForcedDataMigrate) { - String layout = ""; - if (isForcedDataMigrate) { - layout = "forced-data-migrate"; - } else if (isMigrateData) { - layout = "migrate-data"; - } else if (isFixLayout) { - layout = "fix-layout"; - } - return layout; - } - - public String rebalanceStart(String clusterName, String volumeName, Boolean isFixLayout, Boolean isMigrateData, - Boolean isForcedDataMigrate) { - RebalanceVolumeTask rebalanceTask = new RebalanceVolumeTask(clusterService, clusterName, volumeName, getLayout( - isFixLayout, isMigrateData, isForcedDataMigrate)); - rebalanceTask.start(); - taskResource.addTask(clusterName, rebalanceTask); - return rebalanceTask.getId(); - } - - public void rebalanceStop(String clusterName, String volumeName) { - // TODO: arrive at the task id and fetch it - String taskId = ""; - - taskResource.getTask(clusterName, taskId).stop(); - } - - public void startVolume(String clusterName, GlusterServer onlineServer, Volume volume, Boolean force) { - glusterUtil.startVolume(volume.getName(), onlineServer.getName(), force); - - // call the start_volume_cifs.py script only if the volume is cifs enabled - if (volume.isCifsEnable()) { - startCifsReExport(clusterName, volume.getName()); - } - } - - public void stopVolume(String clusterName, GlusterServer onlineServer, Volume volume, Boolean force) { - glusterUtil.stopVolume(volume.getName(), onlineServer.getName(), force); - - // call the stop_volume_cifs.py script only if the volume is cifs enabled - if (volume.isCifsEnable()) { - stopCifsReExport(clusterName, volume.getName()); - } - } - - public void logRotate(String clusterName, String volumeName, List brickList) { - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - try { - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - glusterUtil.logRotate(volumeName, brickList, onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - glusterUtil.logRotate(volumeName, brickList, onlineServer.getName()); - } else { - throw new GlusterRuntimeException("Volume [" + volumeName + "] log rotation failed!", e); - } - } - } - - public void performVolumeOperation(String clusterName, String volumeName, String operation, Boolean force) { - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - try { - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - performOperation(clusterName, volumeName, operation, onlineServer, force); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - performOperation(clusterName, volumeName, operation, onlineServer, force); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void performOperation(String clusterName, String volumeName, String operation, GlusterServer onlineServer, - Boolean force) { - Volume volume = null; - try { - volume = getVolume(clusterName, volumeName); - } catch (Exception e) { - throw new GlusterRuntimeException("Could not fetch volume info for volume [" + volumeName + "]" - + e.getMessage()); - } - - if (operation.equals(TASK_START)) { - startVolume(clusterName, onlineServer, volume, force); - } else if (operation.equals(TASK_STOP)) { - stopVolume(clusterName, onlineServer, volume, force); - } else { - throw new GlusterValidationException("Invalid operation code [" + operation + "]"); - } - } - - public void removeBricksFromVolume(String clusterName, String volumeName, String bricks, Boolean deleteFlag) { - // Convert from comma separated string (query parameter) - List brickList = Arrays.asList(bricks.split(",")); - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if (volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty!"); - } - - if (bricks == null || bricks.isEmpty()) { - throw new GlusterValidationException("Parameter [" + QUERY_PARAM_BRICKS + "] is missing in request!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - if(deleteFlag == null) { - deleteFlag = false; - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - removeBricks(clusterName, volumeName, brickList, onlineServer); - cleanupDirectories(brickList, volumeName, brickList.size(), deleteFlag); - } - - private void removeBricks(String clusterName, String volumeName, List brickList, GlusterServer onlineServer) { - try { - glusterUtil.removeBricks(volumeName, brickList, onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterUtil.removeBricks(volumeName, brickList, onlineServer.getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void cleanupDirectories(List bricks, String volumeName, int maxIndex, boolean deleteFlag) { - String errors = ""; - for (int i = 0; i < maxIndex; i++) { - String[] brickInfo = bricks.get(i).split(":"); - String serverName = brickInfo[0]; - String brickDirectory = brickInfo[1]; - - try { - serverUtil.executeScriptOnServer(serverName, VOLUME_DIRECTORY_CLEANUP_SCRIPT + " " - + brickDirectory + " " + (deleteFlag ? "-d" : "")); - } catch(Exception e) { - logger.error("Error while cleaning brick [" + serverName + ":" + brickDirectory + "] of volume [" - + volumeName + "] : " + e.getMessage(), e); - errors += "[" + brickDirectory + "] => " + e.getMessage() + CoreConstants.NEWLINE; - } - } - if(!errors.trim().isEmpty()) { - throw new GlusterRuntimeException("Volume directory cleanup errors: " + errors.trim()); - } - } - - public void deleteVolume(String clusterName, String volumeName, Boolean deleteFlag) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty"); - } - - if (volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if(onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - if (deleteFlag == null) { - deleteFlag = false; - } - - Volume volume = getVolume(clusterName, volumeName); - - List bricks = volume.getBricks(); - glusterUtil.deleteVolume(volumeName, onlineServer.getName()); - - try { - postDelete(volumeName, bricks, deleteFlag); - if (volume.isCifsEnable()) { - if (volume.getStatus() == VOLUME_STATUS.ONLINE) { - stopCifsReExport(clusterName, volumeName); - } - deleteCifsUsers(clusterName, volumeName); - } - } catch(Exception e) { - throw new GlusterRuntimeException("Volume [" + volumeName - + "] deleted from cluster, however following error(s) occurred: " + CoreConstants.NEWLINE - + e.getMessage()); - } - } - - private void postDelete(String volumeName, List bricks, boolean deleteFlag) { - for (Brick brick : bricks) { - String brickDirectory = brick.getBrickDirectory(); - // String mountPoint = brickDirectory.substring(0, brickDirectory.lastIndexOf("/")); - - serverUtil.executeScriptOnServer(brick.getServerName(), VOLUME_DIRECTORY_CLEANUP_SCRIPT + " " - + brickDirectory + " " + (deleteFlag ? "-d" : "")); - } - } - - public void resetVolumeOptions(String clusterName, String volumeName) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if(volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - try { - glusterUtil.resetOptions(volumeName, onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - glusterUtil.resetOptions(volumeName, onlineServer.getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - - } - } - - public void setVolumeOption(String clusterName, String volumeName, String key, String value) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - if(volumeName == null || volumeName.isEmpty()) { - throw new GlusterValidationException("Volume name must not be empty!"); - } - - if(key == null || key.isEmpty()) { - throw new GlusterValidationException("Option key must not be empty!"); - } - - if(value == null || value.isEmpty()) { - throw new GlusterValidationException("Option value must not be empty!"); - } - - if (clusterService.getCluster(clusterName) == null) { - throw new GlusterRuntimeException("Cluster [" + clusterName + "] not found!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - try { - glusterUtil.setOption(volumeName, key, value, onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - // online server has gone offline! try with a different one. - onlineServer = clusterService.getNewOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - glusterUtil.setOption(volumeName, key, value, onlineServer.getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - public VolumeOptionInfoListResponse getVolumeOptionsInfo(String clusterName) { - if (clusterName == null || clusterName.isEmpty()) { - throw new GlusterValidationException("Cluster name must not be empty!"); - } - - ClusterInfo cluster = clusterService.getCluster(clusterName); - if (cluster == null) { - throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); - } - - if(cluster.getServers().isEmpty()) { - throw new GlusterValidationException("Cluster [" + clusterName + "] is empty! Can't fetch Volume Options Information!"); - } - - GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); - if (onlineServer == null) { - throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); - } - - try { - return glusterUtil.getVolumeOptionsInfo(onlineServer.getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { - onlineServer = clusterService.getNewOnlineServer(clusterName); - return glusterUtil.getVolumeOptionsInfo(onlineServer.getName()); - } else { - throw new GlusterRuntimeException("Fetching volume options info failed! [" + e.getMessage() + "]"); - } - } - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitServerTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitServerTask.java deleted file mode 100644 index db95e8b6..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitServerTask.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * GlusterServerInitializer.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.tasks; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.servlet.ServletContext; - -import org.apache.derby.tools.ij; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.RowCallbackHandler; -import org.springframework.jdbc.core.support.JdbcDaoSupport; -import org.springframework.security.authentication.dao.SaltSource; -import org.springframework.security.authentication.encoding.PasswordEncoder; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.data.PersistenceDao; - -/** - * Initializes the Gluster Management Server. - */ -public class InitServerTask extends JdbcDaoSupport { - @Autowired - private PasswordEncoder passwordEncoder; - - @Autowired - private SaltSource saltSource; - - @Autowired - private UserDetailsService userDetailsService; - - @Autowired - private String appVersion; - - @Autowired - private PersistenceDao clusterDao; - - @Autowired - ServletContext servletContext; - - private static final String SCRIPT_DIR = "data/scripts/"; - - public void securePasswords() { - getJdbcTemplate().query("select username, password from users", new RowCallbackHandler() { - @Override - public void processRow(ResultSet rs) throws SQLException { - String username = rs.getString(1); - String password = rs.getString(2); - UserDetails user = userDetailsService.loadUserByUsername(username); - - String encodedPassword = passwordEncoder.encodePassword(password, saltSource.getSalt(user)); - getJdbcTemplate().update("update users set password = ? where username = ?", encodedPassword, username); - logger.debug("Updating password for username: " + username); - } - }); - } - - private void executeScript(File script) { - ByteArrayOutputStream sqlOut = new ByteArrayOutputStream(); - int numOfExceptions; - try { - numOfExceptions = ij.runScript(getJdbcTemplate().getDataSource().getConnection(), new FileInputStream( - script), CoreConstants.ENCODING_UTF8, sqlOut, CoreConstants.ENCODING_UTF8); - String output = sqlOut.toString(); - sqlOut.close(); - logger.debug("Data script [" + script.getName() + "] returned with exit status [" + numOfExceptions - + "] and output [" + output + "]"); - if (numOfExceptions != 0) { - throw new GlusterRuntimeException("Server data initialization script [ " + script.getName() - + "] failed with [" + numOfExceptions + "] exceptions! [" + output + "]"); - } - } catch (Exception ex) { - throw new GlusterRuntimeException("Server data initialization script [" + script.getName() + "] failed!", - ex); - } - } - - private void initDatabase() { - logger.info("Initializing server data..."); - executeScriptsFrom(getDirFromRelativePath(SCRIPT_DIR + appVersion)); - - securePasswords(); // encrypt the passwords - } - - private File getDirFromRelativePath(String relativePath) { - String scriptDirPath = servletContext.getRealPath(relativePath); - File scriptDir = new File(scriptDirPath); - return scriptDir; - } - - private void executeScriptsFrom(File scriptDir) { - if (!scriptDir.exists()) { - throw new GlusterRuntimeException("Script directory [" + scriptDir.getAbsolutePath() + "] doesn't exist!"); - } - - List scripts = Arrays.asList(scriptDir.listFiles()); - if(scripts.size() == 0) { - throw new GlusterRuntimeException("Script directory [" + scriptDir.getAbsolutePath() + "] is empty!"); - } - - Collections.sort(scripts); - for (File script : scripts) { - executeScript(script); - } - } - - /** - * Initializes the server database, if running for the first time. - */ - public synchronized void initServer() { - try { - String dbVersion = getDBVersion(); - if (!appVersion.equals(dbVersion)) { - logger.info("App version [" + appVersion + "] differs from data version [" + dbVersion - + "]. Trying to upgrade data..."); - upgradeData(dbVersion, appVersion); - } - } catch (Exception ex) { - logger.info("No cluster created yet. DB version query failed with error [" + ex.getMessage() + "]", ex); - // Database not created yet. Create it! - initDatabase(); - } - } - - private void upgradeData(String fromVersion, String toVersion) { - executeScriptsFrom(getDirFromRelativePath(SCRIPT_DIR + fromVersion + "-" + toVersion)); - } - - private String getDBVersion() { - return (String) clusterDao.getSingleResultFromSQL("select version from version"); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java deleted file mode 100644 index 73b1e78f..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/InitializeDiskTask.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * InitializeDiskTask.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.tasks; - -import org.springframework.context.ApplicationContext; -import org.springframework.web.context.ContextLoader; - -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.model.InitDiskStatusResponse; -import com.gluster.storage.management.core.model.InitDiskStatusResponse.FORMAT_STATUS; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.sun.jersey.core.util.Base64; - -public class InitializeDiskTask extends Task { - - private static final String INITIALIZE_DISK_SCRIPT = "format_device.py"; - private static final String INITIALIZE_DISK_STATUS_SCRIPT = "get_format_device_status.py"; - - private String serverName; - private String diskName; - private String fsType; - private String mountPoint; - private ServerUtil serverUtil; - - public InitializeDiskTask(ClusterService clusterService, String clusterName, String serverName, String diskName, - String fsType, String mountPoint) { - // Reference contains "Server:disk" - super(clusterService, clusterName, TASK_TYPE.DISK_FORMAT, serverName + ":" + diskName, "Initialize disk " - + serverName + ":" + diskName, false, false, false); - - setServerName(serverName); - setDiskName(diskName); - setFsType(fsType); - setMountpoint(mountPoint); - taskInfo.setName(getId()); - init(); - } - - public InitializeDiskTask(ClusterService clusterService, String clusterName, TaskInfo info) { - super(clusterService, clusterName, info); - init(); - } - - private void init() { - ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); - serverUtil = ctx.getBean(ServerUtil.class); - } - - @Override - public String getId() { - return new String( - Base64.encode(getClusterName() + "-" + taskInfo.getType() + "-" + serverName + ":" + diskName)); - } - - @Override - public void resume() { - getTaskInfo().setStatus( - new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, - "Stop/Pause/Resume is not supported in Disk Initialization"))); - } - - @Override - public void stop() { - getTaskInfo().setStatus( - new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, - "Stop/Pause/Resume is not supported in Disk Initialization"))); - } - - @Override - public void pause() { - getTaskInfo().setStatus( - new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, - "Stop/Pause/Resume is not supported in Disk Initialization"))); - } - - @Override - public void commit() { - // TODO Auto-generated method stub - } - - @Override - public TASK_TYPE getType() { - return TASK_TYPE.DISK_FORMAT; - } - - - @Override - public void start() { - try { - startInitializeDisk(serverName); - } catch(ConnectionException e) { - // online server might have gone offline. update the failure status - getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); - } - } - - private void startInitializeDisk(String serverName) { - String output = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_SCRIPT + " " + getFsType() + " \"" - + getMountpoint() + "\" " + getDiskName() ); - TaskStatus taskStatus = new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, output)); - taskStatus.setPercentageSupported((getFsType().equals(GlusterConstants.FSTYPE_XFS)) ? false : true); - getTaskInfo().setStatus(taskStatus); - } - - @Override - public TaskStatus checkStatus() { - - try { - return getInitializingDeviceStatus(serverName, getDiskName()); - } catch(ConnectionException e) { - // online server might have gone offline. update the failure status - return new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage())); - } - } - - private TaskStatus getInitializingDeviceStatus(String serverName, String diskName) { - InitDiskStatusResponse initDiskStatusResponse; - TaskStatus taskStatus = new TaskStatus(); - - try { - initDiskStatusResponse = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_STATUS_SCRIPT + " " - + diskName, InitDiskStatusResponse.class); - } catch(RuntimeException e) { - taskStatus.setCode(Status.STATUS_CODE_FAILURE); - taskStatus.setMessage(e.getMessage()); - throw e; - } - - if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.COMPLETED) { - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - } else if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.IN_PROGRESS) { - taskStatus.setCode(Status.STATUS_CODE_RUNNING); - taskStatus.setPercentCompleted(Math.round(initDiskStatusResponse.getCompletedBlocks() - / initDiskStatusResponse.getTotalBlocks() * 100)); - } else if(initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.NOT_RUNNING) { - taskStatus.setCode(Status.STATUS_CODE_FAILURE); - } - - taskStatus.setMessage(initDiskStatusResponse.getMessage()); - return taskStatus; - } - - public void setDiskName(String diskName) { - this.diskName = diskName; - } - - public String getDiskName() { - return diskName; - } - - public void setServerName(String serverName) { - this.serverName = serverName; - } - - public String getServerName() { - return serverName; - } - - public void setFsType(String fsType) { - this.fsType = fsType; - } - - public String getFsType() { - return fsType; - } - - public void setMountpoint(String deviceMountPoint) { - this.mountPoint = deviceMountPoint; - } - - public String getMountpoint() { - return mountPoint; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java deleted file mode 100644 index e5cb17f1..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/MigrateBrickTask.java +++ /dev/null @@ -1,220 +0,0 @@ -/** - * MigrateDiskTask.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.tasks; - -import org.springframework.context.ApplicationContext; -import org.springframework.web.context.ContextLoader; - -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.services.GlusterInterfaceService; -import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.sun.jersey.core.util.Base64; - -public class MigrateBrickTask extends Task { - - private String fromBrick; - private String toBrick; - private Boolean autoCommit; - private GlusterInterfaceService glusterInterface; - protected ServerUtil serverUtil; - - public String getFromBrick() { - return fromBrick; - } - - public void setFromBrick(String fromBrick) { - this.fromBrick = fromBrick; - } - - public String getToBrick() { - return toBrick; - } - - public void setToBrick(String toBrick) { - this.toBrick = toBrick; - } - - public Boolean getAutoCommit() { - return autoCommit; - } - - public void setAutoCommit(Boolean autoCommit) { - this.autoCommit = autoCommit; - } - - public MigrateBrickTask(ClusterService clusterService, String clusterName, String volumeName, String fromBrick, - String toBrick) { - super(clusterService, clusterName, TASK_TYPE.BRICK_MIGRATE, volumeName + "#" + fromBrick + "#" + toBrick, - "Brick Migration on volume [" + volumeName + "] from [" + fromBrick + "] to [" + toBrick + "]", true, - true, true); - setFromBrick(fromBrick); - setToBrick(toBrick); - taskInfo.setName(getId()); - init(); - } - - private void init() { - ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); - glusterInterface = ctx.getBean(GlusterInterfaceService.class); - serverUtil = ctx.getBean(ServerUtil.class); - } - - @Override - public String getId() { - return new String(Base64.encode(clusterName + "-" + taskInfo.getType() + "-" + taskInfo.getReference() + "-" + fromBrick + "-" - + toBrick)); - } - - @Override - public void start() { - try { - startMigration(getOnlineServer().getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone Offline. try with a new one. - startMigration(getNewOnlineServer().getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void startMigration(String onlineServerName) { - String volumeName = getTaskInfo().getReference().split("#")[0]; - glusterInterface.startBrickMigration(onlineServerName, volumeName, getFromBrick(), getToBrick()); - getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, "Brick Migration Started."))); - } - - @Override - public void pause() { - try { - pauseMigration(getOnlineServer().getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. try with a new one. - pauseMigration(getNewOnlineServer().getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void pauseMigration(String onlineServer) { - String volumeName = getTaskInfo().getReference().split("#")[0]; - glusterInterface.pauseBrickMigration(onlineServer, volumeName, getFromBrick(), getToBrick()); - TaskStatus taskStatus = new TaskStatus(); - taskStatus.setCode(Status.STATUS_CODE_PAUSE); - taskStatus.setMessage("Brick Migration Paused"); - getTaskInfo().setStatus(taskStatus); - } - - @Override - public void resume() { - start(); - } - - @Override - public void commit() { - try { - commitMigration(getOnlineServer().getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. try with a new one. - commitMigration(getNewOnlineServer().getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void commitMigration(String serverName) { - String volumeName = getTaskInfo().getReference().split("#")[0]; - glusterInterface.commitBrickMigration(serverName, volumeName, getFromBrick(), getToBrick()); - TaskStatus taskStatus = new TaskStatus(); - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - taskStatus.setMessage("Brick Migration Committed."); - getTaskInfo().setStatus(taskStatus); - } - - @Override - public void stop() { - try { - stopMigration(getOnlineServer().getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. try with a new one. - stopMigration(getNewOnlineServer().getName()); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void stopMigration(String serverName) { - String volumeName = getTaskInfo().getReference().split("#")[0]; - glusterInterface.stopBrickMigration(serverName, volumeName, getFromBrick(), getToBrick()); - TaskStatus taskStatus = new TaskStatus(); - taskStatus.setCode(Status.STATUS_CODE_SUCCESS); - taskStatus.setMessage("Brick Migration Stopped"); - getTaskInfo().setStatus(taskStatus); - } - - @Override - public TaskStatus checkStatus() { - try { - return checkMigrationStatus(getOnlineServer().getName()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. try with a new one. - return checkMigrationStatus(getNewOnlineServer().getName()); - } - } - return null; - } - - private TaskStatus checkMigrationStatus(String serverName) { - // For committed task, status command (CLI) is invalid, just return current status - if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { - return taskInfo.getStatus(); - } - - String volumeName = getTaskInfo().getReference().split("#")[0]; - TaskStatus taskStatus = glusterInterface.checkBrickMigrationStatus(serverName, volumeName, getFromBrick(), - getToBrick()); - if (autoCommit && taskStatus.isCommitPending()) { - commitMigration(serverName); - return taskInfo.getStatus(); // return the committed status - } - - taskInfo.setStatus(taskStatus); // Update the task status - return taskStatus; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java deleted file mode 100644 index 410260ca..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * RebalanceVolumeTask.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.tasks; - -import org.springframework.context.ApplicationContext; -import org.springframework.web.context.ContextLoader; - -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.services.GlusterInterfaceService; -import com.gluster.storage.management.gateway.utils.ServerUtil; -import com.sun.jersey.core.util.Base64; - -public class RebalanceVolumeTask extends Task { - - private String layout; - private String serverName; - private ServerUtil serverUtil; - private GlusterInterfaceService glusterUtil; - - public RebalanceVolumeTask(ClusterService clusterService, String clusterName, String volumeName, String layout) { - super(clusterService, clusterName, TASK_TYPE.VOLUME_REBALANCE, volumeName, "Volume " + volumeName - + " Rebalance", false, true, false); - setLayout(layout); - taskInfo.setName(getId()); - init(); - } - - private void init() { - ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); - serverUtil = ctx.getBean(ServerUtil.class); - glusterUtil = ctx.getBean(GlusterInterfaceService.class); - } - - @Override - public String getId() { - return new String(Base64.encode(getClusterName() + "-" + taskInfo.getType() + "-" + taskInfo.getReference())); - } - - @Override - public void start() { - try { - serverName = getOnlineServer().getName(); - startRebalance(serverName); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. try with a new one - serverName = getNewOnlineServer().getName(); - startRebalance(serverName); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - private void startRebalance(String serverName) { - String command = "gluster volume rebalance " + getTaskInfo().getReference() + " " + getLayout() + " start"; - String output = serverUtil.executeOnServer(serverName, command); - getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, output))); - } - - @Override - public void resume() { - getTaskInfo().setStatus( - new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, - "Pause/Resume is not supported in Volume Rebalance"))); - } - - @Override - public void stop() { - try { - glusterUtil.stopRebalance(serverName, getTaskInfo().getReference()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. update the failure status - getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); - } else { - throw new GlusterRuntimeException(e.getMessage()); - } - } - } - - @Override - public void pause() { - getTaskInfo().setStatus( - new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, - "Pause/Resume is not supported in Volume Rebalance"))); - } - - @Override - public TaskStatus checkStatus() { - try { - return glusterUtil.checkRebalanceStatus(serverName, getTaskInfo().getReference()); - } catch (Exception e) { - // check if online server has gone offline. If yes, try again one more time. - if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { - // online server might have gone offline. update the failure status - getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); - return getTaskInfo().getStatus(); - } - } - return null; - } - - public void setLayout(String layout) { - this.layout = layout; - } - - public String getLayout() { - return layout; - } - - @Override - public void commit() { - // TODO Auto-generated method stub - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/ServerSyncTask.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/ServerSyncTask.java deleted file mode 100644 index 8d788925..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/ServerSyncTask.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * ServerDiscoveryTask.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.tasks; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.constants.GlusterConstants; -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.utils.GlusterCoreUtil; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.gateway.data.ClusterInfo; -import com.gluster.storage.management.gateway.data.PersistenceDao; -import com.gluster.storage.management.gateway.data.ServerInfo; -import com.gluster.storage.management.gateway.services.ClusterService; -import com.gluster.storage.management.gateway.services.DiscoveredServerService; -import com.gluster.storage.management.gateway.services.GlusterServerService; -import com.gluster.storage.management.gateway.utils.ServerUtil; - -/** - * Task for syncing server details. This performs two things:
    - * 1. Auto-discovery of servers eligible to be added to the Gluster cluster.
    - * 2. Syncing of cluster-server mapping with actual servers of the cluster. This mapping can go out of sync if user - * adds/removes servers manually using the CLI. - */ -@Component -public class ServerSyncTask { - private static final String SCRIPT_NAME_SFX = "-discover-servers.py"; - - @Autowired - private ServerUtil serverUtil; - - @Autowired - private DiscoveredServerService discoveredServersService; - - @Autowired - private GlusterServerService glusterServerService; - - @Autowired - private String discoveryMechanism; - - @Autowired - private ClusterService clusterService; - - @Autowired - private PersistenceDao clusterDao; - - private static final Logger logger = Logger.getLogger(ServerSyncTask.class); - - public void perform() { - discoverServers(); - syncClusterServerMapping(); - } - - private void syncClusterServerMapping() { - List clusters = clusterService.getAllClusters(); - for(ClusterInfo cluster : clusters) { - try { - List servers = cluster.getServers(); - if(servers.isEmpty()) { - logger.info("Cluster [" + cluster.getName() + "] is empty, nothing to sync!"); - continue; - } - List actualServers = glusterServerService.getGlusterServers(cluster.getName(), false, - null, null); - updateRemovedServers(cluster, servers, actualServers); - updateAddedServers(cluster, servers, actualServers); - } catch(Exception e) { - // log error and continue with next cluster - logger.error("Couldn't sync cluster-server mapping for cluster [" + cluster.getName() + "]!", e); - continue; - } - } - } - - private void updateAddedServers(ClusterInfo cluster, List servers, List actualServers) { - List addedServers = findAddedServers(cluster.getName(), servers, actualServers); - for(String addedServer : addedServers) { - clusterService.mapServerToCluster(cluster.getName(), addedServer); - } - } - - private void updateRemovedServers(ClusterInfo cluster, List servers, List actualServers) { - List removedServers = findRemovedServers(servers, actualServers); - for(String removedServer : removedServers) { - clusterService.unmapServerFromCluster(cluster.getName(), removedServer); - } - } - - private List findRemovedServers(List servers, List actualServers) { - List removedServers = new ArrayList(); - - for(ServerInfo server : servers) { - if (!GlusterCoreUtil.containsEntityWithName(actualServers, server.getName(), true)) { - removedServers.add(server.getName()); - } - } - return removedServers; - } - - private List findAddedServers(String clusterName, List servers, List actualServers) { - List addedServers = new ArrayList(); - for(GlusterServer actualServer : actualServers) { - if(!serverExists(servers, actualServer.getName())) { - addedServers.add(actualServer.getName()); - } - } - return addedServers; - } - - private boolean serverExists(List servers, String name) { - for(ServerInfo server : servers) { - if(server.getName().equalsIgnoreCase(name)) { - return true; - } - } - return false; - } - - @SuppressWarnings("unchecked") - private void discoverServers() { - if(discoveryMechanism.equals(GlusterConstants.NONE)) { - return; - } - - List serverNameList = new ArrayList(); - - ProcessResult result = serverUtil.executeGlusterScript(true, discoveryMechanism + SCRIPT_NAME_SFX, new ArrayList()); - if(result.isSuccess()) { - List existingServers = clusterDao.findBySQL("select name from server_info"); - String serverNames = result.getOutput(); - String[] parts = serverNames.split(CoreConstants.NEWLINE); - for(String serverName : parts) { - // The server discovery mechanism will return every server that has not been "peer probed". However we - // need to filter out those servers that are the "first" server of a new cluster, and hence are still - // not peer probed. - if(!existingServers.contains(serverName)) { - serverNameList.add(serverName); - } - } - } - - discoveredServersService.setDiscoveredServerNames(serverNameList); - } -} \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/Task.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/Task.java deleted file mode 100644 index 1ba360bc..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/tasks/Task.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Task.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.tasks; - -import com.gluster.storage.management.core.model.GlusterServer; -import com.gluster.storage.management.core.model.TaskInfo; -import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; -import com.gluster.storage.management.core.model.TaskStatus; -import com.gluster.storage.management.gateway.services.ClusterService; - -public abstract class Task { - public String[] TASK_TYPE_STR = { "Format Disk", "Migrate Brick", "Volume Rebalance" }; - - protected TaskInfo taskInfo; - protected String clusterName; - private ClusterService clusterService; - - public Task(ClusterService clusterService, String clusterName, TASK_TYPE type, String reference, String desc, - boolean canPause, boolean canStop, boolean canCommit) { - TaskInfo taskInfo = new TaskInfo(); - taskInfo.setType(type); - taskInfo.setReference(reference); - taskInfo.setDescription(desc); - taskInfo.setPauseSupported(canPause); - taskInfo.setStopSupported(canStop); - taskInfo.setCommitSupported(canCommit); - - init(clusterService, clusterName, taskInfo); - - } - - public Task(ClusterService clusterService, String clusterName, TaskInfo taskInfo) { - init(clusterService, clusterName, taskInfo); - } - - private void init(ClusterService clusterService, String clusterName, TaskInfo taskInfo) { - this.clusterService = clusterService; - setClusterName(clusterName); - setTaskInfo(taskInfo); - } - - protected GlusterServer getOnlineServer() { - return clusterService.getOnlineServer(clusterName); - } - - protected GlusterServer getNewOnlineServer() { - return clusterService.getNewOnlineServer(clusterName); - } - - protected GlusterServer getNewOnlineServer(String exceptServerName) { - return clusterService.getNewOnlineServer(clusterName, exceptServerName); - } - - public String getTypeStr() { - return TASK_TYPE_STR[taskInfo.getType().ordinal()]; - } - - public TASK_TYPE getType() { - return getTaskInfo().getType(); - } - - public String getClusterName() { - return clusterName; - } - - public void setClusterName(String clusterName) { - this.clusterName = clusterName; - } - - public TaskInfo getTaskInfo() { - return taskInfo; - } - - public void setTaskInfo(TaskInfo info) { - this.taskInfo = info; - } - - public abstract String getId(); - - public abstract void start(); - - public abstract void resume(); - - public abstract void stop(); - - public abstract void pause(); - - public abstract void commit(); - - /** - * This method should check current status of the task and update it's taskInfo accordingly - */ - public abstract TaskStatus checkStatus(); -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/AbstractStatsFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/AbstractStatsFactory.java deleted file mode 100644 index 7f3045ba..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/AbstractStatsFactory.java +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.ServerStatsRow; - -/** - * - */ -@Component -public abstract class AbstractStatsFactory implements StatsFactory { - @Autowired - protected ServerUtil serverUtil; - - private Logger logger = Logger.getLogger(AbstractStatsFactory.class); - - protected ServerStats getFirstOnlineServerStats(List serverNames, String period, - boolean removeServerOnError, boolean removeOnlineServer) { - for(int i = serverNames.size() - 1; i >= 0; i--) { - String serverName = serverNames.get(i); - try { - ServerStats stats = fetchStats(serverName, period); - if(removeOnlineServer) { - serverNames.remove(serverName); - } - return stats; - } catch(Exception e) { - // server might be offline - continue with next one - logger.warn("Couldn't fetch stats from server [" + serverName + "]!", e); - if(removeServerOnError) { - serverNames.remove(serverName); - } - continue; - } - } - throw new GlusterRuntimeException("All servers offline!"); - } - - protected void aggregateStats(List serverNames, ServerStats aggregatedStats, String period) { - if(serverNames.isEmpty()) { - return; - } - - int rowCount = aggregatedStats.getMetadata().getRowCount(); - int columnCount = aggregatedStats.getMetadata().getLegend().size(); - int[][] dataCount = initDataCountArray(rowCount, columnCount); - - List allStats = serverUtil.executeScriptOnServers(serverNames, getStatsScriptName() + " " + period, ServerStats.class, false); - - for (ServerStats stats : allStats) { - // add to aggregated stats - addServerStats(stats, aggregatedStats, dataCount); - } - - averageAggregatedStats(aggregatedStats, dataCount); - } - - /** - * - * @param statsToBeAdded - * @param targetStats - * @param dataCount Each element of this matrix will be incremented for every valid element added - * @return - */ - protected List addServerStats(ServerStats statsToBeAdded, ServerStats targetStats, int[][] dataCount) { - List serverStatsRows = statsToBeAdded.getRows(); - for (int rowNum = 0; rowNum < serverStatsRows.size() && rowNum < targetStats.getMetadata().getRowCount() - && rowNum < dataCount.length; rowNum++) { - ServerStatsRow row = serverStatsRows.get(rowNum); - List rowData = row.getUsageData(); - - List aggregatedStatsRowData = targetStats.getRows().get(rowNum).getUsageData(); - for(int i = 1; i < targetStats.getMetadata().getLegend().size(); i++) { - // Add the data - Double data = rowData.get(i); - if(!data.isNaN()) { - // data is available. add it. - Double oldData = aggregatedStatsRowData.get(i); - if(oldData.isNaN()) { - oldData = 0d; - } - aggregatedStatsRowData.set(i, oldData + data); - // increment record count. this will be used for calculating average of aggregated data. - dataCount[rowNum][i]++; - } - } - } - return serverStatsRows; - } - - protected void averageAggregatedStats(ServerStats aggregatedStats, int[][] dataCount) { - List rows = aggregatedStats.getRows(); - for(int rowNum = 0; rowNum < rows.size() && rowNum < dataCount.length; rowNum++) { - List data = rows.get(rowNum).getUsageData(); - for(int columnNum = 0; columnNum < data.size(); columnNum++) { - data.set(columnNum, data.get(columnNum) / dataCount[rowNum][columnNum]); - } - } - } - - protected int[][] initDataCountArray(int rowCount, int columnCount) { - int[][] dataCount = new int[rowCount][columnCount]; - // initialize all data counts to 1 - for(int rowNum = 0; rowNum < rowCount; rowNum++) { - for(int columnNum = 0; columnNum < columnCount; columnNum++) { - dataCount[rowNum][columnNum] = 1; - } - } - return dataCount; - } - - @Override - public ServerStats fetchAggregatedStats(List serverNames, String period) { - if(serverNames == null || serverNames.size() == 0) { - throw new GlusterRuntimeException("No server names passed to fetchAggregaredStats!"); - } - - ServerStats firstServerStats = getFirstOnlineServerStats(serverNames, period, true, true); - - ServerStats aggregatedStats = new ServerStats(firstServerStats); - aggregateStats(serverNames, aggregatedStats, period); - return aggregatedStats; - } - - @Override - public ServerStats fetchStats(String serverName, String period, String...args) { - String argsStr = ""; - for (String arg : args) { - if(arg != null) { - argsStr += " " + arg; - } - } - return serverUtil.executeScriptOnServer(serverName, getStatsScriptName() + argsStr + " " + period, - ServerStats.class); - } - - public abstract String getStatsScriptName(); -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/CpuStatsFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/CpuStatsFactory.java deleted file mode 100644 index b6ef9ef2..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/CpuStatsFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import org.springframework.stereotype.Component; - -/** - * - */ -@Component -public class CpuStatsFactory extends AbstractStatsFactory { - - private static final String CPU_STATS_SCRIPT = "get_rrd_cpu_details.py"; - - @Override - public String getStatsScriptName() { - return CPU_STATS_SCRIPT; - } - -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java deleted file mode 100644 index ca4821d1..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/DBUtil.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import java.sql.DriverManager; -import java.sql.SQLException; - -import org.apache.log4j.Logger; - -import com.gluster.storage.management.core.constants.CoreConstants; - -/** - * - */ -public class DBUtil { - private static final Logger logger = Logger.getLogger(DBUtil.class); - public static void shutdownDerby() { - try { - // the shutdown=true attribute shuts down Derby - DriverManager.getConnection("jdbc:derby:;shutdown=true"); - - // To shut down a specific database only, but keep the - // engine running (for example for connecting to other - // databases), specify a database in the connection URL: - //DriverManager.getConnection("jdbc:derby:" + dbName + ";shutdown=true"); - } catch (Exception e) { - if(e instanceof SQLException) { - SQLException se = (SQLException) e; - if (((se.getErrorCode() == 50000) && ("XJ015".equals(se.getSQLState())))) { - // we got the expected exception - logger.info("Derby shut down normally"); - // Note that for single database shutdown, the expected - // SQL state is "08006", and the error code is 45000. - } else { - // if the error code or SQLState is different, we have - // an unexpected exception (shutdown failed) - logger.error("Derby did not shut down normally!" + inspectSQLException(se), se); - } - } else { - logger.error("Derby did not shut down normally! [" + e.getMessage() + "]", e); - } - } - // force garbage collection to unload the EmbeddedDriver - // so Derby can be restarted - System.gc(); - } - - /** - * Extracts details of an SQLException chain to String. - * Details included are SQL State, Error code, Exception message. - * - * @param e the SQLException from which to print details. - */ - private static String inspectSQLException(SQLException e) - { - // Unwraps the entire exception chain to unveil the real cause of the - // Exception. - String errMsg = ""; - while (e != null) - { - errMsg += "\n----- SQLException -----" + CoreConstants.NEWLINE + " SQL State: " + e.getSQLState() - + CoreConstants.NEWLINE + " Error Code: " + e.getErrorCode() + CoreConstants.NEWLINE - + " Message: " + e.getMessage(); - e = e.getNextException(); - } - return errMsg; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/MemoryStatsFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/MemoryStatsFactory.java deleted file mode 100644 index dc88bf52..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/MemoryStatsFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import java.util.List; - -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.ServerStatsRow; - -/** - * - */ -@Component -public class MemoryStatsFactory extends AbstractStatsFactory { - - private static final String MEM_STATS_SCRIPT = "get_rrd_memory_details.py"; - - @Override - public String getStatsScriptName() { - return MEM_STATS_SCRIPT; - } - - @Override - public ServerStats fetchStats(String serverName, String period, String... args) { - ServerStats stats = super.fetchStats(serverName, period, args); - - // stats returned by rrd script contains five columns - user, free, cache, buffer, total - // out of this, the "user" memory includes cached and buffer. We remove them to get the - // actual memory used by "user" - for(ServerStatsRow row : stats.getRows()) { - List data = row.getUsageData(); - Double user = data.get(0); - Double free = data.get(1); - Double cache = data.get(2); - Double buffer = data.get(3); - Double total = data.get(4); - - Double actualUser = user - cache - buffer; - - // convert all figures from bytes to percentages - data.set(0, (actualUser * 100) / total); - data.set(1, (free * 100) / total); - data.set(2, (cache * 100) / total); - data.set(3, (buffer * 100) / total); - data.set(4, (total * 100) / total); - } - - return stats; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java deleted file mode 100644 index fdc4b1d2..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/NetworkStatsFactory.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.NetworkInterface; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.ServerStats; -import com.gluster.storage.management.core.model.ServerStatsRow; -import com.gluster.storage.management.core.utils.ProcessUtil; - -/** - * - */ -@Component -public class NetworkStatsFactory extends AbstractStatsFactory { - private static final Logger logger = Logger.getLogger(NetworkStatsFactory.class); - private static final String NETWORK_STATS_SCRIPT = "get_rrd_net_details.py"; - private int[][] dataCount; - - @Override - public String getStatsScriptName() { - return NETWORK_STATS_SCRIPT; - } - - @Override - protected ServerStats getFirstOnlineServerStats(List serverNames, String period, - boolean removeServerOnError, boolean removeOnlineServer) { - ServerStats firstOnlineServerStats = null; - for(int i = serverNames.size() - 1; i >= 0; i--) { - String serverName = serverNames.get(i); - Server server = new Server(serverName); - serverUtil.fetchServerDetails(server); - if(!server.isOnline()) { - if(removeServerOnError) { - // server is offline. no point in trying to fetch it's details. - serverNames.remove(serverName); - } - continue; - } - try { - for(NetworkInterface networkInterface : server.getNetworkInterfaces()) { - ServerStats stats = fetchStats(serverName, period, networkInterface.getName()); - if(firstOnlineServerStats == null) { - firstOnlineServerStats = stats; - int rowCount = firstOnlineServerStats.getMetadata().getRowCount(); - int columnCount = firstOnlineServerStats.getMetadata().getLegend().size(); - dataCount = initDataCountArray(rowCount, columnCount); - } else { - addServerStats(stats, firstOnlineServerStats, dataCount); - } - } - - if(removeOnlineServer) { - serverNames.remove(serverName); - } - return firstOnlineServerStats; - } catch(Exception e) { - // server might be offline - continue with next one - logger.warn("Couldn't fetch stats from server [" + serverName + "]!", e); - if(removeServerOnError) { - serverNames.remove(serverName); - } - continue; - } - } - throw new GlusterRuntimeException("All servers offline!"); - } - - protected void aggregateStats(List serverNames, ServerStats aggregatedStats, String period) { - if(serverNames.isEmpty()) { - return; - } - - List statsList = Collections.synchronizedList(new ArrayList()); - try { - List threads = createThreads(serverNames, period, statsList); - ProcessUtil.waitForThreads(threads); - for(ServerStats stats : statsList) { - addServerStats(stats, aggregatedStats, dataCount); - } - } catch (InterruptedException e) { - String errMsg = "Exception while aggregating network statistics on servers [" + serverNames - + "] for period [" + period + "]! Error: [" + e.getMessage() + "]"; - logger.error(errMsg, e); - throw new GlusterRuntimeException(errMsg, e); - } - - averageAggregatedStats(aggregatedStats, dataCount); - } - - private List createThreads(List serverNames, String period, List statsList) - throws InterruptedException { - List threads = new ArrayList(); - for (int i = serverNames.size()-1; i >= 0 ; i--) { - Thread thread = new NetworkStatsThread(serverNames.get(i), period, statsList); - threads.add(thread); - thread.start(); - if(i >= 5 && i % 5 == 0) { - // After every 5 servers, wait for 1 second so that we don't end up with too many running threads - Thread.sleep(1000); - } - } - return threads; - } - - public class NetworkStatsThread extends Thread { - private String serverName; - private String period; - private List statsList; - - public NetworkStatsThread(String serverName, String period, List statsList) { - this.serverName = serverName; - this.period = period; - this.statsList = statsList; - } - - @Override - public void run() { - try { - Server server = new Server(serverName); - serverUtil.fetchServerDetails(server); - - for (NetworkInterface networkInterface : server.getNetworkInterfaces()) { - // fetch the stats and add to aggregated stats - statsList.add(fetchStats(serverName, period, networkInterface.getName())); - } - } catch(Exception e) { - // server might be offline - continue with next one - logger.warn("Couldn't fetch Network stats from server [" + serverName + "]!", e); - } - } - } - - @Override - public ServerStats fetchStats(String serverName, String period, String... args) { - ServerStats stats = super.fetchStats(serverName, period, args); - - // the data returned by rrd contains "bytes/sec". Update the stats object to represent KiB/s - for(ServerStatsRow row : stats.getRows()) { - List data = row.getUsageData(); - for (int i = 0; i < data.size(); i++) { - Double val = data.get(i); - data.set(i, val / 1024); - } - } - - return stats; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java deleted file mode 100644 index 6af08049..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/PasswordManager.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import org.apache.derby.jdbc.EmbeddedDriver; -import org.springframework.jdbc.datasource.SimpleDriverDataSource; -import org.springframework.security.authentication.dao.ReflectionSaltSource; -import org.springframework.security.authentication.encoding.ShaPasswordEncoder; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.gateway.security.UserAuthDao; - -/** - * Tool to reset password of default user gluster - */ -public class PasswordManager { - private static final int USAGE_ERR = 1; - private static final int SQL_ERR = 2; - - private void resetPassword(String username) { - try { - UserAuthDao userAuthDao = createUserAuthDao(); - ReflectionSaltSource saltSource = createSaltSource(); - - String encodedPassword = new ShaPasswordEncoder(256).encodePassword(CoreConstants.DEFAULT_PASSWORD, - saltSource.getSalt(userAuthDao.loadUserByUsername(username))); - - userAuthDao.changePassword(username, encodedPassword); - - System.out.println("Password for user [" + username + "] reset successsfully to default value of [" - + CoreConstants.DEFAULT_PASSWORD + "]." + CoreConstants.NEWLINE); - - DBUtil.shutdownDerby(); - } catch (Exception e) { - System.err.println(CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Password reset for user [" + username - + "] failed! " + CoreConstants.NEWLINE - + "Make sure that the Management Gateway is not running while performing password reset." - + CoreConstants.NEWLINE); - System.exit(SQL_ERR); - } - } - - private ReflectionSaltSource createSaltSource() { - ReflectionSaltSource saltSource = new ReflectionSaltSource(); - saltSource.setUserPropertyToUse("username"); - return saltSource; - } - - private UserAuthDao createUserAuthDao() throws InstantiationException, IllegalAccessException, - ClassNotFoundException { - UserAuthDao authDao = new UserAuthDao(); - EmbeddedDriver driver = (EmbeddedDriver) Class.forName(EmbeddedDriver.class.getName()).newInstance(); - SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driver, "jdbc:derby:/opt/glustermg/data", "gluster", "syst3m"); - - authDao.setDataSource(dataSource); - return authDao; - } - - public static void main(String args[]) { - if (args.length != 2 || !args[0].equals("reset")) { - System.err.println("Usage: java " + PasswordManager.class.getName() + " reset \n"); - System.exit(USAGE_ERR); - } - - new PasswordManager().resetPassword(args[1]); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java deleted file mode 100644 index 63f2bbf4..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/ServerUtil.java +++ /dev/null @@ -1,370 +0,0 @@ -/** - * ServerUtil.java - * - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - */ -package com.gluster.storage.management.gateway.utils; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.servlet.ServletContext; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; -import org.springframework.web.context.ContextLoader; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.model.Server; -import com.gluster.storage.management.core.model.Server.SERVER_STATUS; -import com.gluster.storage.management.core.model.Status; -import com.gluster.storage.management.core.response.StringListResponse; -import com.gluster.storage.management.core.utils.ProcessResult; -import com.gluster.storage.management.core.utils.ProcessUtil; -import com.gluster.storage.management.gateway.services.GlusterInterfaceService; - -@Component -public class ServerUtil { - @Autowired - ServletContext servletContext; - - @Autowired - private SshUtil sshUtil; - - @Autowired - private String appVersion; - - private static final Logger logger = Logger.getLogger(ServerUtil.class); - - private static final String SCRIPT_DIR = "scripts"; - private static final String SCRIPT_COMMAND = "python"; - private static final String REMOTE_SCRIPT_GET_DISK_FOR_DIR = "get_disk_for_dir.py"; - private static final String REMOTE_SCRIPT_GET_SERVER_DETAILS = "get_server_details.py"; - private static final String REMOTE_SCRIPT_GET_FILE_SYSTEM_TYPE = "get_filesystem_type.py"; - private static final String REMOTE_SCRIPT_BASE_DIR = "/opt/glustermg"; - private static final String REMOTE_SCRIPT_DIR_NAME = "backend"; - - public void setSshUtil(SshUtil sshUtil) { - this.sshUtil = sshUtil; - } - - public ProcessResult executeGlusterScript(boolean runInForeground, String scriptName, String...arguments) { - return executeGlusterScript(runInForeground, scriptName, Arrays.asList(arguments)); - } - - public ProcessResult executeGlusterScript(boolean runInForeground, String scriptName, List arguments) { - List command = new ArrayList(); - - command.add(SCRIPT_COMMAND); - command.add(getScriptPath(scriptName)); - command.addAll(arguments); - return ProcessUtil.executeCommand(runInForeground, command); - } - - private String getScriptPath(String scriptName) { - return servletContext.getRealPath(SCRIPT_DIR) + CoreConstants.FILE_SEPARATOR + scriptName; - } - - private String getRemoteScriptDir() { - return REMOTE_SCRIPT_BASE_DIR + File.separator + appVersion + File.separator + REMOTE_SCRIPT_DIR_NAME; - } - - /** - * Fetch details of the given server. The server name must be populated in the object before calling this method. - * - * @param server - * Server whose details are to be fetched - */ - public void fetchServerDetails(Server server) { - try { - Server serverDetails = fetchServerDetails(server.getName()); - server.copyFrom(serverDetails); // Update the details in object - server.setDisks(serverDetails.getDisks()); - } catch (ConnectionException e) { - logger.warn("Couldn't connect to server [" + server.getName() + "]. Marking it offline!", e); - server.setStatus(SERVER_STATUS.OFFLINE); - } - } - - public boolean isServerOnline(Server server) { - // fetch latest details and check if server is still online - fetchServerDetails(server); - return server.isOnline(); - } - - public String fetchHostName(String serverName) { - Object response = fetchServerDetails(serverName); - return ((Server) response).getName(); - } - - private Server fetchServerDetails(String serverName) { - // fetch standard server details like cpu, disk, memory details - return executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_SERVER_DETAILS, Server.class); - } - - /** - * Executes given script on all given servers in parallel, collects the output in objects of given class, and - * returns a list of all returned objects. - * - * @param serverNames - * @param scriptWithArgs - * @param expectedClass - * @param failOnError - * If true, an exception will be thrown as soon as the script execution fails on any of the servers. If - * false, the exception will be caught and logged. Execution on all other servers will continue. - * @return - */ - public List executeScriptOnServers(List serverNames, String scriptWithArgs, - Class expectedClass, boolean failOnError) { - List result = Collections.synchronizedList(new ArrayList()); - try { - List threads = createScriptExecutionThreads(serverNames, getRemoteScriptDir() + File.separator - + scriptWithArgs, expectedClass, result, failOnError); - ProcessUtil.waitForThreads(threads); - return result; - } catch (InterruptedException e) { - String errMsg = "Exception while executing script [" + scriptWithArgs + "] on servers [" + serverNames + "]! Error: [" + e.getMessage() + "]"; - logger.error(errMsg, e); - throw new GlusterRuntimeException(errMsg, e); - } - } - - /** - * Creates threads that will run in parallel and execute the given command on each of the given servers - * - * @param serverNames - * @param commandWithArgs - * @param expectedClass - * @param result - * @param failOnError - * If true, an exception will be thrown as soon as the script execution fails on any of the servers. If - * false, the exception will be caught and logged. Execution on all other servers will continue. - * @return - * @throws InterruptedException - */ - private List createScriptExecutionThreads(List serverNames, String commandWithArgs, Class expectedClass, List result, - boolean failOnError) - throws InterruptedException { - List threads = new ArrayList(); - for (int i = serverNames.size()-1; i >= 0 ; i--) { - Thread thread = new RemoteExecutionThread(serverNames.get(i), commandWithArgs, expectedClass, result, failOnError); - threads.add(thread); - thread.start(); - if(i >= 5 && i % 5 == 0) { - // After every 5 servers, wait for 1 second so that we don't end up with too many running threads - Thread.sleep(1000); - } - } - return threads; - } - - - public class RemoteExecutionThread extends Thread { - private String serverName; - private String commandWithArgs; - private List result; - private Class expectedClass; - private boolean failOnError = false; - - public RemoteExecutionThread(String serverName, String commandWithArgs, Class expectedClass, List result, - boolean failOnError) { - this.serverName = serverName; - this.commandWithArgs = commandWithArgs; - this.result = result; - this.expectedClass = expectedClass; - this.failOnError = failOnError; - } - - @Override - public void run() { - try { - result.add(executeOnServer(serverName, commandWithArgs, expectedClass)); - } catch(Exception e) { - String errMsg = "Couldn't execute command [" + commandWithArgs + "] on [" + serverName + "]!"; - logger.error(errMsg, e); - if(failOnError) { - throw new GlusterRuntimeException(errMsg, e); - } - } - } - } - - - /** - * Executes given script on given server. Since the remote server may contain multiple versions of backend, this - * method will invoke the script present in directory of same version as the gateway. - * - * @param serverName - * @param scriptWithArgs - * The script name followed by arguments to be passed. Note that the script name should not contain path - * as it will be automatically identified by the method. - * @param expectedClass - * Class of the object expected from script execution - * @return Output (console/error) from the script execution - * @throws GlusterRuntimeException in case the remote execution fails. - */ - public String executeScriptOnServer(String serverName, String scriptWithArgs) { - return executeOnServer(serverName, getRemoteScriptDir() + File.separator + scriptWithArgs, String.class); - } - - /** - * Executes given script on given server. Since the remote server may contain multiple versions of backend, this - * method will invoke the script present in directory of same version as the gateway. - * - * @param serverName - * @param scriptWithArgs - * The script name followed by arguments to be passed. Note that the script name should not contain path - * as it will be automatically identified by the method. - * @param expectedClass - * Class of the object expected from script execution - * @return Object of the expected class from remote execution of the command. - * @throws GlusterRuntimeException in case the remote execution fails. - */ - public T executeScriptOnServer(String serverName, String scriptWithArgs, - Class expectedClass) { - return executeOnServer(serverName, getRemoteScriptDir() + File.separator + scriptWithArgs, - expectedClass); - } - - /** - * Executes given command on given server - * - * @param serverName - * @param commandWithArgs - * @param expectedClass - * Class of the object expected from script execution - * @return Object of the expected class from remote execution of the command. In case the remote execution fails - * ungracefully, an object of class {@link Status} will be returned. - */ - @SuppressWarnings("unchecked") - public T executeOnServer(String serverName, String commandWithArgs, - Class expectedClass) { - String output = executeOnServer(serverName, commandWithArgs); - if (expectedClass == String.class) { - return (T) output; - } - - return unmarshal(expectedClass, output); - } - - public String executeOnServer(String serverName, String commandWithArgs) { - ProcessResult result = sshUtil.executeRemote(serverName, commandWithArgs); - - if (!result.isSuccess()) { - throw new GlusterRuntimeException("Command [" + commandWithArgs + "] failed on [" + serverName - + "] with error [" + result.getExitValue() + "][" + result.getOutput() + "]"); - } - return result.getOutput(); - } - - // This is the old executeOnServer that used socket communication. - // We can keep it commented for the time being. - // private String executeOnServerUsingSocket(String serverName, String commandWithArgs) { - // try { - // InetAddress address = InetAddress.getByName(serverName); - // Socket connection = new Socket(address, 50000); - // - // PrintWriter writer = new PrintWriter(connection.getOutputStream(), true); - // writer.println(commandWithArgs); - // writer.println(); // empty line means end of request - // - // InputStream inputStream = connection.getInputStream(); - // int available = inputStream.available(); - // - // StringBuffer output = new StringBuffer(); - // if( available > 0 ) { - // // This happens when PeerAgent sends complete file - // byte[] responseData = new byte[available]; - // inputStream.read(responseData); - // output.append(new String(responseData, "UTF-8")); - // } else { - // // This happens in case of normal XML response from PeerAgent - // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); - // - // String line; - // while (!(line = reader.readLine()).trim().isEmpty()) { - // output.append(line + CoreConstants.NEWLINE); - // } - // } - // connection.close(); - // - // return output.toString(); - // } catch (Exception e) { - // throw new GlusterRuntimeException("Error during remote execution: [" + e.getMessage() + "]"); - // } - // } - - public void getFileFromServer(String serverName, String remoteFileName, String localDirName) { - sshUtil.getFile(serverName, remoteFileName, localDirName); - } - - /** - * Unmarshals given input string into object of given class - * - * @param expectedClass - * Class whose object is expected - * @param input - * Input string - * @return Object of given expected class - */ - public T unmarshal(Class expectedClass, String input) { - try { - // create JAXB context and instantiate marshaller - JAXBContext context = JAXBContext.newInstance(expectedClass); - Unmarshaller um = context.createUnmarshaller(); - return (T)um.unmarshal(new ByteArrayInputStream(input.getBytes())); - } catch (JAXBException e) { - String errMsg = "Error during unmarshalling string [" + input + "] for class [" + expectedClass.getName() - + ": [" + e.getMessage() + "]"; - logger.error(errMsg, e); - throw new GlusterRuntimeException(errMsg, e); - } - } - - /** - * @param serverName - * Server on which the directory is present - * @param brickDir - * Directory whose disk is to be fetched - * @return Status object containing the disk name, or error message in case the remote script fails. - */ - public Status getDiskForDir(String serverName, String brickDir) { - return executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_DISK_FOR_DIR + " " + brickDir, Status.class); - } - - public T getBean(Class clazz) { - ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); - return ctx.getBean(clazz); - } - - public List getFsTypes(String serverName) { - String output = executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_FILE_SYSTEM_TYPE); - return Arrays.asList(output.trim().split(CoreConstants.NEWLINE)); - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java deleted file mode 100644 index 706fef31..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/SshUtil.java +++ /dev/null @@ -1,463 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Arrays; - -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import ch.ethz.ssh2.ChannelCondition; -import ch.ethz.ssh2.Connection; -import ch.ethz.ssh2.SCPClient; -import ch.ethz.ssh2.Session; -import ch.ethz.ssh2.StreamGobbler; - -import com.gluster.storage.management.core.constants.CoreConstants; -import com.gluster.storage.management.core.exceptions.ConnectionException; -import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; -import com.gluster.storage.management.core.utils.FileUtil; -import com.gluster.storage.management.core.utils.LRUCache; -import com.gluster.storage.management.core.utils.ProcessResult; - -/** - * - */ -@Component -public class SshUtil { - private static final String TEMP_DIR = "/tmp/"; - public static final String SSH_AUTHORIZED_KEYS_DIR_LOCAL = "/opt/glustermg/keys/"; - public static final String SSH_AUTHORIZED_KEYS_DIR_REMOTE = "/root/.ssh/"; - private static final String SSH_AUTHORIZED_KEYS_FILE = "authorized_keys"; - private static final String SSH_AUTHORIZED_KEYS_PATH_REMOTE = SSH_AUTHORIZED_KEYS_DIR_REMOTE + SSH_AUTHORIZED_KEYS_FILE; - public static final File PRIVATE_KEY_FILE = new File(SSH_AUTHORIZED_KEYS_DIR_LOCAL + "gluster.pem"); - public static final File PUBLIC_KEY_FILE = new File(SSH_AUTHORIZED_KEYS_DIR_LOCAL + "gluster.pub"); - private LRUCache sshConnCache = new LRUCache(10); - - // TODO: Make user name configurable - private static final String USER_NAME = "root"; - // TODO: Make default password configurable - private static final String DEFAULT_PASSWORD = "syst3m"; - - private static final Logger logger = Logger.getLogger(SshUtil.class); - - @Autowired - private Integer sshConnectTimeout; - @Autowired - private Integer sshKexTimeout; - @Autowired - private Integer sshExecTimeout; - - public boolean hasDefaultPassword(String serverName) { - try { - getConnectionWithPassword(serverName).close(); - return true; - } catch(Exception e) { - logger.warn("Couldn't connect to [" + serverName + "] with default password!", e); - return false; - } - } - - /** - * Checks if public key of management gateway is configured on given server - * - * @param serverName - * @return true if public key is configured, else false - */ - public boolean isPublicKeyInstalled(String serverName) { - try { - getConnectionWithPubKey(serverName).close(); - return true; - } catch(ConnectionException e) { - logger.warn("Couldn't connect to [" + serverName + "] with public key!", e); - return false; - } - } - - public void getFile(String serverName, String remoteFile, String localDir) { - try { - Connection conn = getConnection(serverName); - SCPClient scpClient = new SCPClient(conn); - scpClient.get(remoteFile, localDir); - } catch (IOException e) { - throw new GlusterRuntimeException("Error while fetching file [" + remoteFile + "] from server [" - + serverName + "]", e); - } - } - - public synchronized void installPublicKey(String serverName) { - Connection conn = null; - try { - conn = getConnectionWithPassword(serverName); - } catch(Exception e) { - // authentication failed. close the connection. - conn.close(); - if (e instanceof GlusterRuntimeException) { - throw (GlusterRuntimeException) e; - } else { - throw new GlusterRuntimeException("Exception during authentication with public key on server [" - + serverName + "]", e); - } - } - SCPClient scpClient = new SCPClient(conn); - - // delete file if it exists - File localTempFile = new File(TEMP_DIR + SSH_AUTHORIZED_KEYS_FILE); - if(localTempFile.exists()) { - localTempFile.delete(); - } - - try { - // get authorized_keys from server - scpClient.get(SSH_AUTHORIZED_KEYS_PATH_REMOTE, TEMP_DIR); - } catch (IOException e) { - // file doesn't exist. it will get created. - // create the .ssh directory in case it doesn't exist - logger.info("Couldn't fetch file [" + SSH_AUTHORIZED_KEYS_PATH_REMOTE +"].", e); - logger.info("Creating /root/.ssh on [" + serverName + "] in case it doesn't exist."); - String command = "mkdir -p " + SSH_AUTHORIZED_KEYS_DIR_REMOTE; - ProcessResult result = executeCommand(conn, command); - if(!result.isSuccess()) { - String errMsg = "Command [" + command + "] failed on server [" + serverName + "] with error: " + result; - logger.error(errMsg); - throw new GlusterRuntimeException(errMsg); - } - } - - byte[] publicKeyData; - try { - publicKeyData = FileUtil.readFileAsByteArray(PUBLIC_KEY_FILE); - } catch (Exception e) { - conn.close(); - throw new GlusterRuntimeException("Couldn't load public key file [" + PUBLIC_KEY_FILE + "]", e); - } - - try { - // append it - FileOutputStream outputStream = new FileOutputStream(localTempFile, true); - outputStream.write(CoreConstants.NEWLINE.getBytes()); - outputStream.write(publicKeyData); - outputStream.close(); - } catch (Exception e) { - conn.close(); - throw new GlusterRuntimeException("Couldnt append file [" + localTempFile + "] with public key!", e); - } - - try { - scpClient.put(localTempFile.getAbsolutePath(), SSH_AUTHORIZED_KEYS_FILE, SSH_AUTHORIZED_KEYS_DIR_REMOTE, "0600"); - } catch (IOException e) { - throw new GlusterRuntimeException("Couldn't add public key to server [" + serverName + "]", e); - } finally { - conn.close(); - localTempFile.delete(); - } - - // It was decided NOT to disable password login as this may not be acceptable in a bare-metal environment - // disableSshPasswordLogin(serverName, scpClient); - } - -// private void disableSshPasswordLogin(String serverName, SCPClient scpClient) { -// ProcessResult result = executeRemote(serverName, SCRIPT_DISABLE_SSH_PASSWORD_AUTH); -// if(!result.isSuccess()) { -// throw new GlusterRuntimeException("Couldn't disable SSH password authentication on [" + serverName -// + "]. Error: " + result); -// } -// } - - private synchronized Connection getConnectionWithPassword(String serverName) { - Connection conn = createConnection(serverName); - if(!authenticateWithPassword(conn)) { - conn.close(); - throw new ConnectionException("SSH Authentication (password) failed for server [" - + conn.getHostname() + "]"); - } - return conn; - } - - private synchronized Connection getConnectionWithPubKey(String serverName) { - Connection conn = createConnection(serverName); - if(!authenticateWithPublicKey(conn)) { - conn.close(); - throw new ConnectionException("SSH Authentication (public key) failed for server [" - + conn.getHostname() + "]"); - } - return conn; - } - - private synchronized Connection getConnection(String serverName) { - Connection conn = sshConnCache.get(serverName); - if (conn != null) { - return conn; - } - - conn = createConnection(serverName); - try { - if(!authenticateWithPublicKey(conn)) { - if(!authenticateWithPassword(conn)) { - conn.close(); - throw new ConnectionException("SSH authentication failed on server [" + serverName + "]!"); - } - } - } catch(Exception e) { - // authentication failed. close the connection. - conn.close(); - if(e instanceof GlusterRuntimeException) { - throw (GlusterRuntimeException)e; - } else { - throw new GlusterRuntimeException("Exception during authentication on server [" + serverName + "]", e); - } - } - - sshConnCache.put(serverName, conn); - return conn; - } - - private boolean authenticateWithPublicKey(Connection conn) { - try { - if (!supportsPublicKeyAuthentication(conn)) { - throw new ConnectionException("Public key authentication not supported on [" + conn.getHostname() - + "]"); - } - - if (!conn.authenticateWithPublicKey(USER_NAME, PRIVATE_KEY_FILE, null)) { - return false; - } - - return true; - } catch (IOException e) { - throw new ConnectionException("Exception during SSH authentication (public key) for server [" - + conn.getHostname() + "]", e); - } - } - - private boolean authenticateWithPassword(Connection conn) { - try { - if (!supportsPasswordAuthentication(conn)) { - throw new ConnectionException("Password authentication not supported on [" + conn.getHostname() - + "]"); - } - - if (!conn.authenticateWithPassword(USER_NAME, DEFAULT_PASSWORD)) { - return false; - } - return true; - } catch (IOException e) { - throw new ConnectionException("Exception during SSH authentication (password) for server [" - + conn.getHostname() + "]", e); - } - } - - private boolean supportsPasswordAuthentication(Connection conn) throws IOException { - return Arrays.asList(conn.getRemainingAuthMethods(USER_NAME)).contains("password"); - } - - private boolean supportsPublicKeyAuthentication(Connection conn) throws IOException { - return Arrays.asList(conn.getRemainingAuthMethods(USER_NAME)).contains("publickey"); - } - - private synchronized Connection createConnection(String serverName) { - Connection conn = new Connection(serverName); - try { - conn.connect(null, sshConnectTimeout, sshKexTimeout); - } catch (IOException e) { - logger.error("Couldn't establish SSH connection with server [" + serverName + "]", e); - conn.close(); - throw new ConnectionException("Exception while creating SSH connection with server [" + serverName + "]", e); - } - return conn; - } - - private boolean wasTerminated(int condition) { - return ((condition | ChannelCondition.EXIT_SIGNAL) == condition); - } - - private boolean hasErrors(int condition, Session session) { - return (hasErrorStream(condition) || (exitedGracefully(condition) && exitedWithError(session))); - } - - private boolean timedOut(int condition) { - return (condition == ChannelCondition.TIMEOUT); - } - - private boolean exitedWithError(Session session) { - return session.getExitStatus() != ProcessResult.SUCCESS; - } - - private boolean exitedGracefully(int condition) { - return (condition | ChannelCondition.EXIT_STATUS) == condition; - } - - private boolean hasErrorStream(int condition) { - return (condition | ChannelCondition.STDERR_DATA) == condition; - } - - private ProcessResult executeCommand(Connection sshConnection, String command) { - Session session = null; - try { - session = sshConnection.openSession(); - BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(new StreamGobbler( - session.getStdout()))); - BufferedReader stderrReader = new BufferedReader(new InputStreamReader(new StreamGobbler( - session.getStderr()))); - session.execCommand(command); - ProcessResult result = getResultOfExecution(session, stdoutReader, stderrReader); - return result; - } catch (Exception e) { - String errMsg = "Exception while executing command [" + command + "] on [" + sshConnection.getHostname() - + "]"; - logger.error(errMsg, e); - - // remove the connection from cache and close it - sshConnCache.remove(sshConnection.getHostname()); - sshConnection.close(); - if(e instanceof IllegalStateException || e instanceof IOException) { - // The connection is no more valid. Create and throw a connection exception. - throw new ConnectionException("Couldn't open SSH session on [" + sshConnection.getHostname() + "]!", e); - } else { - throw new GlusterRuntimeException(errMsg, e); - } - } finally { - if(session != null) { - session.close(); - } - } - } - - private ProcessResult getResultOfExecution(Session session, BufferedReader stdoutReader, BufferedReader stderrReader) { - // Wait for program to come out either - // a) gracefully with an exit status, OR - // b) because of a termination signal - // c) command takes to long to exit (timeout) - int condition = session.waitForCondition(ChannelCondition.EXIT_SIGNAL | ChannelCondition.EXIT_STATUS, - sshExecTimeout); - StringBuilder output = new StringBuilder(); - - try { - if(!timedOut(condition)) { - readFromStream(stdoutReader, output); - if (hasErrors(condition, session)) { - readFromStream(stderrReader, output); - } - } - - return prepareProcessResult(session, condition, output.toString().trim()); - } catch (IOException e) { - String errMsg = "Error while reading output stream from SSH connection!"; - logger.error(errMsg, e); - return new ProcessResult(ProcessResult.FAILURE, errMsg); - } - } - - private ProcessResult prepareProcessResult(Session session, int condition, String output) { - ProcessResult result = null; - - if (wasTerminated(condition)) { - result = new ProcessResult(ProcessResult.FAILURE, output); - } else if (timedOut(condition)) { - result = new ProcessResult(ProcessResult.FAILURE, "Command timed out!"); - } else if (hasErrors(condition, session)) { - Integer exitStatus = session.getExitStatus(); - int statusCode = (exitStatus == null ? ProcessResult.FAILURE : exitStatus); - result = new ProcessResult(statusCode, output); - } else { - result = new ProcessResult(ProcessResult.SUCCESS, output); - } - - return result; - } - - private void readFromStream(BufferedReader streamReader, StringBuilder output) throws IOException { - while (true) { - String line = streamReader.readLine(); - if (line == null) { - break; - } - output.append(line + CoreConstants.NEWLINE); - } - } - - /** - * Executes given command on remote machine using password authentication - * - * @param serverName - * @param command - * @return Result of remote execution - */ - public ProcessResult executeRemoteWithPassword(String serverName, String command) { - logger.info("Executing command [" + command + "] on server [" + serverName + "] with default password."); - Connection conn = null; - try { - conn = getConnectionWithPassword(serverName); - return executeCommand(conn, command); - } finally { - // we don't cache password based connections. hence the connection must be closed. - if(conn != null) { - conn.close(); - } - } - } - - /** - * Executes given command on remote machine using public key authentication - * - * @param serverName - * @param command - * @return Result of remote execution - */ - public ProcessResult executeRemote(String serverName, String command) { - logger.info("Executing command [" + command + "] on server [" + serverName + "]"); - return executeCommand(getConnection(serverName), command); - } - - public void cleanup() { - for (Connection conn : sshConnCache.values()) { - conn.close(); - } - } - - public Integer getSshConnectTimeout() { - return sshConnectTimeout; - } - - public void setSshConnectTimeout(Integer sshConnectTimeout) { - this.sshConnectTimeout = sshConnectTimeout; - } - - public Integer getSshKexTimeout() { - return sshKexTimeout; - } - - public void setSshKexTimeout(Integer sshKexTimeout) { - this.sshKexTimeout = sshKexTimeout; - } - - public Integer getSshExecTimeout() { - return sshExecTimeout; - } - - public void setSshExecTimeout(Integer sshExecTimeout) { - this.sshExecTimeout = sshExecTimeout; - } -} diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/StatsFactory.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/StatsFactory.java deleted file mode 100644 index 09851367..00000000 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/StatsFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Gluster, Inc. - * This file is part of Gluster Management Console. - * - * Gluster Management Console is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Gluster Management Console is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License - * for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see - * . - *******************************************************************************/ -package com.gluster.storage.management.gateway.utils; - -import java.util.List; - -import com.gluster.storage.management.core.model.ServerStats; - -/** - * - */ -public interface StatsFactory { - public ServerStats fetchStats(String serverName, String period, String...args); - public ServerStats fetchAggregatedStats(List serverName, String period); -} diff --git a/src/com.gluster.storage.management.gateway/src/log4j.properties b/src/com.gluster.storage.management.gateway/src/log4j.properties deleted file mode 100644 index bde9e66f..00000000 --- a/src/com.gluster.storage.management.gateway/src/log4j.properties +++ /dev/null @@ -1,20 +0,0 @@ -log4j.rootLogger=INFO, R - -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.immediateFlush=true -log4j.appender.CONSOLE.target=System.out -log4j.appender.CONSOLE.threshold=DEBUG -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{dd MMM, yyyy HH:mm:ss} %p: %c %t - %m%n - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.File=/var/log/glustermg/glustermg.log -log4j.appender.R.MaxFileSize=10MB -log4j.appender.R.MaxBackupIndex=10 -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=%d{dd MMM, yyyy HH:mm:ss} %p: %c %t - %m%n -#log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n - -log4j.logger.org=ERROR -log4j.logger.com=ERROR -log4j.logger.com.gluster=DEBUG \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/rebel.xml b/src/com.gluster.storage.management.gateway/src/rebel.xml deleted file mode 100644 index 0f2140c9..00000000 --- a/src/com.gluster.storage.management.gateway/src/rebel.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/com.gluster.storage.management.gateway/src/spring/gluster-server-base.xml b/src/com.gluster.storage.management.gateway/src/spring/gluster-server-base.xml deleted file mode 100644 index 72eb0409..00000000 --- a/src/com.gluster.storage.management.gateway/src/spring/gluster-server-base.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.gluster.storage.management.gateway.data.ClusterInfo - - - - - - com.gluster.storage.management.gateway.data.ServerInfo - - - - - - - - - - - \ No newline at end of file diff --git a/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml b/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml deleted file mode 100644 index e160d31a..00000000 --- a/src/com.gluster.storage.management.gateway/src/spring/gluster-server-security.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/org.gluster.storage.management.client/.classpath b/src/org.gluster.storage.management.client/.classpath new file mode 100644 index 00000000..cd4aaff7 --- /dev/null +++ b/src/org.gluster.storage.management.client/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.client/.project b/src/org.gluster.storage.management.client/.project new file mode 100644 index 00000000..e8da4675 --- /dev/null +++ b/src/org.gluster.storage.management.client/.project @@ -0,0 +1,34 @@ + + + org.gluster.storage.management.client + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + com.instantiations.assist.eclipse.coverage.instrumentationBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + com.instantiations.assist.eclipse.coverage.codeCoverageNature + + diff --git a/src/org.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs b/src/org.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f8b5cc38 --- /dev/null +++ b/src/org.gluster.storage.management.client/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Dec 29 15:47:13 IST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/org.gluster.storage.management.client/META-INF/MANIFEST.MF b/src/org.gluster.storage.management.client/META-INF/MANIFEST.MF new file mode 100644 index 00000000..0ff85d5f --- /dev/null +++ b/src/org.gluster.storage.management.client/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Gluster Storage Platform Client +Bundle-SymbolicName: org.gluster.storage.management.client +Bundle-Version: 1.0.0 +Bundle-Vendor: GLUSTER +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.gluster.storage.management.core;bundle-version="1.0.0", + org.eclipse.equinox.common;bundle-version="3.6.0" +Export-Package: org.gluster.storage.management.client, + org.gluster.storage.management.client.constants +Bundle-ClassPath: ., + lib/jersey-1.5/jersey-client-1.5.jar, + lib/jersey-1.5/jersey-core-1.5.jar, + lib/jersey-1.5/jersey-multipart-1.5.jar, + keystore/ +Import-Package: org.eclipse.jface.preference diff --git a/src/org.gluster.storage.management.client/build.properties b/src/org.gluster.storage.management.client/build.properties new file mode 100644 index 00000000..b9d04dbf --- /dev/null +++ b/src/org.gluster.storage.management.client/build.properties @@ -0,0 +1,14 @@ +source.. = src/ +output.. = bin/ +bin.includes = .,\ + META-INF/,\ + lib/,\ + keystore/,\ + lib/jersey-1.5/jersey-multipart-1.5.jar +src.includes = lib/,\ + keystore/,\ + build.properties,\ + .project,\ + .classpath,\ + .settings/,\ + META-INF/ diff --git a/src/org.gluster.storage.management.client/keystore/gmc-trusted.keystore b/src/org.gluster.storage.management.client/keystore/gmc-trusted.keystore new file mode 100644 index 00000000..5517b6e5 Binary files /dev/null and b/src/org.gluster.storage.management.client/keystore/gmc-trusted.keystore differ diff --git a/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar b/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar new file mode 100644 index 00000000..62f790fa Binary files /dev/null and b/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-client-1.5.jar differ diff --git a/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar b/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar new file mode 100644 index 00000000..92b38466 Binary files /dev/null and b/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-core-1.5.jar differ diff --git a/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar b/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar new file mode 100644 index 00000000..1c134f05 Binary files /dev/null and b/src/org.gluster.storage.management.client/lib/jersey-1.5/jersey-multipart-1.5.jar differ diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/AbstractClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/AbstractClient.java new file mode 100644 index 00000000..bef3f87b --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/AbstractClient.java @@ -0,0 +1,429 @@ +package org.gluster.storage.management.client; + +import static org.gluster.storage.management.client.constants.ClientConstants.ALGORITHM_SUNX509; +import static org.gluster.storage.management.client.constants.ClientConstants.KEYSTORE_TYPE_JKS; +import static org.gluster.storage.management.client.constants.ClientConstants.PROTOCOL_TLS; +import static org.gluster.storage.management.client.constants.ClientConstants.TRUSTED_KEYSTORE; +import static org.gluster.storage.management.client.constants.ClientConstants.TRUSTED_KEYSTORE_ACCESS; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.ConnectException; +import java.net.URI; +import java.security.KeyStore; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManagerFactory; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; + +import org.gluster.storage.management.client.utils.ClientUtil; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.UniformInterfaceException; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.WebResource.Builder; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.representation.Form; +import com.sun.jersey.client.urlconnection.HTTPSProperties; +import com.sun.jersey.core.util.MultivaluedMapImpl; +import com.sun.jersey.multipart.FormDataMultiPart; + +public abstract class AbstractClient { + private static final String HTTP_HEADER_AUTH = "Authorization"; + protected static final MultivaluedMap NO_PARAMS = new MultivaluedMapImpl(); + protected static String clusterName; + protected static String securityToken; + protected WebResource resource; + private String authHeader; + private Client client; + + /** + * This constructor will work only after the data model manager has been initialized. + */ + public AbstractClient() { + this(securityToken, clusterName); + } + + /** + * This constructor will work only after the data model manager has been initialized. + */ + public AbstractClient(String clusterName) { + this(securityToken, clusterName); + } + + public AbstractClient(String securityToken, String clusterName) { + AbstractClient.clusterName = clusterName; + setSecurityToken(securityToken); + + createClient(); + + // this must be after setting clusterName as sub-classes may refer to cluster name in the getResourcePath method + resource = client.resource(ClientUtil.getServerBaseURI()).path(getResourcePath()); + } + + private void createClient() { + SSLContext context = initializeSSLContext(); + DefaultClientConfig config = createClientConfig(context); + client = Client.create(config); + } + + private DefaultClientConfig createClientConfig(SSLContext context) { + DefaultClientConfig config = new DefaultClientConfig(); + config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new HTTPSProperties(createHostnameVerifier(), context)); + return config; + } + + private HostnameVerifier createHostnameVerifier() { + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String arg0, SSLSession arg1) { + return true; + } + }; + return hostnameVerifier; + } + + private SSLContext initializeSSLContext() { + SSLContext context = null; + try { + context = SSLContext.getInstance(PROTOCOL_TLS); + + KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE_JKS); + keyStore.load(loadResource(TRUSTED_KEYSTORE), TRUSTED_KEYSTORE_ACCESS.toCharArray()); + + KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(ALGORITHM_SUNX509); + keyManagerFactory.init(keyStore, TRUSTED_KEYSTORE_ACCESS.toCharArray()); + + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(ALGORITHM_SUNX509); + trustManagerFactory.init(keyStore); + + context.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null); + } catch (Exception e) { + throw new GlusterRuntimeException( + "Couldn't initialize SSL Context with Gluster Management Gateway! Error: " + e, e); + } + return context; + } + + private InputStream loadResource(String resourcePath) { + return this.getClass().getClassLoader().getResourceAsStream(resourcePath); + } + + /** + * Fetches the given resource by dispatching a GET request + * + * @param res + * Resource to be fetched + * @param queryParams + * Query parameters to be sent for the GET request + * @param responseClass + * Expected class of the response + * @return Object of responseClass received as a result of the GET request + */ + private T fetchResource(WebResource res, MultivaluedMap queryParams, Class responseClass) { + try { + return res.queryParams(queryParams).header(HTTP_HEADER_AUTH, authHeader).accept(MediaType.APPLICATION_XML) + .get(responseClass); + } catch (Exception e1) { + throw createGlusterException(e1); + } + } + + private GlusterRuntimeException createGlusterException(Exception e) { + if (e instanceof GlusterRuntimeException) { + return (GlusterRuntimeException) e; + } + + if (e instanceof UniformInterfaceException) { + UniformInterfaceException uie = (UniformInterfaceException) e; + if ((uie.getResponse().getStatus() == Response.Status.UNAUTHORIZED.getStatusCode())) { + // authentication failed. clear security token. + setSecurityToken(null); + return new GlusterRuntimeException("Invalid credentials!"); + } else { + return new GlusterRuntimeException("[" + uie.getResponse().getStatus() + "][" + + uie.getResponse().getEntity(String.class) + "]"); + } + } else { + Throwable cause = e.getCause(); + if (cause != null && cause instanceof ConnectException) { + return new GlusterRuntimeException("Couldn't connect to Gluster Management Gateway!"); + } + + return new GlusterRuntimeException("Exception in REST communication! [" + e.getMessage() + "]", e); + } + } + + protected void downloadResource(WebResource res, String filePath) { + ClientResponse response = null; + try { + response = res.header(HTTP_HEADER_AUTH, authHeader).accept(MediaType.APPLICATION_OCTET_STREAM) + .get(ClientResponse.class); + checkResponseStatus(response); + } catch (Exception e1) { + throw createGlusterException(e1); + } + + try { + if (!response.hasEntity()) { + throw new GlusterRuntimeException("No entity in response!"); + } + + InputStream inputStream = response.getEntityInputStream(); + FileOutputStream outputStream = new FileOutputStream(filePath); + + int c; + while ((c = inputStream.read()) != -1) { + outputStream.write(c); + } + inputStream.close(); + outputStream.close(); + } catch (IOException e) { + throw new GlusterRuntimeException("Error while downloading resource [" + res.getURI().getPath() + "]", e); + } + } + + public void uploadResource(WebResource res, FormDataMultiPart form) { + try { + res.header(HTTP_HEADER_AUTH, authHeader).type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, form); + } catch (Exception e) { + throw createGlusterException(e); + } + } + + /** + * Fetches the default resource (the one returned by {@link AbstractClient#getResourcePath()}) by dispatching a GET + * request on the resource + * + * @param queryParams + * Query parameters to be sent for the GET request + * @param responseClass + * Expected class of the response + * @return Object of responseClass received as a result of the GET request + */ + protected T fetchResource(MultivaluedMap queryParams, Class responseClass) { + return fetchResource(resource, queryParams, responseClass); + } + + /** + * Fetches the default resource (the one returned by {@link AbstractClient#getResourcePath()}) by dispatching a GET + * request on the resource + * + * @param responseClass + * Expected class of the response + * @return Object of responseClass received as a result of the GET request + */ + protected T fetchResource(Class responseClass) { + return fetchResource(resource, NO_PARAMS, responseClass); + } + + /** + * Fetches the resource whose name is arrived at by appending the "subResourceName" parameter to the default + * resource (the one returned by {@link AbstractClient#getResourcePath()}) + * + * @param subResourceName + * Name of the sub-resource + * @param responseClass + * Expected class of the response + * @return Object of responseClass received as a result of the GET request on the sub-resource + */ + protected T fetchSubResource(String subResourceName, Class responseClass) { + return fetchResource(resource.path(subResourceName), NO_PARAMS, responseClass); + } + + protected void downloadSubResource(String subResourceName, String filePath) { + downloadResource(resource.path(subResourceName), filePath); + } + + /** + * Fetches the resource whose name is arrived at by appending the "subResourceName" parameter to the default + * resource (the one returned by {@link AbstractClient#getResourcePath()}) + * + * @param subResourceName + * Name of the sub-resource + * @param queryParams + * Query parameters to be sent for the GET request + * @param responseClass + * Expected class of the response + * @return Object of responseClass received as a result of the GET request on the sub-resource + */ + protected T fetchSubResource(String subResourceName, MultivaluedMap queryParams, + Class responseClass) { + return fetchResource(resource.path(subResourceName), queryParams, responseClass); + } + + private ClientResponse postRequest(WebResource resource, Form form) { + try { + ClientResponse response = prepareFormRequestBuilder(resource).post(ClientResponse.class, form); + checkResponseStatus(response); + return response; + } catch (UniformInterfaceException e) { + throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); + } + } + + /** + * Submits given object to the resource and returns the object received as response + * + * @param responseClass + * Class of the object expected as response + * @param requestObject + * the Object to be submitted + * @return Object of given class received as response + */ + protected T postObject(Class responseClass, Object requestObject) { + return resource.type(MediaType.APPLICATION_XML).header(HTTP_HEADER_AUTH, authHeader) + .accept(MediaType.APPLICATION_XML).post(responseClass, requestObject); + } + + /** + * Submits given Form using POST method to the resource and returns the object received as response + * + * @param form + * Form to be submitted + */ + protected URI postRequest(Form form) { + return postRequest(resource, form).getLocation(); + } + + /** + * Submits given Form using POST method to the given sub-resource and returns the object received as response + * + * @param subResourceName + * Name of the sub-resource to which the request is to be posted + * @param form + * Form to be submitted + */ + protected void postRequest(String subResourceName, Form form) { + postRequest(resource.path(subResourceName), form); + } + + private ClientResponse putRequest(WebResource resource, Form form) { + try { + ClientResponse response = prepareFormRequestBuilder(resource).put(ClientResponse.class, form); + checkResponseStatus(response); + return response; + } catch (Exception e) { + throw createGlusterException(e); + } + } + + private void checkResponseStatus(ClientResponse response) { + if ((response.getStatus() == Response.Status.UNAUTHORIZED.getStatusCode())) { + // authentication failed. clear security token. + setSecurityToken(null); + throw new GlusterRuntimeException("Invalid credentials!"); + } + if (response.getStatus() >= 300) { + throw new GlusterRuntimeException(response.getEntity(String.class)); + } + } + + public Builder prepareFormRequestBuilder(WebResource resource) { + return resource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).header(HTTP_HEADER_AUTH, authHeader) + .accept(MediaType.APPLICATION_XML); + } + + /** + * Submits given Form using PUT method to the given sub-resource and returns the object received as response + * + * @param subResourceName + * Name of the sub-resource to which the request is to be posted + * @param form + * Form to be submitted + */ + protected void putRequest(String subResourceName, Form form) { + putRequest(resource.path(subResourceName), form); + } + + protected URI putRequestURI(String subResourceName, Form form) { + ClientResponse response = putRequest(resource.path(subResourceName), form); + return response.getLocation(); + } + + /** + * Submits given Form using PUT method to the given sub-resource and returns the object received as response + * + * @param form + * Form to be submitted + */ + protected void putRequest(Form form) { + putRequest(resource, form); + } + + /** + * Submits given Form using PUT method to the given sub-resource and returns the object received as response + * + * @param subResourceName + * Name of the sub-resource to which the request is to be posted + */ + protected void putRequest(String subResourceName) { + try { + prepareFormRequestBuilder(resource.path(subResourceName)).put(); + } catch (UniformInterfaceException e) { + throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); + } + } + + private void deleteResource(WebResource resource, MultivaluedMap queryParams) { + try { + resource.queryParams(queryParams).header(HTTP_HEADER_AUTH, authHeader).delete(); + } catch (UniformInterfaceException e) { + throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); + } + } + + protected void deleteResource(MultivaluedMap queryParams) { + deleteResource(resource, queryParams); + } + + protected void deleteSubResource(String subResourceName, MultivaluedMap queryParams) { + deleteResource(resource.path(subResourceName), queryParams); + } + + protected void deleteSubResource(String subResourceName) { + try { + resource.path(subResourceName).header(HTTP_HEADER_AUTH, authHeader).delete(); + } catch (UniformInterfaceException e) { + throw new GlusterRuntimeException(e.getResponse().getEntity(String.class)); + } + } + + public abstract String getResourcePath(); + + /** + * @return the securityToken + */ + protected String getSecurityToken() { + return securityToken; + } + + /** + * @param securityToken + * the securityToken to set + */ + protected void setSecurityToken(String securityToken) { + AbstractClient.securityToken = securityToken; + authHeader = "Basic " + securityToken; + } + + /** + * @param uri + * The URI to be fetched using GET API + * @param responseClass + * Expected type of response object + * @return Object of the given class + */ + protected T fetchResource(URI uri, Class responseClass) { + return fetchResource(client.resource(uri), NO_PARAMS, responseClass); + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/ClustersClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/ClustersClient.java new file mode 100644 index 00000000..cbb08f2c --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/ClustersClient.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.client; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CLUSTER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; + +import java.util.List; + +import org.gluster.storage.management.core.response.ClusterNameListResponse; + +import com.sun.jersey.api.representation.Form; + +/** + * + */ +public class ClustersClient extends AbstractClient { + public ClustersClient() { + super(); + } + + public ClustersClient(String securityToken) { + super(); + setSecurityToken(securityToken); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.client.AbstractClient#getResourcePath() + */ + @Override + public String getResourcePath() { + return RESOURCE_PATH_CLUSTERS; + } + + public List getClusterNames() { + return ((ClusterNameListResponse)fetchResource(ClusterNameListResponse.class)).getClusterNames(); + } + + public void createCluster(String clusterName) { + Form form = new Form(); + form.add(FORM_PARAM_CLUSTER_NAME, clusterName); + + postRequest(form); + } + + public void registerCluster(String clusterName, String knownServer) { + Form form = new Form(); + form.add(FORM_PARAM_CLUSTER_NAME, clusterName); + form.add(FORM_PARAM_SERVER_NAME, knownServer); + putRequest(form); + } + + public void deleteCluster(String clusterName) { + deleteSubResource(clusterName); + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/DiscoveredServersClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/DiscoveredServersClient.java new file mode 100644 index 00000000..b18e0d17 --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/DiscoveredServersClient.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.client; + +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_DISCOVERED_SERVERS; + +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.response.ServerListResponse; +import org.gluster.storage.management.core.response.ServerNameListResponse; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; + +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class DiscoveredServersClient extends AbstractClient { + + public DiscoveredServersClient(String clusterName) { + super(clusterName); + } + + public DiscoveredServersClient(String securityToken, String clusterName) { + super(securityToken, clusterName); + } + + @Override + public String getResourcePath() { + return RESOURCE_PATH_DISCOVERED_SERVERS; + } + + private T getDiscoveredServers(Boolean details, Class responseClass) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.putSingle(QUERY_PARAM_DETAILS, details.toString()); + return fetchResource(queryParams, responseClass); + } + + public List getDiscoveredServerNames() { + return ((ServerNameListResponse) getDiscoveredServers(Boolean.FALSE, ServerNameListResponse.class)) + .getServerNames(); + } + + public List getDiscoveredServerDetails() { + List servers = ((ServerListResponse) getDiscoveredServers(Boolean.TRUE, ServerListResponse.class)) + .getServers(); + + for (Server server : servers) { + GlusterCoreUtil.updateServerNameOnDevices(server); + } + return servers; + } + + public Server getServer(String serverName) { + return (Server) fetchSubResource(serverName, Server.class); + } + + public static void main(String[] args) { + UsersClient usersClient = new UsersClient(); + try { + usersClient.authenticate("gluster", "gluster"); + DiscoveredServersClient serverResource = new DiscoveredServersClient(usersClient.getSecurityToken(), "new"); + List discoveredServerNames = serverResource.getDiscoveredServerNames(); + System.out.println(discoveredServerNames); + List discoveredServers = serverResource.getDiscoveredServerDetails(); + System.out.println(discoveredServers); + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/GlusterServersClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/GlusterServersClient.java new file mode 100644 index 00000000..46200c9a --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/GlusterServersClient.java @@ -0,0 +1,140 @@ +/******************************************************************************* +* Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.client; + +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_SERVERS; + +import java.net.URI; +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.response.FsTypeListResponse; +import org.gluster.storage.management.core.response.GlusterServerListResponse; +import org.gluster.storage.management.core.response.StringListResponse; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; + +import com.sun.jersey.api.representation.Form; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class GlusterServersClient extends AbstractClient { + + public GlusterServersClient() { + super(); + } + + public GlusterServersClient(String clusterName) { + super(clusterName); + } + + public GlusterServersClient(String securityToken, String clusterName) { + super(securityToken, clusterName); + } + + @Override + public String getResourcePath() { + return RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_SERVERS; + } + + public List getServers() { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.putSingle(QUERY_PARAM_DETAILS, "true"); + List servers = ((GlusterServerListResponse) fetchResource(queryParams, GlusterServerListResponse.class)).getServers(); + for(GlusterServer server : servers) { + GlusterCoreUtil.updateServerNameOnDevices(server); + } + return servers; + } + + public GlusterServer getGlusterServer(String serverName) { + GlusterServer server = (GlusterServer) fetchSubResource(serverName, GlusterServer.class); + GlusterCoreUtil.updateServerNameOnDevices(server); + return server; + } + + public URI addServer(String serverName) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_SERVER_NAME, serverName); + return postRequest(form); + } + + public List getFSTypes(String serverName) { + FsTypeListResponse fsTypeListResponse = ((FsTypeListResponse) fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_FSTYPES, + FsTypeListResponse.class)); + return fsTypeListResponse.getFsTypes(); + } + + public URI initializeDisk(String serverName, String diskName, String fsType, String mountPoint) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_FSTYPE, fsType); + form.add(RESTConstants.FORM_PARAM_MOUNTPOINT, fsType); + return putRequestURI(serverName + "/" + RESTConstants.RESOURCE_DISKS + "/" + diskName, form); + } + + public void removeServer(String serverName) { + deleteSubResource(serverName); + } + + public ServerStats getCpuStats(String serverName, String period) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_CPU); + queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); + return fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); + } + + public ServerStats getMemoryStats(String serverName, String period) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_MEMORY); + queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); + return fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); + } + + public ServerStats getNetworkStats(String serverName, String networkInterface, String period) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_NETWORK); + queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); + queryParams.add(RESTConstants.QUERY_PARAM_INTERFACE, networkInterface); + return fetchSubResource(serverName + "/" + RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); + } + + public ServerStats getAggregatedCpuStats(String period) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_CPU); + queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); + return fetchSubResource(RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); + } + + public ServerStats getAggregatedNetworkStats(String period) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_TYPE, RESTConstants.STATISTICS_TYPE_NETWORK); + queryParams.add(RESTConstants.QUERY_PARAM_PERIOD, period); + return fetchSubResource(RESTConstants.RESOURCE_STATISTICS, queryParams, ServerStats.class); + } + + public GlusterServer getGlusterServer(URI uri) { + GlusterServer server = fetchResource(uri, GlusterServer.class); + GlusterCoreUtil.updateServerNameOnDevices(server); + return server; + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/KeysClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/KeysClient.java new file mode 100644 index 00000000..de4abd69 --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/KeysClient.java @@ -0,0 +1,56 @@ +/** + * KeysClient.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.client; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import javax.ws.rs.core.MediaType; + +import org.gluster.storage.management.core.constants.RESTConstants; + +import com.sun.jersey.multipart.FormDataMultiPart; + +public class KeysClient extends AbstractClient { + + public KeysClient() { + super(); + } + + @Override + public String getResourcePath() { + return RESTConstants.RESOURCE_KEYS; + } + + public void exportSshKeys(String filePath) { + downloadResource(resource, filePath); + } + + public void importSshKeys(String keysFile) { + FormDataMultiPart form = new FormDataMultiPart(); + try { + form.field("file", new FileInputStream(keysFile), MediaType.TEXT_PLAIN_TYPE); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + uploadResource(resource, form); + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/TasksClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/TasksClient.java new file mode 100644 index 00000000..80e10691 --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/TasksClient.java @@ -0,0 +1,104 @@ +/** + * tasksClient.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.client; + +import java.net.URI; +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.response.TaskInfoListResponse; + +import com.sun.jersey.api.representation.Form; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class TasksClient extends AbstractClient { + + public TasksClient() { + super(); + } + + public TasksClient(String clusterName) { + super(clusterName); + } + + public TasksClient(String securityToken,String clusterName) { + super(securityToken, clusterName); + } + + @Override + public String getResourcePath() { + return RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESTConstants.RESOURCE_TASKS + "/"; + } + + public List getAllTasks() { // TaskListResponse get only the list of taskInfo not list of Tasks + return ((TaskInfoListResponse) fetchResource(TaskInfoListResponse.class)).getTaskList(); + } + + // see startMigration @ VolumesClient, etc + public void pauseTask(String taskId) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_PAUSE); + + putRequest( taskId, form); + } + + public void resumeTask(String taskId) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_RESUME); + + putRequest(taskId, form); + } + + public void stopTask(String taskId) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_STOP); + + putRequest(taskId, form); + } + + public void commitTask(String taskId) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_COMMIT); + + putRequest(taskId, form); + } + + public void getTaskStatus(String taskId) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_STATUS); + + putRequest(taskId, form); + } + + public void deleteTask(String taskId) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_DELETE); + + deleteSubResource(taskId, queryParams); + } + + public TaskInfo getTaskInfo(URI uri) { + return ((TaskInfo) fetchResource(uri, TaskInfo.class)); + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/UsersClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/UsersClient.java new file mode 100644 index 00000000..b35444f7 --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/UsersClient.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.client; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_NEW_PASSWORD; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OLD_PASSWORD; + +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Status; + +import com.sun.jersey.api.representation.Form; +import com.sun.jersey.core.util.Base64; + + +public class UsersClient extends AbstractClient { + private String generateSecurityToken(String user, String password) { + return new String(Base64.encode(user + ":" + password)); + } + + public UsersClient() { + super(); + } + + public void authenticate(String user, String password) { + setSecurityToken(generateSecurityToken(user, password)); + fetchSubResource(user, Status.class); + } + + public void changePassword(String user, String oldPassword, String newPassword) { + String oldSecurityToken = getSecurityToken(); + String newSecurityToken = generateSecurityToken(user, oldPassword); + if(!oldSecurityToken.equals(newSecurityToken)) { + throw new GlusterRuntimeException("Invalid old password!"); + } + + Form form = new Form(); + form.add(FORM_PARAM_OLD_PASSWORD, oldPassword); + form.add(FORM_PARAM_NEW_PASSWORD, newPassword); + putRequest(user, form); + + // password changed. set the new security token + setSecurityToken(generateSecurityToken(user, newPassword)); + //authenticate(user, newPassword); + } + + public static void main(String[] args) { + UsersClient authClient = new UsersClient(); + + // authenticate user + authClient.authenticate("gluster", "gluster"); + + // change password to gluster1 + authClient.changePassword("gluster", "gluster", "gluster1"); + + // change it back to gluster + authClient.changePassword("gluster", "gluster1", "gluster"); + + System.out.println("success"); + } + + /* + * (non-Javadoc) + * + * @see org.gluster.storage.management.client.AbstractClient#getResourceName() + */ + @Override + public String getResourcePath() { + return RESTConstants.RESOURCE_USERS; + } + + /* + * (non-Javadoc) + * + * @see org.gluster.storage.management.client.AbstractClient#getSecurityToken() + */ + @Override + public String getSecurityToken() { + return super.getSecurityToken(); + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/VolumesClient.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/VolumesClient.java new file mode 100644 index 00000000..221ae84a --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/VolumesClient.java @@ -0,0 +1,282 @@ +/** + * VolumesClient.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.client; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_ACCESS_PROTOCOLS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_USERS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_REPLICA_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_STRIPE_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TRANSPORT_TYPE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_OPTIONS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_TYPE; + +import java.net.URI; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import javax.ws.rs.core.MultivaluedMap; + +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeLogMessage; +import org.gluster.storage.management.core.model.VolumeOptionInfo; +import org.gluster.storage.management.core.response.LogMessageListResponse; +import org.gluster.storage.management.core.response.VolumeListResponse; +import org.gluster.storage.management.core.response.VolumeOptionInfoListResponse; +import org.gluster.storage.management.core.utils.DateUtil; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.StringUtil; + +import com.sun.jersey.api.representation.Form; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class VolumesClient extends AbstractClient { + public VolumesClient() { + super(); + } + + public VolumesClient(String clusterName) { + super(clusterName); + } + + public VolumesClient(String securityToken, String clusterName) { + super(securityToken, clusterName); + } + + @Override + public String getResourcePath() { + return RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESTConstants.RESOURCE_VOLUMES; + } + + public void createVolume(Volume volume) { + Form form = new Form(); + form.add(FORM_PARAM_VOLUME_NAME, volume.getName()); + form.add(FORM_PARAM_VOLUME_TYPE, volume.getVolumeType().toString()); + form.add(FORM_PARAM_TRANSPORT_TYPE, volume.getTransportType().toString()); + form.add(FORM_PARAM_REPLICA_COUNT, volume.getReplicaCount()); + form.add(FORM_PARAM_STRIPE_COUNT, volume.getStripeCount()); + form.add(FORM_PARAM_BRICKS, StringUtil.collectionToString(volume.getBricks(), ",")); + form.add(FORM_PARAM_ACCESS_PROTOCOLS, StringUtil.collectionToString(volume.getNASProtocols(), ",")); + form.add(FORM_PARAM_VOLUME_OPTIONS, StringUtil.collectionToString(volume.getOptions().getOptions(), ",")); + if (volume.isCifsEnable()) { + form.add(FORM_PARAM_CIFS_USERS, StringUtil.collectionToString(volume.getCifsUsers(), ",")); + } + postRequest(form); + } + + private void performOperation(String volumeName, String operation, Boolean force) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, operation); + form.add(RESTConstants.FORM_PARAM_FORCE, force); + + putRequest(volumeName, form); + } + + public void startVolume(String volumeName, Boolean forceStart) { + performOperation(volumeName, RESTConstants.TASK_START, forceStart); + } + + public void stopVolume(String volumeName, Boolean forceStop) { + performOperation(volumeName, RESTConstants.TASK_STOP, forceStop); + } + + public void setCifsConfig(String volumeName, Boolean isCifsEnabled, String cifsUsers) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.FORM_PARAM_CIFS_CONFIG); + form.add(RESTConstants.FORM_PARAM_CIFS_ENABLE, isCifsEnabled); + form.add(RESTConstants.FORM_PARAM_CIFS_USERS, cifsUsers); + putRequest(volumeName, form); + } + + public boolean volumeExists(String volumeName) { + try { + // TODO: instead of fetching full volume name, fetch list of volumes and check if + // it contains our volume name + getVolume(volumeName); + return true; + } catch(Exception e) { + return false; + } + } + + public void setVolumeOption(String volume, String key, String value) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPTION_KEY, key); + form.add(RESTConstants.FORM_PARAM_OPTION_VALUE, value); + postRequest(volume + "/" + RESTConstants.RESOURCE_OPTIONS, form); + } + + public void resetVolumeOptions(String volume) { + putRequest(volume + "/" + RESTConstants.RESOURCE_OPTIONS); + } + + public List getAllVolumes() { + return ((VolumeListResponse) fetchResource(VolumeListResponse.class)).getVolumes(); + } + + public Volume getVolume(String volumeName) { + return (Volume)fetchSubResource(volumeName, Volume.class); + } + + public void deleteVolume(String volumeName, boolean deleteOption) { + MultivaluedMap queryParams = prepareDeleteVolumeQueryParams(deleteOption); + deleteSubResource(volumeName, queryParams); + } + + public List getVolumeOptionsInfo() { + return ((VolumeOptionInfoListResponse) fetchSubResource(RESTConstants.RESOURCE_DEFAULT_OPTIONS, + VolumeOptionInfoListResponse.class)).getOptions(); + } + + public void addBricks(String volumeName, Set brickList) { + String bricks = StringUtil.collectionToString(brickList, ","); + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_BRICKS, bricks); + postRequest(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, form); + } + + /** + * Fetches volume logs for the given volume based on given filter criteria + * + * @param volumeName + * Name of volume whose logs are to be fetched + * @param brickName + * Name of the brick whose logs are to be fetched. Pass ALL to fetch log messages from all bricks of the + * volume. + * @param severity + * Log severity {@link GlusterConstants#VOLUME_LOG_LEVELS_ARR}. Pass ALL to fetch log messages of all + * severity levels. + * @param fromTimestamp + * From timestamp. Pass null if this filter is not required. + * @param toTimestamp + * To timestamp. Pass null if this filter is not required. + * @param messageCount + * Number of most recent log messages to be fetched (from each disk) + * @return Log Message List response received from the Gluster Management Server. + */ + public List getLogs(String volumeName, String brickName, String severity, Date fromTimestamp, + Date toTimestamp, int messageCount) { + MultivaluedMap queryParams = prepareGetLogQueryParams(brickName, severity, fromTimestamp, + toTimestamp, messageCount); + + return ((LogMessageListResponse) fetchSubResource(volumeName + "/" + RESTConstants.RESOURCE_LOGS, + queryParams, LogMessageListResponse.class)).getLogMessages(); + } + + public void downloadLogs(String volumeName, String filePath) { + downloadSubResource(volumeName + "/" + RESTConstants.RESOURCE_LOGS + "/" + RESTConstants.RESOURCE_DOWNLOAD, filePath); + } + + public void removeBricks(String volumeName, Set BrickList, boolean deleteOption) { + String bricks = StringUtil.collectionToString(GlusterCoreUtil.getQualifiedBrickList(BrickList), ","); + MultivaluedMap queryParams = prepareRemoveBrickQueryParams(volumeName, bricks, deleteOption); + deleteSubResource(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, queryParams); + } + + private MultivaluedMap prepareRemoveBrickQueryParams(String volumeName, String bricks, + boolean deleteOption) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_VOLUME_NAME, volumeName); + queryParams.add(RESTConstants.QUERY_PARAM_BRICKS, bricks); + queryParams.add(RESTConstants.QUERY_PARAM_DELETE_OPTION, "" + deleteOption); + return queryParams; + } + + private MultivaluedMap prepareDeleteVolumeQueryParams(boolean deleteOption) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_DELETE_OPTION, "" + deleteOption); + return queryParams; + } + + private MultivaluedMap prepareGetLogQueryParams(String brickName, String severity, + Date fromTimestamp, Date toTimestamp, int messageCount) { + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add(RESTConstants.QUERY_PARAM_LINE_COUNT, "" + messageCount); + if (!brickName.equals(CoreConstants.ALL)) { + queryParams.add(RESTConstants.QUERY_PARAM_BRICK_NAME, brickName); + } + + if (!severity.equals(CoreConstants.ALL)) { + queryParams.add(RESTConstants.QUERY_PARAM_LOG_SEVERITY, severity); + } + + if (fromTimestamp != null) { + queryParams.add(RESTConstants.QUERY_PARAM_FROM_TIMESTAMP, + DateUtil.dateToString(fromTimestamp, CoreConstants.DATE_WITH_TIME_FORMAT)); + } + + if (toTimestamp != null) { + queryParams.add(RESTConstants.QUERY_PARAM_TO_TIMESTAMP, + DateUtil.dateToString(toTimestamp, CoreConstants.DATE_WITH_TIME_FORMAT)); + } + return queryParams; + } + + public URI startMigration(String volumeName, String brickFrom, String brickTo, Boolean autoCommit) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_SOURCE, brickFrom); + form.add(RESTConstants.FORM_PARAM_TARGET, brickTo); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_START); + form.add(RESTConstants.FORM_PARAM_AUTO_COMMIT, autoCommit); + return putRequestURI(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, form); + } + + public URI rebalanceStart(String volumeName, Boolean fixLayout, Boolean migrateData, Boolean forcedDataMigrate) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_REBALANCE_START); + form.add(RESTConstants.FORM_PARAM_FIX_LAYOUT, fixLayout); + form.add(RESTConstants.FORM_PARAM_MIGRATE_DATA, migrateData); + form.add(RESTConstants.FORM_PARAM_FORCED_DATA_MIGRATE, forcedDataMigrate); + return putRequestURI(volumeName, form); + } + + public void rebalanceStop(String volumeName) { + Form form = new Form(); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_REBALANCE_STOP); + putRequest(volumeName, form); + } + + public void volumeLogRotate(String volumeName, List brickList) { + Form form = new Form(); + String bricks = StringUtil.collectionToString(brickList, ","); + form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.TASK_LOG_ROTATE); + form.add(FORM_PARAM_BRICKS, bricks); + putRequest(volumeName, form); + } + + public static void main(String[] args) { + UsersClient usersClient = new UsersClient(); + try { + usersClient.authenticate("gluster", "gluster"); + VolumesClient client = new VolumesClient(usersClient.getSecurityToken()); + System.out.println(client.getAllVolumes()); +// client.downloadLogs("vol1", "/tmp/temp1.tar.gz"); + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/constants/ClientConstants.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/constants/ClientConstants.java new file mode 100644 index 00000000..4e6e5602 --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/constants/ClientConstants.java @@ -0,0 +1,39 @@ +/** + * ClientConstants.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.client.constants; + +/** + * + */ +public class ClientConstants { + public static final String SYS_PROP_SERVER_URL = "gluster.server.url"; + public static final String DEFAULT_SERVER_URL = "https://localhost:8443/glustermg/linux.gtk.x86_64"; + public static final String CONTEXT_ROOT = "glustermg"; + public static final String REST_API_VERSION = "1.0.0"; + + // SSL related + public static final String TRUSTED_KEYSTORE = "gmc-trusted.keystore"; + public static final String TRUSTED_KEYSTORE_ACCESS = "gluster"; + public static final String PROTOCOL_TLS = "TLS"; + public static final String ALGORITHM_SUNX509 = "SunX509"; + public static final String KEYSTORE_TYPE_JKS = "JKS"; +} + diff --git a/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/utils/ClientUtil.java b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/utils/ClientUtil.java new file mode 100644 index 00000000..0c0bbc8d --- /dev/null +++ b/src/org.gluster.storage.management.client/src/org/gluster/storage/management/client/utils/ClientUtil.java @@ -0,0 +1,21 @@ +package org.gluster.storage.management.client.utils; + +import java.net.URI; + +import javax.ws.rs.core.UriBuilder; + +import org.gluster.storage.management.client.constants.ClientConstants; + + +public class ClientUtil { + + public static URI getServerBaseURI() { + return UriBuilder.fromUri(getBaseURL()).path(ClientConstants.REST_API_VERSION).build(); + } + + private static String getBaseURL() { + // remove the platform path (e.g. /linux.gtk.x86_64) from the URL + return System.getProperty(ClientConstants.SYS_PROP_SERVER_URL, ClientConstants.DEFAULT_SERVER_URL) + .replaceAll(ClientConstants.CONTEXT_ROOT + "\\/.*", ClientConstants.CONTEXT_ROOT + "\\/"); + } +} diff --git a/src/org.gluster.storage.management.console.feature.webstart/.project b/src/org.gluster.storage.management.console.feature.webstart/.project new file mode 100644 index 00000000..f306a1c9 --- /dev/null +++ b/src/org.gluster.storage.management.console.feature.webstart/.project @@ -0,0 +1,17 @@ + + + org.gluster.storage.management.console.feature.webstart + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/src/org.gluster.storage.management.console.feature.webstart/buckminster.cspex b/src/org.gluster.storage.management.console.feature.webstart/buckminster.cspex new file mode 100644 index 00000000..252a5e15 --- /dev/null +++ b/src/org.gluster.storage.management.console.feature.webstart/buckminster.cspex @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console.feature.webstart/build.properties b/src/org.gluster.storage.management.console.feature.webstart/build.properties new file mode 100644 index 00000000..322a3114 --- /dev/null +++ b/src/org.gluster.storage.management.console.feature.webstart/build.properties @@ -0,0 +1,2 @@ +#bin.includes = feature.xml +root=rootfiles diff --git a/src/org.gluster.storage.management.console.feature.webstart/build/glustermc.ant b/src/org.gluster.storage.management.console.feature.webstart/build/glustermc.ant new file mode 100644 index 00000000..93bf3ccb --- /dev/null +++ b/src/org.gluster.storage.management.console.feature.webstart/build/glustermc.ant @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console.feature.webstart/feature.xml b/src/org.gluster.storage.management.console.feature.webstart/feature.xml new file mode 100644 index 00000000..eb4ae9e9 --- /dev/null +++ b/src/org.gluster.storage.management.console.feature.webstart/feature.xml @@ -0,0 +1,229 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp b/src/org.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp new file mode 100644 index 00000000..ee333971 --- /dev/null +++ b/src/org.gluster.storage.management.console.feature.webstart/rootfiles/gluster-management-console.jnlp @@ -0,0 +1,44 @@ + + + + Gluster Management Console + Gluster Inc. + + Gluster Management Console + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console.feature.webstart/rootfiles/splash.png b/src/org.gluster.storage.management.console.feature.webstart/rootfiles/splash.png new file mode 100644 index 00000000..74983f8a Binary files /dev/null and b/src/org.gluster.storage.management.console.feature.webstart/rootfiles/splash.png differ diff --git a/src/org.gluster.storage.management.console.feature/.project b/src/org.gluster.storage.management.console.feature/.project new file mode 100644 index 00000000..a4a4a321 --- /dev/null +++ b/src/org.gluster.storage.management.console.feature/.project @@ -0,0 +1,17 @@ + + + org.gluster.storage.management.console.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/src/org.gluster.storage.management.console.feature/build.properties b/src/org.gluster.storage.management.console.feature/build.properties new file mode 100644 index 00000000..64f93a9f --- /dev/null +++ b/src/org.gluster.storage.management.console.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/src/org.gluster.storage.management.console.feature/feature.xml b/src/org.gluster.storage.management.console.feature/feature.xml new file mode 100644 index 00000000..3e1f0a2d --- /dev/null +++ b/src/org.gluster.storage.management.console.feature/feature.xml @@ -0,0 +1,942 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console.help/.project b/src/org.gluster.storage.management.console.help/.project new file mode 100644 index 00000000..51640e5e --- /dev/null +++ b/src/org.gluster.storage.management.console.help/.project @@ -0,0 +1,22 @@ + + + org.gluster.storage.management.console.help + + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + + diff --git a/src/org.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs b/src/org.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..970d49e2 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,8 @@ +#Tue Aug 23 12:38:58 IST 2011 +eclipse.preferences.version=1 +encoding//html/concepts/about_gmc.html=UTF-8 +encoding//html/concepts/common_terms.html=UTF-8 +encoding//html/concepts/gluster_fs.html=UTF-8 +encoding//html/gettingstarted/check_req_client.html=UTF-8 +encoding//html/gettingstarted/cifs_service.html=UTF-8 +encoding/build.properties=UTF-8 diff --git a/src/org.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs b/src/org.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs new file mode 100644 index 00000000..d7503970 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/.settings/org.eclipse.wst.css.core.prefs @@ -0,0 +1,4 @@ +#Tue Aug 09 14:50:25 IST 2011 +css-profile//html/concepts/about_gmc.html=org.eclipse.wst.css.core.cssprofile.css1 +css-profile//html/concepts/common_terms.html=org.eclipse.wst.css.core.cssprofile.css1 +eclipse.preferences.version=1 diff --git a/src/org.gluster.storage.management.console.help/META-INF/MANIFEST.MF b/src/org.gluster.storage.management.console.help/META-INF/MANIFEST.MF new file mode 100644 index 00000000..ae61234a --- /dev/null +++ b/src/org.gluster.storage.management.console.help/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Gluster Management Console - Help +Bundle-SymbolicName: org.gluster.storage.management.console.help;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: GLUSTER +Require-Bundle: org.eclipse.help.ui;bundle-version="3.5.2", + org.eclipse.help.webapp;bundle-version="3.5.2", + org.eclipse.help diff --git a/src/org.gluster.storage.management.console.help/build.properties b/src/org.gluster.storage.management.console.help/build.properties new file mode 100644 index 00000000..9fb97e12 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/build.properties @@ -0,0 +1,8 @@ +bin.includes = plugin.xml,\ + META-INF/,\ + html/,\ + toc.xml,\ + tocconcepts.xml,\ + tocgettingstarted.xml,\ + toctasks.xml,\ + tocreference.xml diff --git a/src/org.gluster.storage.management.console.help/html/concepts/about_gmc.html b/src/org.gluster.storage.management.console.help/html/concepts/about_gmc.html new file mode 100644 index 00000000..ef79927b --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/about_gmc.html @@ -0,0 +1,21 @@ + + + + + + +Main Topic + + + +

    About Gluster Management Console

    +Gluster Management Console is a Java application that provides a single interface to perform the administrative tasks such as create, manage, and maintain your storage cluster.

    You can use the Gluster Management Console to:

    +
      +
    • Create a Gluster Storage Cluster +
    • Expand your cluster +
    • Monitor systems in your cluster +
    • Manage logs +
    + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/concepts/about_gmg.html b/src/org.gluster.storage.management.console.help/html/concepts/about_gmg.html new file mode 100644 index 00000000..34f9c860 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/about_gmg.html @@ -0,0 +1,16 @@ + + + + + + + Main Topic + + + +

    Gluster Management Gateway

    +Gluster Management Gateway provides simple and powerful ReST APIs for managing your Gluster Storage Cluster. It also hosts the Gluster Management Console binaries, which can be launched from a browser using the Java Webstart. Gluster Management Console uses the ReST APIs for performing the administrative tasks on the Gluster Storage Cluster +

    Gluster Management Gateway Architecture + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/concepts/common_terms.html b/src/org.gluster.storage.management.console.help/html/concepts/common_terms.html new file mode 100644 index 00000000..ccf6d218 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/common_terms.html @@ -0,0 +1,50 @@ + + + + + + +Sub Topic 2 + + + +

    Common Cluster Terminologies

    +

    Cluster

    +

    A cluster is a group of linked computers, working together closely thus in many respects forming a single computer.

    +

    Brick +

    Brick is the basic unit of storage, represented by an export directory on a server in the trusted storage pool.

    +

    Network

    +

    A network is a collection of interconnected computers able to +communicate with each other and transfer information back and forth.

    +

    Distributed File Systems

    +

    A file system is a collection of files and the facilities +(programs and commands) that enable users to access the information in +the files. All computing environments have file systems. A distributed +file system takes advantage of the interconnected nature of the network +by storing files on more than one computer in the network and making +them accessible to all of them. In other words, the responsibility for +file storage and delivery is "distributed" among multiple machines +instead of relying on only one.

    +

    File Server Machines

    +

    File server machines store the files in the distributed file +system, and a server process running on the file server machine delivers +and receives files.

    +

    Volumes

    +

    A volume is a conceptual container for a set of related files +that keeps them all together on one file server machine partition. +Volumes can vary in size, but are (by definition) smaller than a +partition. You can maintain maximum system efficiency by moving volumes +to keep the load balanced evenly among the different machines. If a +partition becomes full, the small size of individual volumes makes it +easy to find enough room on other machines for them. Each volume +corresponds logically to a directory in the file tree and keeps +together, on a single partition, all the data that makes up the files in +the directory (including possible subdirectories). By maintaining (for +example) a separate volume for each user's home directory, you keep all +of the user's files together, but separate from those of other users. +This is an administrative convenience that is impossible if the +partition is the smallest unit of storage.

    + + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/concepts/gluster_fs.html b/src/org.gluster.storage.management.console.help/html/concepts/gluster_fs.html new file mode 100644 index 00000000..4efe5f36 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/gluster_fs.html @@ -0,0 +1,19 @@ + + + + + + +Sub Topic + + + +

    Introducing Gluster Filesystem (GlusterFS)

    +GlusterFS is an open source, scale-out file system capable of scaling to several petabytes and handling thousands of clients. GlusterFS assembles storage building blocks, aggregating disk and memory resources and managing data in a single global namespace. GlusterFS is based on a stackable user space design and can deliver exceptional performance for diverse workloads

    The GlusterFS modular architecture allows administrators to stack modules to match user requirements, as needed. For example, administrators can use GlusterFS to quickly configure a standalone server system and later expand the system as their business needs grow.

    +

    Virtualized Cloud Environments

    +

    GlusterFS is designed for today's high-performance, virtualized cloud environments. Unlike traditional data centers, cloud environments require multi-tenancy along with the ability to grow or shrink resources on demand. GlusterFS incorporates cloud capabilities into the core architecture. +

    Every module in GlusterFS is treated as a volume. GlusterFS further adds an elastic volume manager (the glusterd daemon) and a console manager (the gluster command line interface). Using the console manager, administrators can dynamically expand, shrink, rebalance, and migrate volumes, among other operations. The command line interface additionally provides an interactive shell (with auto-completion) along with scripting capabilities suitable for automation.

    +

    GlusterFS Architecture + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/concepts/maintopic.html b/src/org.gluster.storage.management.console.help/html/concepts/maintopic.html new file mode 100644 index 00000000..a476078a --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/maintopic.html @@ -0,0 +1,13 @@ + + + + + + Main Topic + + + +

    Main Topic

    +Please enter your text here. + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/concepts/subtopic.html b/src/org.gluster.storage.management.console.help/html/concepts/subtopic.html new file mode 100644 index 00000000..8a61c501 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/subtopic.html @@ -0,0 +1,13 @@ + + + + + + Sub Topic + + + +

    Sub Topic

    +Please enter your text here. + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/concepts/subtopic2.html b/src/org.gluster.storage.management.console.help/html/concepts/subtopic2.html new file mode 100644 index 00000000..86bcbf9c --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/concepts/subtopic2.html @@ -0,0 +1,13 @@ + + + + + + Sub Topic 2 + + + +

    Sub Topic 2

    +Please enter your text here. + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console.help/html/css/Builder/style.css b/src/org.gluster.storage.management.console.help/html/css/Builder/style.css new file mode 100644 index 00000000..39efe946 --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/css/Builder/style.css @@ -0,0 +1,939 @@ +/* +Theme Name: Builder +Theme URI: http://ithemes.com/ +Description: Builder lets you create custom layouts quickly and easily. +Author: iThemes +Author URI: http://ithemes.com/ +Version: 2.8.0 +Tags: blog, theme options, multiple layouts, multiple color schemes + +Version History + See history.txt +*/ + +/********************************************* + Default font settings and typography. + The font-size percentage is of 16px. (0.75 * 16px = 12px) +*********************************************/ +html { + font-size: 100.01%; +} +body { + font-size: 75%; + line-height: 1.5; + color: #222222; + font-family: Arial, Helvetica, sans-serif; +} +input, select, textarea { + font-family: Arial, Helvetica, sans-serif; +} +pre, code, tt, kbd { + font-family: 'andale mono', 'lucida console', monospace; + font-size: 1em; + line-height: 1.5; +} +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +address, dfn, img, samp, ul, ol, dl { + margin-top: 1.5em; + margin-bottom: 1.5em; +} +a img { + margin: 0; +} + +/********************************************* + Constrain table, image, and input widths +*********************************************/ +table, img, input, textarea, select { + max-width: 100%; + height: auto; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; +} + +/********************************************* + Main Background +*********************************************/ +body { + background: #F7F7F7; +} + +/********************************************* + Universal Link Styles +*********************************************/ +a { + color: #000000; + text-decoration: underline; +} +a:hover { + color: #000000; + text-decoration: underline; +} +a:focus { + color: #000000; +} + +/********************************************* + Headings +*********************************************/ +h1, h2, h3, h4, h5, h6 { + font-weight: bold; + color: #111111; +} +h1 { + font-family: "Arial Black", Arial, Helvetica, Sans-Serif; + font-size: 2em; + line-height: 1.5; + margin-top: 0.75em; + margin-bottom: 0.75em; + letter-spacing: -1px; +} +h2 { + font-size: 1.7em; + line-height: 1.75em; + margin-top: 0.9em; + margin-bottom: 0.9em; +} +h3 { + font-size: 1.5em; + line-height: 1; + margin-top: 1em; + margin-bottom: 1em; +} +h4 { + font-size: 1.2em; + line-height: 1.25em; + margin-top: 1.25em; + margin-bottom: 1.25em; +} +h5, h6 { + font-size: 1em; +} +h6 { + font-style: italic; +} +h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { + margin: 0; +} + +/********************************************* + Container Div +*********************************************/ +.builder-container-outer-wrapper { + background: transparent; + margin: 1.5em auto; + border: none; + display: block; +} + +/********************************************* + Default Module Styling +*********************************************/ +.builder-module { + background: #FFFFFF; + margin-bottom: 1.5em; + border-top: .1em solid #777777; + border-bottom: .1em solid #777777; +} +.builder-module-last { + margin-bottom: 0; +} + +/* Failed attempt #5 at producing full-height sidebars + + This does not work due to a Firefox glitch that causes wide content to + override the width of blocks. + + These rules should be looked at again later in case Firefox fixes this issue. +*/ +/* +.builder-module { + display: table; + table-layout: fixed; +} +.builder-module-block-outer-wrapper { + display: table-cell !important; + float: none !important; + vertical-align: top; +} +*/ + +/********************************************* + All Sidebars +*********************************************/ +.builder-module-sidebar { + background: #DDDDDD; + display: block; + width: 100%; + text-align: left; + margin: 0; + padding: .75em 0; +} +.builder-module-sidebar.right { + margin-right: 0; +} +.builder-module-sidebar.left { + margin-left: 0; +} +.builder-module-sidebar .widget-wrapper { + width: 100%; +} +.builder-module-sidebar .widget { + margin: 0; + padding: .75em 1.5em; + color: #333333; +} +.builder-module-block-outer-wrapper { + overflow: visible !important; +} +.builder-module-block-outer-wrapper .widget-wrapper-left .widget, +.builder-module-block-outer-wrapper .widget-wrapper-middle .widget { + padding-right: .75em; +} +.builder-module-block-outer-wrapper .widget-wrapper-middle .widget, +.builder-module-block-outer-wrapper .widget-wrapper-right .widget { + padding-left: .75em; +} +.builder-module-sidebar h4.widget-title { + color: #333333; + background: none; + font-size: 1.2em; + line-height: 1.25; + padding: 0; + margin: 0 0 1.25em 0; +} +.builder-module-sidebar h4.widget-title a { + color: #333333; +} +.builder-module-sidebar h4.widget-title + * { + margin-top: 0; +} +.builder-module-sidebar .widget *:first-child { + margin-top: 0; +} +.builder-module-sidebar .widget *:last-child { + margin-bottom: 0; +} +.builder-module-sidebar .widget a.rsswidget img { + display: none; +} + +/********************************************* + Navigation Module +*********************************************/ +.builder-module-navigation { + font-size: 1em; + line-height: 2em; + background: #FFFFFF url('images/nav_bg.png') repeat top left; + display: block; + width: 100%; +} +.builder-module-navigation .builder-module-element { + margin: 0 .5em; +} +.builder-module-navigation ul { + float: left; + display: block; + margin: 0; + padding: 0; +} +.builder-module-navigation ul * { + margin: 0; +} +.builder-module-navigation li { + padding: 0; +} +.builder-module-navigation li a, +.builder-module-navigation li.current_page_item li a, +.builder-module-navigation li.current-cat li a { + font-size: 1em; + padding: .4em .6em; + color: #333333; + font-weight: bold; + text-decoration: none; + background: #FFFFFF url('images/nav_bg.png') repeat-x top left; +} +.builder-module-navigation li a:hover { + background: #333333 url('images/nav_bg_hover.jpg') repeat-x top left; + color: #FFFFFF; +} +.builder-module-navigation li.current_page_item a, +.builder-module-navigation li.current-cat a { +} +/* second level stuff */ +.builder-module-navigation li ul { + width: 14em; + border: .1em solid #777777; + border-bottom: 0; +} +.builder-module-navigation li li { + border-bottom: .1em solid #777777; + width: 14em; +} +.builder-module-navigation li li a { + float: none; +} +.builder-module-navigation li li a:hover, +.builder-module-navigation li li a.sfhover { +} +.builder-module-navigation li ul ul { + margin: -2.9em 0 0 14em; +} + +/********************************************* + Widget Bar Module +*********************************************/ +.builder-module-widget-bar { + background: #DDDDDD; +} + +/********************************************* + Footer Module +*********************************************/ +.builder-module-footer { + background: transparent; + border: none; +} +.builder-module-footer .builder-module-element { + text-align: left; + color: #333333; + margin: 0 1.5em; +} +.builder-module-footer .builder-module-element .alignright { + text-align: right; +} +.builder-module-footer .builder-module-element a { + color: #333333; + text-decoration: none; +} +.builder-module-footer .builder-module-element a:hover { + text-decoration: underline; +} + +/********************************************* + Image Module +*********************************************/ +.builder-module-image .builder-module-element { + font-size: 0; +} +.builder-module-image .builder-module-element img { + margin: 0; +} + +/********************************************* + HTML Module +*********************************************/ + +/********************************************* + Content Module +*********************************************/ +.builder-module-content .builder-module-element { + margin: 1.5em; + display: block; + text-align: left; + overflow: hidden; +} +.builder-module-content .post { + margin-bottom: 1.5em; +} + +.post-title, .post-title * { + margin: 0; + padding: 0; +} +.post .thumbnail-wrap { + display: none; +} +.post .date { + /*display: none;*/ + float: left; +} + +.post-title h1, +.post-title h2, +.post-title h3 { + font-family: "Arial Black",Arial,Helvetica,Sans-Serif; + clear: both; + color: #262626; + font-size: 1.9em; + line-height: 1em; + letter-spacing: -1px; + font-weight: bold; + text-transform: uppercase; + margin-bottom: .56em; +} +.post-title a { + text-decoration: none; + color: #262626; + font-size: 1em; +} + +.post .post-meta { + display: block; + /*clear: both;*/ +} +.post .post-meta a { + text-decoration: none; + font-style: italic; +} +.post .post-meta a:hover { + text-decoration: underline; +} +.post .meta-bottom { + display: block; +} +.post .meta-bottom img { + max-width: none; +} + +.post .entry-attachment .attachment { + text-align: center; +} + +.post .edit-entry-link { + margin: 0 0 1.5em 0; + clear: both; +} + +.post-content { + margin-top: 1.5em; + clear: both; +} +.page-title { + font-size: 1.75em; + line-height: 1.7em; + margin-top: 0; + margin-bottom: .875em; +} + +/********************************************* + Style images and galleries + .hentry is used instead of .page or .post + as it applies to all content types +*********************************************/ +.hentry .gallery a, +.hentry .gallery dt, +.hentry .gallery img { + margin: 0; + font-size: 0; + line-height: 0; +} +.hentry .gallery-item { + display: inline-block; + margin: 0 1.5em 1.5em 0; + padding: 5px; + vertical-align: top; + text-align: left; + width: 150px; + border: 1px solid #CFCFCF; + background: #F3F3F3; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} +.hentry .gallery-item img { + border: 0; + margin: 0; + padding: 0; +} +.hentry .gallery-caption { + margin: 0; + padding: 10px 5px 5px 5px; + line-height: 1; +} +.hentry .gallery + * { + margin-top: 0; +} + +.hentry img { + border: 1px solid #CFCFCF; + background: #F3F3F3; + padding: 5px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} +.hentry .alignright { + margin: 0 0 1.5em 1.5em; +} +.hentry .alignleft { + margin: 0 1.5em 1.5em 0; +} +.hentry .aligncenter { + margin: 0 auto 1.5em auto; +} + +.hentry .wp-caption { + border: 1px solid #CFCFCF; + background: #F3F3F3; + padding: 5px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + border-radius: 3px; +} +.hentry .wp-caption img { + border: none; + background: transparent; + padding: 0; +} + +.hentry .wp-caption-text { + text-align: left; + margin: 0; + padding: 10px 5px 5px 5px; + line-height: 1; +} + + +/********************************************* + Post Meta Styles, if needed +*********************************************/ +.meta-top { + clear: both; /* we need this so floats in the post are cleared */ +} + +.meta-bottom { + clear: both; /* we need this so floats in the post are cleared */ + border-top: .1em solid #D7D7D7; + padding-top: 1.4em; + margin-bottom: 3em; +} +.meta-bottom .alignright { + margin-bottom: 1.5em; +} +.meta-bottom .categories, +.meta-bottom .tags { + background: url( 'images/folder.png' ) 0 0 no-repeat; + padding: 0 0 0 1.5em; +} +.meta-bottom .comments { + background: url( 'images/comments.png' ) 0 2px no-repeat; + padding: 0 0 0 1.5em; +} + +.EXIF table { + margin: 1.5em auto; +} +.photometa h4 { + text-align: center; + margin: 0; + padding: 0; +} +.photometa ul { + list-style-type: none; +} + +/********************************************* + Previous/Next Page Navigation +*********************************************/ +.paging { + clear: both; /* To clear any floats */ + margin: 0; + padding: 0; +} + +/********************************************* + Comment Styles +*********************************************/ +#comments { + margin: 3em 0 1.5em 0; + padding: 0; +} +#comments ol.commentlist { + margin: 1.5em 0; + padding: 0; + background: transparent; +} +#comments ul.children { + margin: 0 1.5em; +} +#comments .vcard { + line-height: 1; + margin-bottom: .5em; +} +#comments .vcard .avatar { + display: block; + float: left; + margin: 0 .75em 0 0; +} +#comments .comment-meta { + margin-bottom: 1.5em; +} +#comments li { + clear: both; + list-style-type: none; + margin: 1.5em 0; + border: 1px solid #999999; + overflow: hidden; +} +#comments li .comment-body { + margin: 1.5em; +} +#comments blockquote { + margin: 1.5em; +} + +#respond { + margin-top: 3em; + overflow: visible !important; +} +.comment #respond { + margin: 1.5em 1.5em 1.5em 1.5em; + padding: 0 1.5em 1.5em 1.5em; + border: 1px solid #999999; +} +#respond h3 { + margin-bottom: 0; +} +#respond .cancel-comment-reply a { + margin: 0; + display: block; +} +#commentform label { + margin-left: 1em; +} +#commentform input[type="text"] { + width: 20em; +} +#commentform input, +#commentform textarea { + margin: 0; +} +#commentform #comment { + width: 100%; +} +#commentform .comment-submit-wrapper { + margin-bottom: 0; +} + +/********************************************* + Text elements +*********************************************/ +p { +} +p img.left { + float: left; + margin: 1.5em 1.5em 1.5em 0; + padding: 0; +} +p img.right { + float: right; + margin: 1.5em 0 1.5em 1.5em; +} +blockquote { + background: url('images/blockquote.png') top left no-repeat; + margin: 1.5em; + padding: 0; + color: #666666; + font-style: italic; +} +strong { + font-weight: bold; +} +em, dfn { + font-style: italic; +} +dfn { + font-weight: bold; +} +sup, sub { + height: 0; + line-height: 1.5; + vertical-align: baseline; + position: relative; +} +sup { + bottom: 1ex; +} +sub { + top: .5ex; +} +abbr, acronym { + border-bottom: 1px dotted #666; +} +address { + font-style: italic; +} +del { + color: #666666; +} +pre { + margin: 1.5em 0; + white-space: pre; +} +big { + font-size: 1.2em; + line-height: 1; +} + +/********************************************* + Lists +*********************************************/ +ul, ol { + list-style-position: outside; + margin: 0 0 0 1.4em; + padding: 0; +} +.post-content > ul, +.post-content > ol { + margin-top: 1.5em; + margin-bottom: 1.5em; +} +ol { + margin-left: 20px; + *margin-left: 24px; /* targeted IE 6, 7 fix */ +} +li { + margin: 0; + padding: 0; +} +li > * { + margin-top: 0; +} +li *:last-child { + margin-bottom: 0; +} +li > p + ul { + margin-top: -1.5em; +} +ul { + list-style-type: disc; +} +ol { + list-style-type: decimal; +} +dl { + margin: 0 0 1.5em 0; +} +dl dt { + font-weight: bold; +} +dd { + margin-left: 1.5em; +} +dd + dd { + margin-top: 1.5em; +} + +/********************************************* + Tables +*********************************************/ +table { + margin-bottom: 1.5em; + background: #F3F3F3; +} +table, td, th { + border: 1px solid #CFCFCF; + border-collapse: collapse; +} +th { + font-weight: bold; + line-height: 1.5; + background: #E8E8E8; +} +th, td, caption { + padding: .75em; +} +tr:nth-child(2n) th { + background: #F6F6F6; +} +tr:nth-child(2n) td { + background: #FFFFFF; +} +tfoot { + font-style: italic; +} +caption { + background: #EEEEEE; +} + +/********************************************* + Misc classes +*********************************************/ +.small { + font-size: .8em; + line-height: 1.875; + margin-top: 1.875em; + margin-bottom: 1.875em; +} +.large { + font-size: 1.2em; + line-height: 2.5; + margin-top: 1.25em; + margin-bottom: 1.25em; +} +.hide { + display: none; +} +.quiet { + color: #666666; +} +.loud { + color: #000000; +} +.highlight { + background: #FFFF00; +} +.added { + background: #006600; + color: #FFFFFF; +} +.removed { + background: #990000; + color: #FFFFFF; +} +.first { + margin-left: 0; + padding-left: 0; +} +.last { + margin-right: 0; + padding-right: 0; +} +.top { + margin-top: 0; + padding-top: 0; +} +.bottom { + margin-bottom: 0; + padding-bottom: 0; +} + +/********************************************* + Default styling for forms +*********************************************/ +label { + font-weight: bold; +} +fieldset { + padding: 1.4em; + margin: 0 0 1.5em 0; + border: .1em solid #CCCCCC; +} +legend { + font-weight: bold; + font-size: 1.2em; +} + +/********************************************* + Form fields +*********************************************/ +input[type=text], input[type=password], input.text, input.title, textarea, select { + font-size: 1em; + margin-top: .5em; + margin-bottom: .5em; +} +input[type=text], input[type=password], input.text, input.title, textarea { + background-color: #FFFFFF; + border: 1px solid #999999; + padding: 5px; +} +input[type=text]:focus, input[type=password]:focus, input.text:focus, input.title:focus, textarea:focus { + border-color: #666666; +} +textarea { + width: 30em; + height: 20em; +} +input[type=checkbox], input[type=radio], input.checkbox, input.radio { +/* position: relative; + top: .25em;*/ +} +.search-text-box { + margin-bottom: 0; +} +.search-submit-button { + margin: 0 !important; + padding: .2em .5em; +} + +/********************************************* + Success, notice and error boxes +*********************************************/ +.error, .notice, .success { + padding: .8em; + margin-bottom: 1em; + border: 2px solid #ddd; +} +.error { + background: #FBE3E4; + color: #8a1f11; + border-color: #FBC2C4; +} +.notice { + background: #FFF6BF; + color: #514721; + border-color: #FFD324; +} +.success { + background: #E6EFC2; + color: #264409; + border-color: #C6D880; +} +.error a { + color: #8a1f11; +} +.notice a { + color: #514721; +} +.success a { + color: #264409; +} + +/********************************************* + Widget Styling +*********************************************/ +.widget_rss li { + margin-bottom: 1.5em; +} +.widget_rss .rsswidget { + display: block; + margin: 0; +} +.widget_rss .rss-date { + display: block; + font-style: italic; + margin-bottom: 1.5em; +} +.widget_rss .rssSummary { + margin: 1.5em 0; +} + + +/********************************************* + Social Tabs +*********************************************/ +#social-tags { + position: fixed; + width: 95px; + height: 100%; + right: 0; + left: auto; + margin-right: 0; + margin-left: auto; + padding-top: 10px; + overflow: hidden; +} +#social-tags a { + position: relative; + right: -50px; + margin: 0; +} +#social-tags a:hover { + right: 0; +} + +/********************************************* + The Obligatory WP Styles +*********************************************/ +.alignright { + margin-left: 1.5em; +} +.alignleft { + margin-right: 1.5em; +} +.post img.wp-smiley { + border: none; +} diff --git a/src/org.gluster.storage.management.console.help/html/css/builder-gluster/style.css b/src/org.gluster.storage.management.console.help/html/css/builder-gluster/style.css new file mode 100644 index 00000000..80daf9fb --- /dev/null +++ b/src/org.gluster.storage.management.console.help/html/css/builder-gluster/style.css @@ -0,0 +1,1341 @@ +/* +Theme Name: Gluster - Builder Theme +Description: Gluster Theme based on Builder Framework +Author: iThemes modified by glassCanopy +Template: Builder +*/ + +/* do not remove the import line */ +@import url("../Builder/style.css"); + + +/********************************************* + Default font settings and typography. + The font-size percentage is of 16px. (0.75 * 16px = 12px) +*********************************************/ +body { + font-size: 75%; + line-height: 1.5; + color: #333333; + font-family: Arial,Verdana,Helvetica,sans-serif; +} +input, select, textarea { + font-family: Arial,Verdana,Helvetica,sans-serif; +} + +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +address, dfn, samp, dl, img, ul, ol { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + +/*img, li { filter:alpha(opacity=100)!important;} */ + +a img { + margin: 0; +} + +table, th, td { + border:0; + background-color:none; +} + +ul { + list-style-type:none; +} +/* +html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { + vertical-align: top; +} +*/ + + +.hentry img { + border: 0; + background: none; + padding: 0; + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; +/* width: auto !important; + height: auto !important; */ +} + +p { + font-size:110%; + line-height:1.5em; + margin:0; + padding:0 0 .5em 0; +} + +table, img, input, textarea, select { + max-width: auto; + height: auto; + -moz-box-sizing: none; + -webkit-box-sizing: none; + -ms-box-sizing: none; + box-sizing: none; +} + +.builder-module-block-outer-wrapper .widget-wrapper-left .widget, .builder-module-block-outer-wrapper .widget-wrapper-middle .widget { + padding-right: 0.25em; + padding-left:2em; +} + +/********************************************* + Main Background +*********************************************/ +body { + background: #FFFFFF; +} + +.builder-container-outer-wrapper { + background: url(/wp-content/themes/builder-gluster/images/background-top.png); + background-position:top right; + background-repeat:no-repeat; +} + +#gluster-logo { + display:block; + border:0; + position:absolute; + top:4px; + z-index:900; + width:464px; + height:86px; +} + + +/********************************************* + Universal Link Styles +*********************************************/ +a { + color: #EF7622; + text-decoration: underline; +} +a:hover { + color: #EF7622; + text-decoration: underline; +} + +/********************************************* + Headings +*********************************************/ +h1, h2, h3, h4, h5, h6 { + font-weight: bold; + color: #60A0CF; +} +h1 { + font-family: Arial, Helvetica, Sans-Serif; + font-size: 135%; + line-height: 1.5; + margin-top: 0; + margin-bottom: 0.5em; + letter-spacing: 1px; + color: #284764; +} +h2 { + + color: #60A0CF; + font-family: Verdana,Arial,Helvetica,sans-serif; + font-size: 13px; + margin: 0; + padding: 8px 0 4px 0; + line-height: 1.75em; +} +h3 { + font-size: 1.5em; + line-height: 1; + margin-top: 1em; + margin-bottom: 1em; +} +h4 { + font-size: 1.2em; + line-height: 1.25em; + margin-top: 1.25em; + margin-bottom: 1.25em; +} +h5, h6 { + font-size: 1em; +} +h6 { + font-style: italic; +} +h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { + margin: 0; +} + +.type-page .post-title { +display: none; +} + +.type-post .post-title h1 { + font-family: Arial, Helvetica, Sans-Serif; + font-size: 135%; + line-height: 1.5; + margin-top: 1em; + margin-bottom: 0em; + letter-spacing: 1px; + color: #284764; +} + +.post-title h1 { + font-family: Arial, Helvetica, Sans-Serif; + font-size: 135%; + line-height: 1.5; + margin-top: 0; + margin-bottom: 0.5em; + letter-spacing: 1px; + color: #284764; +} + +.post-content { + clear: both; + margin-top: 1em; +} + +.post-content > ul, .post-content > ol { + margin-bottom: 0.5em; + margin-top: 0.5em; +} + +.builder-module-sidebar h4.widget-title { + background: none repeat scroll 0 0 transparent; + color:#284764; + letter-spacing:1px; + font-size: 1.2em; + line-height: 1.25; + margin: 0 0 1.25em; + padding: 0; + font-weight:normal; +} + +.builder-module-content .builder-module-element { + display: block; + margin: 0 0.25em 1.5em 0.25em; + overflow: hidden; + text-align: left; +} + +.builder-module-sidebar .widget { + color: #333333; + margin: 0; + padding: 0.25em .75em 0 .75em; +} + +.widget-content p { + margin:0; + padding:0; +} + +.widget-it-content { + margin:0; + padding:0; +} + +/********************************************* + All Sidebars +*********************************************/ +.builder-module-sidebar { + background: #FFFFFF; +} + +/* fix footer link underline */ +.builder-module-footer .builder-module-element a { + text-decoration: underline; +} + +/********************************************* + Navigation Module +*********************************************/ +.builder-module-navigation { + font-size: 1em; + line-height: 1.81em; + background: none; + display: block; + width: 100%; + margin-bottom: 0; + +} +.builder-module-navigation .builder-module-element { + margin: 0 .5em; +} +.builder-module-navigation ul { + float: right; + display: block; + margin: 0; + padding: 0; +} +.builder-module-navigation ul * { + margin: 0; +} +.builder-module-navigation li { + padding: 0; +} +.builder-module-navigation li a, +.builder-module-navigation li.current_page_item li a, +.builder-module-navigation li.current-cat li a { + font-size: 1em; + padding: .1em .6em; + color: #ffffff; + font-weight: normal; + text-decoration: none; + background: none; +} +.builder-module-navigation li a:hover { + background: none; + color: #325C84; + text-decoration:none; +} +.builder-module-navigation li.current_page_item a, +.builder-module-navigation li.current-cat a { + color: #325C84; +} + +.builder-module-navigation li.current_page_item a:hover, +.builder-module-navigation li.current-cat a:hover { + color: #ffffff; + background: none; + border:none; +} + +.builder-module { + border:0px solid #ffffff; +background:none; +} +.builder-module-block { +border:0px solid #ffffff; +background:none; +} + +#menu-utility-menu li a { + background:none; + color:#FFFFFF; + font-size:90%; +} + +#menu-utility-menu li a:hover{ + background:none; + color:#FFFFFF; + text-decoration:underline; + font-size:90%; +} + +#menu-top-menu .sub-menu li.menu-item, #menu-top-menu .sub-menu li.menu-item a { +background: #67ABDD; +color:#ffffff; + +} + +#menu-top-menu .sub-menu li.menu-item a:hover, #menu-top-menu .sub-menu li.menu-item a:hover { +background:#67ABDD; +color: #325C84; + +} + +/* second level stuff */ +.builder-module-navigation li ul { + width: 14em; + border:none; + border-bottom: 0; +} +.builder-module-navigation li li { + border-bottom: .1em solid #ffffff; + width: 14em; +} +.builder-module-navigation li li a { + float: none; +} +.builder-module-navigation li li a:hover, +.builder-module-navigation li li a.sfhover { +} +.builder-module-navigation li ul ul { + /* margin: -2.9em 0 0 14em;*/ + margin: -2.05em 0 0 14em; +} +.builder-module-navigation li ul ul li { + border-left: 1px solid #89c8f9; +} + +/* LEFT NAVIGATION */ +#nav_menu-2 ul, +#nav_menu-3 ul, +#nav_menu-4 ul, +#nav_menu-5 ul, +#nav_menu-6 ul, +#nav_menu-7 ul, +#nav_menu-8 ul, +#nav_menu-9 ul, +#nav_menu-10 ul, +#nav_menu-11 ul, +#nav_menu-12 ul, +#nav_menu-13 ul, +#nav_menu-14 ul { + color:#325C84; + list-style-type:disc; + margin-left:1em; + padding-left:0; + +} +#nav_menu-2 li a:link, #nav_menu-2 li a:visited, #nav_menu-2 li a:hover, +#nav_menu-3 li a:link, #nav_menu-3 li a:visited, #nav_menu-3 li a:hover, +#nav_menu-4 li a:link, #nav_menu-4 li a:visited, #nav_menu-4 li a:hover, +#nav_menu-5 li a:link, #nav_menu-5 li a:visited, #nav_menu-5 li a:hover, +#nav_menu-6 li a:link, #nav_menu-6 li a:visited, #nav_menu-6 li a:hover, +#nav_menu-7 li a:link, #nav_menu-7 li a:visited, #nav_menu-7 li a:hover, +#nav_menu-8 li a:link, #nav_menu-8 li a:visited #nav_menu-8 li a:hover, +#nav_menu-9 li a:link, #nav_menu-9 li a:visited #nav_menu-9 li a:hover, +#nav_menu-10 li a:link, #nav_menu-10 li a:visited #nav_menu-10 li a:hover, +#nav_menu-11 li a:link, #nav_menu-11 li a:visited #nav_menu-11 li a:hover, +#nav_menu-12 li a:link, #nav_menu-12 li a:visited, #nav_menu-12 li a:hover, +#nav_menu-13 li a:link, #nav_menu-13 li a:visited, #nav_menu-13 li a:hover, +#nav_menu-14 li a:link, #nav_menu-14 li a:visited, #nav_menu-14 li a:hover { + color: #325C84; + font-weight: normal; + text-decoration: none; +} +#nav_menu-2 li.menu-item a, +#nav_menu-3 li.menu-item a, +#nav_menu-4 li.menu-item a, +#nav_menu-5 li.menu-item a, +#nav_menu-6 li.menu-item a, +#nav_menu-7 li.menu-item a, +#nav_menu-8 li.menu-item a, +#nav_menu-9 li.menu-item a, +#nav_menu-10 li.menu-item a, +#nav_menu-11 li.menu-item a, +#nav_menu-12 li.menu-item a, +#nav_menu-13 li.menu-item a, +#nav_menu-14 li.menu-item a { + color: #325C84; + font-weight: normal; + text-decoration: none; +} +#nav_menu-2 ul li ul.sub-menu, +#nav_menu-3 ul li ul.sub-menu, +#nav_menu-4 ul li ul.sub-menu, +#nav_menu-5 ul li ul.sub-menu, +#nav_menu-6 ul li ul.sub-menu, +#nav_menu-7 ul li ul.sub-menu, +#nav_menu-8 ul li ul.sub-menu, +#nav_menu-9 ul li ul.sub-menu, +#nav_menu-10 ul li ul.sub-menu, +#nav_menu-11 ul li ul.sub-menu, +#nav_menu-12 ul li ul.sub-menu, +#nav_menu-13 ul li ul.sub-menu, +#nav_menu-14 ul li ul.sub-menu { +margin-top:.2em; +list-style-type:none; +} + + + +/* HOME PAGE STYLES */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/add_volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/add_volume.svg new file mode 100644 index 00000000..66307f36 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/add_volume.svg @@ -0,0 +1,3235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/brick.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/brick.svg new file mode 100644 index 00000000..365110f2 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/brick.svg @@ -0,0 +1,652 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + go + lower + down + arrow + pointer + > + + + + + Andreas Nilsson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg new file mode 100644 index 00000000..1fa4e0d4 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/brick_migration.svg @@ -0,0 +1,3697 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/bricks.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/bricks.svg new file mode 100644 index 00000000..39af40f2 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/bricks.svg @@ -0,0 +1,684 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + go + lower + down + arrow + pointer + > + + + + + Andreas Nilsson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/cloud.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/cloud.svg new file mode 100644 index 00000000..d51128ac --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/cloud.svg @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg new file mode 100644 index 00000000..2cc8da4e --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/create-volume-disabled.svg @@ -0,0 +1,3044 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/create-volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/create-volume.svg new file mode 100644 index 00000000..14a5823f --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/create-volume.svg @@ -0,0 +1,3006 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg new file mode 100644 index 00000000..bfe35cce --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk (32-32).svg @@ -0,0 +1,1088 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg new file mode 100644 index 00000000..79f172df --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk (48-48).svg @@ -0,0 +1,2263 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk.svg new file mode 100644 index 00000000..730e9b27 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk.svg @@ -0,0 +1,850 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk_available.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_available.svg new file mode 100644 index 00000000..667535c1 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_available.svg @@ -0,0 +1,1983 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk_error.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_error.svg new file mode 100644 index 00000000..1dda3bbf --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_error.svg @@ -0,0 +1,1991 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg new file mode 100644 index 00000000..5bffaa8f --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_initialisation.svg @@ -0,0 +1,2302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg new file mode 100644 index 00000000..5d5388b2 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_inuse.svg @@ -0,0 +1,1848 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg new file mode 100644 index 00000000..f3cdd2ee --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/disk_uninitialised.svg @@ -0,0 +1,2585 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/download_log.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/download_log.svg new file mode 100644 index 00000000..2ac27d12 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/download_log.svg @@ -0,0 +1,1187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + document + settings + preferences + properties + tweak + + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg new file mode 100644 index 00000000..1ed67ab8 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/high_CPU_usage.svg @@ -0,0 +1,1661 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg new file mode 100644 index 00000000..0ee3b389 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/high_memory_usage.svg @@ -0,0 +1,589 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/log.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/log.svg new file mode 100644 index 00000000..42559766 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/log.svg @@ -0,0 +1,1160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + document + settings + preferences + properties + tweak + + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg new file mode 100644 index 00000000..dc5faa1b --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/low_diskspace.svg @@ -0,0 +1,1790 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + cdrom + media + removable + cd + audio + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg new file mode 100644 index 00000000..fb587339 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/offline-8x8.svg @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/offline.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/offline.svg new file mode 100644 index 00000000..9ee10367 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/offline.svg @@ -0,0 +1,1637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + document + settings + preferences + properties + tweak + + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg new file mode 100644 index 00000000..bf1963df --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick.svg @@ -0,0 +1,4413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg new file mode 100644 index 00000000..5bc030db --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_brick_alert.svg @@ -0,0 +1,713 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + go + lower + down + arrow + pointer + > + + + + + Andreas Nilsson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/offline_server.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_server.svg new file mode 100644 index 00000000..f1f50c40 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_server.svg @@ -0,0 +1,838 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg new file mode 100644 index 00000000..8146a910 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/offline_volume.svg @@ -0,0 +1,3171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg new file mode 100644 index 00000000..8cef7653 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/online-8x8.svg @@ -0,0 +1,246 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/online.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/online.svg new file mode 100644 index 00000000..c25a4232 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/online.svg @@ -0,0 +1,1410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + document + settings + preferences + properties + tweak + + + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/remove-server.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/remove-server.svg new file mode 100644 index 00000000..4280df60 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/remove-server.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-03-08 + + + Jakub Steiner + + + + + workstation + computer + node + client + + + + http://jimmac.musichall.cz/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg new file mode 100644 index 00000000..450b24c8 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/remove_brick.svg @@ -0,0 +1,4483 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg new file mode 100644 index 00000000..83055628 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/remove_volume.svg @@ -0,0 +1,3248 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg new file mode 100644 index 00000000..cd048c2b --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/reset_volume_option.svg @@ -0,0 +1,2946 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/running_task.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/running_task.svg new file mode 100644 index 00000000..d9cf0582 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/running_task.svg @@ -0,0 +1,1498 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-10-10 + + + Andreas Nilsson + + + + + edit + paste + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg new file mode 100644 index 00000000..f3027569 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/star-8x8.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg new file mode 100644 index 00000000..3ef559c7 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/start-volume-disabled.svg @@ -0,0 +1,3350 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/start_volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/start_volume.svg new file mode 100644 index 00000000..5e738c33 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/start_volume.svg @@ -0,0 +1,3312 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg new file mode 100644 index 00000000..315bb09b --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/stop_volume.svg @@ -0,0 +1,3268 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_clear.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_clear.svg new file mode 100644 index 00000000..02b0b919 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_clear.svg @@ -0,0 +1,845 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Lapo Calamandrei + + + + + + media + pause + playback + video + music + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_commit.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_commit.svg new file mode 100644 index 00000000..29817471 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_commit.svg @@ -0,0 +1,310 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + + + go + higher + up + arrow + pointer + > + + + + + Andreas Nilsson + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_pause.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_pause.svg new file mode 100644 index 00000000..ff9b5f3e --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_pause.svg @@ -0,0 +1,821 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Lapo Calamandrei + + + + + + media + pause + playback + video + music + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_paused.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_paused.svg new file mode 100644 index 00000000..9d6930e1 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_paused.svg @@ -0,0 +1,812 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-10-10 + + + Andreas Nilsson + + + + + edit + paste + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_resume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_resume.svg new file mode 100644 index 00000000..2bd8732c --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_resume.svg @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Lapo Calamandrei + + + + + + play + media + music + video + player + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_running.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_running.svg new file mode 100644 index 00000000..fa15b7b8 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_running.svg @@ -0,0 +1,796 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-10-10 + + + Andreas Nilsson + + + + + edit + paste + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg new file mode 100644 index 00000000..ce0bf238 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_status_completed.svg @@ -0,0 +1,577 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-10-10 + + + Andreas Nilsson + + + + + edit + paste + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg new file mode 100644 index 00000000..5fb8b116 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_status_error.svg @@ -0,0 +1,654 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-10-10 + + + Andreas Nilsson + + + + + edit + paste + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_stop.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_stop.svg new file mode 100644 index 00000000..07227fd4 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_stop.svg @@ -0,0 +1,748 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Lapo Calamandrei + + + + + + media + stop + playback + video + music + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg new file mode 100644 index 00000000..d900f03f --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/task_stopped.svg @@ -0,0 +1,784 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 2005-10-10 + + + Andreas Nilsson + + + + + edit + paste + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg new file mode 100644 index 00000000..995fb90b --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/utilities-terminal.svg @@ -0,0 +1,500 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Terminal + 2005-10-15 + + + Andreas Nilsson + + + + + terminal + emulator + term + command line + + + + + + Jakub Steiner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg new file mode 100644 index 00000000..565f6dad --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/view-refresh.svg @@ -0,0 +1,393 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + View Refresh + + + reload + refresh + view + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/volume.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/volume.svg new file mode 100644 index 00000000..b5e50a46 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/volume.svg @@ -0,0 +1,2917 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/volume_option.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/volume_option.svg new file mode 100644 index 00000000..3fb4a928 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/volume_option.svg @@ -0,0 +1,2875 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg new file mode 100644 index 00000000..78fdc384 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/volume_rebalance.svg @@ -0,0 +1,3713 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/icons/tango/scalable/volumes.svg b/src/org.gluster.storage.management.console/icons/tango/scalable/volumes.svg new file mode 100644 index 00000000..3c99b006 --- /dev/null +++ b/src/org.gluster.storage.management.console/icons/tango/scalable/volumes.svg @@ -0,0 +1,2949 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/images/gauge.png b/src/org.gluster.storage.management.console/images/gauge.png new file mode 100644 index 00000000..6f5764ea Binary files /dev/null and b/src/org.gluster.storage.management.console/images/gauge.png differ diff --git a/src/org.gluster.storage.management.console/images/gauge_small.png b/src/org.gluster.storage.management.console/images/gauge_small.png new file mode 100644 index 00000000..71e424fe Binary files /dev/null and b/src/org.gluster.storage.management.console/images/gauge_small.png differ diff --git a/src/org.gluster.storage.management.console/images/gluster-about.png b/src/org.gluster.storage.management.console/images/gluster-about.png new file mode 100644 index 00000000..9518b2b2 Binary files /dev/null and b/src/org.gluster.storage.management.console/images/gluster-about.png differ diff --git a/src/org.gluster.storage.management.console/images/login-screen-with-text.psd b/src/org.gluster.storage.management.console/images/login-screen-with-text.psd new file mode 100644 index 00000000..f6e7ab35 Binary files /dev/null and b/src/org.gluster.storage.management.console/images/login-screen-with-text.psd differ diff --git a/src/org.gluster.storage.management.console/images/login-screen.psd b/src/org.gluster.storage.management.console/images/login-screen.psd new file mode 100644 index 00000000..a9bfc27e Binary files /dev/null and b/src/org.gluster.storage.management.console/images/login-screen.psd differ diff --git a/src/org.gluster.storage.management.console/images/splash-dialog.bmp b/src/org.gluster.storage.management.console/images/splash-dialog.bmp new file mode 100644 index 00000000..932032fb Binary files /dev/null and b/src/org.gluster.storage.management.console/images/splash-dialog.bmp differ diff --git a/src/org.gluster.storage.management.console/images/splash-screen.psd b/src/org.gluster.storage.management.console/images/splash-screen.psd new file mode 100644 index 00000000..43544f41 Binary files /dev/null and b/src/org.gluster.storage.management.console/images/splash-screen.psd differ diff --git a/src/org.gluster.storage.management.console/plugin.properties b/src/org.gluster.storage.management.console/plugin.properties new file mode 100644 index 00000000..5393818f --- /dev/null +++ b/src/org.gluster.storage.management.console/plugin.properties @@ -0,0 +1,7 @@ +aboutText=Gluster Management Console\n\ +Version: 1.0.0\n\n\ +Copyright (c) 2011 Gluster, Inc.\n\ +Visit http://www.gluster.com/\n\n\ +This product includes software developed by the\n\ +Eclipse Foundation http://eclipse.org/\n\ +RichClientGUI http://www.richclientgui.com/ \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/plugin.xml b/src/org.gluster.storage.management.console/plugin.xml new file mode 100644 index 00000000..f80c72e1 --- /dev/null +++ b/src/org.gluster.storage.management.console/plugin.xml @@ -0,0 +1,1658 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.console/preferences.ini b/src/org.gluster.storage.management.console/preferences.ini new file mode 100644 index 00000000..5a4c6846 --- /dev/null +++ b/src/org.gluster.storage.management.console/preferences.ini @@ -0,0 +1,3 @@ +org.eclipse.ui/KEY_CONFIGURATION_ID = org.gluster.storage.management.console.KeyConfig +org.eclipse.help.base/help_home=/org.gluster.storage.management.console.help/html/help_home.html +IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP=true \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/splash.bmp b/src/org.gluster.storage.management.console/splash.bmp new file mode 100644 index 00000000..d4510414 Binary files /dev/null and b/src/org.gluster.storage.management.console/splash.bmp differ diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Activator.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Activator.java new file mode 100644 index 00000000..0edd74cf --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Activator.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.gluster.storage.management.console"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + public void editorOpened() { + System.err.println("Editor opened!"); + } + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/AlertsManager.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/AlertsManager.java new file mode 100644 index 00000000..c44dea09 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/AlertsManager.java @@ -0,0 +1,216 @@ +/** + * AlertsManager.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Alert.ALERT_TYPES; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + + +public class AlertsManager { + private List alerts = new ArrayList(); + private Cluster cluster; + + private Double CPU_USAGE_THRESHOLD; + private Double MEMORY_USAGE_THRESHOLD; + private Double DISK_SPACE_USAGE_THRESHOLD; + + public AlertsManager(Cluster cluster) { + this.cluster = cluster; + + IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + CPU_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD); + MEMORY_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD); + DISK_SPACE_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD); + } + + public List getAlerts() { + return alerts; + } + + public Alert getAlert(String id) { + for (Alert alert : getAlerts()) { + if (alert.getId().equals(id)) { + return alert; + } + } + return null; + } + + public void addAlert(Alert alert) { + alerts.add(alert); + } + + public void addAlerts(List alerts) { + this.alerts.addAll(alerts); + } + + public void setAlerts(List alerts) { + this.alerts = alerts; + } + + public Boolean removeAlert(String id) { + for (int i = 0; i < alerts.size(); i++) { + if (alerts.get(i).getId().equals(id)) { + return (alerts.remove(i) != null); + } + } + return false; + } + + public void clearAll() { + this.alerts.clear(); + } + + public void buildAlerts() { + clearAll(); + addAlerts(getServerAlerts()); + addAlerts(getVolumeAlerts()); + } + + private List getServerAlerts() { + List serverAlerts = new ArrayList(); + Alert offlineServerAlert = getOfflineServerAlerts(); + if (offlineServerAlert != null) { + serverAlerts.add(offlineServerAlert); // Single alert for offline servers + } + + for (GlusterServer server : cluster.getServers()) { + // To check off line servers + // if (server.getStatus() == SERVER_STATUS.OFFLINE) { + // serverAlerts.add(new Alert(ALERT_TYPES.OFFLINE_SERVERS_ALERT, server.getName(), "Server [" + // + server.getName() + "] is Offline")); + // continue; // If the server is Offline skip other Alert builds + // } + + // To check High CPU usage + if (server.getCpuUsage() >= CPU_USAGE_THRESHOLD) { + serverAlerts.add(new Alert(ALERT_TYPES.CPU_USAGE_ALERT, server.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.CPU_USAGE_ALERT.ordinal()] + " [" + + NumberUtil.formatNumber(server.getCpuUsage()) + "] in server [" + server.getName() + + "]")); + } + + // To check High Memory usage + Double memoryUtilized = server.getMemoryInUse() / server.getTotalMemory() * 100d; + if (memoryUtilized >= MEMORY_USAGE_THRESHOLD) { + serverAlerts.add(new Alert(ALERT_TYPES.MEMORY_USAGE_ALERT, server.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.MEMORY_USAGE_ALERT.ordinal()] + " [" + + NumberUtil.formatNumber(memoryUtilized) + "%] in server [" + server.getName() + + "]")); + } + + // To Check low disk space + serverAlerts.addAll(getLowDiskAlerts(server)); + } + return serverAlerts; + } + + private Alert getOfflineServerAlerts() { + List offlineServers = new ArrayList(); + for (GlusterServer server : cluster.getServers()) { + if (server.getStatus() == SERVER_STATUS.OFFLINE) { + offlineServers.add(server.getName()); + } + } + if (offlineServers.size() > 0) { + return new Alert(ALERT_TYPES.OFFLINE_SERVERS_ALERT, "Server", + Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_SERVERS_ALERT.ordinal()] + "(s) " + + offlineServers.toString()); + } + return null; + } + + private List getLowDiskAlerts(GlusterServer server) { + List diskAlerts = new ArrayList(); + boolean hasPartition; + Double deviceSpaceUsed; + for (Disk disk : server.getDisks()) { + hasPartition = false; + for (Partition partition : disk.getPartitions()) { + hasPartition = true; + deviceSpaceUsed = partition.getSpaceInUse() / partition.getSpace() * 100d; + if (deviceSpaceUsed >= DISK_SPACE_USAGE_THRESHOLD) { + diskAlerts.add(new Alert(ALERT_TYPES.DISK_USAGE_ALERT, partition.getQualifiedName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [" + + NumberUtil.formatNumber(deviceSpaceUsed) + "% used] in disk [" + + partition.getQualifiedName() + "]")); + } + } + if (hasPartition) { + continue; // Do not check disk usage + } + + // If it is disk + deviceSpaceUsed = disk.getSpaceInUse() / disk.getSpace() * 100d; + if (deviceSpaceUsed >= DISK_SPACE_USAGE_THRESHOLD) { + diskAlerts.add(new Alert(ALERT_TYPES.DISK_USAGE_ALERT, disk.getQualifiedName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [" + + NumberUtil.formatNumber(deviceSpaceUsed) + "% used] in [" + + disk.getQualifiedName() + "]")); + } + } + return diskAlerts; + } + + private List getVolumeAlerts() { + List volumeAlerts = new ArrayList(); + List offlineBricks = new ArrayList(); + + for (Volume volume : cluster.getVolumes()) { + if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { + volumeAlerts.add(new Alert(ALERT_TYPES.OFFLINE_VOLUME_ALERT, volume.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_ALERT.ordinal()] + " [" + volume.getName() + + "]")); + continue; + } + + // To check off line bricks + offlineBricks = new ArrayList(); + for (Brick brick : volume.getBricks()) { + if (brick.getStatus() == BRICK_STATUS.OFFLINE) { + offlineBricks.add(brick.getQualifiedName()); + } + } + // One offline brick alert per volume + if (offlineBricks.size() > 0) { + volumeAlerts.add(new Alert(ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT, volume.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT.ordinal()] + " " + + offlineBricks.toString() + " in volume " + volume.getName())); + } + } + return volumeAlerts; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Application.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Application.java new file mode 100644 index 00000000..f5a88479 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Application.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.jface.action.IStatusLineManager; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; +import org.gluster.storage.management.console.dialogs.LoginDialog; +import org.gluster.storage.management.core.model.Entity; + + +/** + * This class controls all aspects of the application's execution + */ +public class Application implements IApplication { + + public static final String PLUGIN_ID = "org.gluster.storage.management.console"; + private static Application instance; + private List entityListeners = Collections.synchronizedList(new ArrayList()); + private IStatusLineManager statusLineManager; + + public Application() { + instance = this; + } + + public static Application getApplication() { + return instance; + } + + public IStatusLineManager getStatusLineManager() { + return statusLineManager; + } + + public void setStatusLineManager(IStatusLineManager statusLineManager) { + this.statusLineManager = statusLineManager; + } + + private boolean login() { + LoginDialog loginDialog = new LoginDialog(new Shell(Display.getDefault())); + return (loginDialog.open() == Window.OK); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) { + setSystemProperties(); + + Display display = PlatformUI.createDisplay(); + + final boolean[] loginSuccess = new boolean[1]; + Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { + public void run() { + loginSuccess[0] = login(); + } + }); + + if (!loginSuccess[0]) { + return IApplication.EXIT_OK; + } + try { + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + private void setSystemProperties() { + // TODO: Trying this to avoid the webstart authentication dialog + // to be tested, and removed if this doesn't work. + System.setProperty("javaws.cfg.jauthenticator", "none"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + if (!PlatformUI.isWorkbenchRunning()) + return; + final IWorkbench workbench = PlatformUI.getWorkbench(); + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } + + public void addEntityListener(IEntityListener listener) { + entityListeners.add(listener); + } + + public void entityChanged(Entity entity, String[] paremeters) { + for (IEntityListener listener : entityListeners) { + listener.entityChanged(entity, paremeters); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationActionBarAdvisor.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationActionBarAdvisor.java new file mode 100644 index 00000000..df608eea --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationActionBarAdvisor.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.ICoolBarManager; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.swt.SWT; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.gluster.storage.management.console.utils.GUIHelper; + + +/** + * An action bar advisor is responsible for creating, adding, and disposing of the actions added to a workbench window. + * Each window will be populated with new actions. + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + private IWorkbenchWindow window; + /* + * Actions - important to allocate these only in makeActions, and then use them in the fill methods. This ensures + * that the actions aren't recreated when fillActionBars is called with FILL_PROXY. + */ + private IWorkbenchAction exitAction; + private IWorkbenchAction aboutAction; + private IWorkbenchAction helpContentsAction; + + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(final IWorkbenchWindow window) { + this.window = window; + /* + * Creates the actions and registers them. Registering is needed to ensure that key bindings work. The + * corresponding commands keybindings are defined in the plugin.xml file. Registering also provides automatic + * disposal of the actions when the window is closed. + */ + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + + aboutAction = ActionFactory.ABOUT.create(window); + aboutAction.setText("&About"); + aboutAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.HELP_16x16)); + register(aboutAction); + + helpContentsAction = ActionFactory.HELP_CONTENTS.create(window); + helpContentsAction.setText("&Management Console Help"); + helpContentsAction.setAccelerator(SWT.F1); + //helpContentsAction.setImageDescriptor(newImage) + register(helpContentsAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + // File + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + fileMenu.add(new Separator()); + fileMenu.add(exitAction); + + // Help + MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); + helpMenu.add(helpContentsAction); + helpMenu.add(aboutAction); + + menuBar.add(fileMenu); + // Add a group marker indicating where action set menus will appear. + // All action sets from plugin.xml will get added here + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(helpMenu); + } + + protected void fillCoolBar(ICoolBarManager coolBar) { + // All our actions are added to toolbar through the extension point org.eclipse.ui.actionSets + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java new file mode 100644 index 00000000..e0fa5539 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.ui.application.IWorkbenchConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; +import org.gluster.storage.management.console.jobs.DataSyncJob; +import org.gluster.storage.management.console.preferences.PreferenceConstants; + + +/** + * This workbench advisor creates the window advisor, and specifies + * the perspective id for the initial window. + */ +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + private Job syncJob; + private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + private long JOB_INTERVAL = preferenceStore.getLong(PreferenceConstants.P_DATA_SYNC_INTERVAL) * 1000; + private IPropertyChangeListener propertyChangeListener; + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return Perspective.ID; + } + + @Override + public void initialize(IWorkbenchConfigurer configurer) { + super.initialize(configurer); + configurer.setSaveAndRestore(false); // we don't need save/restore as of now + + createPropertyChangeListener(); + preferenceStore.addPropertyChangeListener(propertyChangeListener); + } + + private void createPropertyChangeListener() { + propertyChangeListener = new IPropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent event) { + if(event.getProperty().equals(PreferenceConstants.P_DATA_SYNC_INTERVAL)) { + JOB_INTERVAL = (Integer)event.getNewValue() * 1000L; + } + } + }; + } + + @Override + public void postStartup() { + super.postStartup(); + setupBackgroundJobs(); + } + + private void setupBackgroundJobs() { + syncJob = new DataSyncJob("Retrieving Management Info"); + syncJob.schedule(JOB_INTERVAL); + syncJob.addJobChangeListener(new JobChangeAdapter() { + @Override + public void done(IJobChangeEvent event) { + super.done(event); + + // job done. schedule again after the pre-defined interval + syncJob.schedule(JOB_INTERVAL); + } + }); + } + + @Override + public boolean preShutdown() { + return syncJob.cancel(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 00000000..41043b27 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; +import org.gluster.storage.management.console.utils.GUIHelper; + + +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + private final static int DEFAULT_WIDTH = 1024; + private final static int DEFAULT_HEIGHT = 768; + private final GUIHelper guiHelper = GUIHelper.getInstance(); + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + @Override + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + @Override + public void preWindowOpen() { + super.preWindowOpen(); + + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT)); + configurer.setShowCoolBar(true); + configurer.setShowStatusLine(true); + configurer.setShowMenuBar(true); + configurer.setShowProgressIndicator(true); // shows progress indicator in status bar + } + + @Override + public void postWindowCreate() { + super.postWindowCreate(); + guiHelper.centerShellInScreen(getWindowConfigurer().getWindow().getShell()); + getWindowConfigurer().getWindow().getShell().setMaximized(true); + Application.getApplication().setStatusLineManager( + getWindowConfigurer().getActionBarConfigurer().getStatusLineManager()); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/BrickTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/BrickTableLabelProvider.java new file mode 100644 index 00000000..80b4c812 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/BrickTableLabelProvider.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.swt.graphics.Image; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.BricksPage.BRICK_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.console.views.pages.DisksPage.DISK_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + + +public class BrickTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + + if (!(element instanceof Brick)) { + return null; + } + + Brick brick = (Brick) element; + if (columnIndex == DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + BRICK_STATUS status = brick.getStatus(); + + switch(status) { + case ONLINE: + return guiHelper.getImage(IImageKeys.BRICK_ONLINE_16x16); + case OFFLINE: + return guiHelper.getImage(IImageKeys.BRICK_OFFLINE_16x16); + } + } + return null; + } + + private String getDeviceFreeSpace(Device device) { + if (device != null && device.isReady() && device.getFreeSpace() != null) { + return NumberUtil.formatNumber((device.getFreeSpace() / 1024)); + } else { + return "NA"; + } + } + + private String getDeviceCapacity(Device device) { + if (device != null && device.isReady() && device.getSpace() != null && device.getSpace() != 0.0) { + return NumberUtil.formatNumber((device.getSpace() / 1024)); + } else { + return "NA"; + } + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Brick)) { + return null; + } + + Brick brick = (Brick) element; + Device device = GlusterDataModelManager.getInstance().getDeviceForBrickDir(brick); + return (columnIndex == BRICK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? brick.getServerName() + : columnIndex == BRICK_TABLE_COLUMN_INDICES.BRICK.ordinal() ? brick.getBrickDirectory() + : columnIndex == BRICK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? getDeviceFreeSpace(device) + : columnIndex == BRICK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? getDeviceCapacity(device) + : columnIndex == BRICK_TABLE_COLUMN_INDICES.STATUS.ordinal() ? brick.getStatusStr() : "Invalid"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ConsoleConstants.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ConsoleConstants.java new file mode 100644 index 00000000..ced7f9e7 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ConsoleConstants.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +/** + * + */ +public class ConsoleConstants { + public static final String CONSOLE_TITLE = "Gluster Management Console"; + public static final String TERMINAL_VIEW_ID = "org.eclipse.tm.terminal.view.TerminalView"; + public static final String PROPERTY_AUTO_LOGIN_PASSWORD = "auto.login.password"; + public static final String PROPERTY_AUTO_CLUSTER_NAME = "auto.cluster.name"; +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/DeviceTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/DeviceTableLabelProvider.java new file mode 100644 index 00000000..6b6f7669 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/DeviceTableLabelProvider.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.resource.FontRegistry; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + + +public class DeviceTableLabelProvider extends LabelProvider implements ITableLabelProvider { + + private GUIHelper guiHelper = GUIHelper.getInstance(); + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + public enum DEVICE_COLUMN_INDICES { + DISK, PARTITION, FREE_SPACE, SPACE_IN_USE, STATUS + }; + + FontRegistry registry = new FontRegistry(); + + public DeviceTableLabelProvider() { + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof Device)) { + return null; + } + + Device device = (Device) element; + if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { + DEVICE_STATUS status = device.getStatus(); + + if (status == null) { + if (element instanceof Partition) { + if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { + status = device.getStatus(); + } + } + } + + if (status == null) { + return null; + } + + if(element instanceof Disk && ((Disk)element).hasPartitions()) { + // disk has partitions. so don't show status image at disk level. + return null; + } + + switch (status) { + case INITIALIZED: + if(modelManager.isDeviceUsed(device)) { + return guiHelper.getImage(IImageKeys.DISK_IN_USE_16x16); + } else { + return guiHelper.getImage(IImageKeys.DISK_AVAILABLE_16x16); + } + case IO_ERROR: + return guiHelper.getImage(IImageKeys.IO_ERROR_16x16); + case UNINITIALIZED: + return guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED_16x16); + case INITIALIZING: + return guiHelper.getImage(IImageKeys.DISK_INITIALIZING_16x16); + default: + throw new GlusterRuntimeException("Invalid disk status [" + status + "]"); + } + } + + return null; + } + + @Override + public String getText(Object element) { + return super.getText(element); + } + + private String getDeviceFreeSpace(Device device) { + if (device.hasErrors() || device.isUninitialized()) { + return "NA"; + } else { + return NumberUtil.formatNumber((device.getFreeSpace() / 1024)); + } + } + + private String getTotalDeviceSpace(Device device) { + if (device.hasErrors() || device.isUninitialized()) { + return "NA"; + } else { + return NumberUtil.formatNumber((device.getSpace() / 1024)); + } + } + + public String getColumnText(Object element, int columnIndex) { + + if (element == null) { + return ""; + } + + Device device = (Device) element; + if (columnIndex == DEVICE_COLUMN_INDICES.DISK.ordinal()) { + // show value in "disk" column only if it's a disk + if (device instanceof Disk) { + return device.getQualifiedName(); + } else { + return ""; + } + } + + if(element instanceof Disk && ((Disk)element).hasPartitions()) { + // disk has partitions. so don't show any other details + return ""; + } + + if (columnIndex == DEVICE_COLUMN_INDICES.FREE_SPACE.ordinal()) { + return "" + getDeviceFreeSpace(device); + } else if (columnIndex == DEVICE_COLUMN_INDICES.SPACE_IN_USE.ordinal()) { + return "" + getTotalDeviceSpace(device); + } else if (columnIndex == DEVICE_COLUMN_INDICES.PARTITION.ordinal()) { + if (device instanceof Partition) { + return device.getQualifiedName(); + } else { + return ""; + } + } else if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { + if(device.isUninitialized()) { + return ""; + } + if(modelManager.isDeviceUsed(device)) { + return "In Use"; + } else { + return device.getStatusStr(); + } + } else { + return ""; + } + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/EntityGroupContentProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/EntityGroupContentProvider.java new file mode 100644 index 00000000..ca83d520 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/EntityGroupContentProvider.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.gluster.storage.management.core.model.EntityGroup; + + +public class EntityGroupContentProvider implements + IStructuredContentProvider { + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + + } + + @SuppressWarnings("rawtypes") + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof EntityGroup) { + return ((EntityGroup) inputElement).getChildren().toArray(); + } + return null; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterDataModelManager.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterDataModelManager.java new file mode 100644 index 00000000..94d3c59c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterDataModelManager.java @@ -0,0 +1,1036 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.gluster.storage.management.client.DiscoveredServersClient; +import org.gluster.storage.management.client.GlusterServersClient; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterDataModel; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeOptionInfo; +import org.gluster.storage.management.core.model.Alert.ALERT_TYPES; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.model.Device.DEVICE_TYPE; +import org.gluster.storage.management.core.model.Event.EVENT_TYPE; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; +import org.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; + + +public class GlusterDataModelManager { + private static GlusterDataModelManager instance = new GlusterDataModelManager(); + private GlusterDataModel model; + private String securityToken; + private List listeners = new ArrayList(); + private List volumeOptionsInfo; + private String clusterName; + private static Boolean syncInProgress = false; + private static final GlusterLogger logger = GlusterLogger.getInstance();; + + private GlusterDataModelManager() { + } + + public String getSecurityToken() { + return securityToken; + } + + public void setSecurityToken(String securityToken) { + this.securityToken = securityToken; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public String getClusterName() { + return clusterName; + } + + public GlusterDataModel getModel() { + return model; + } + + public static GlusterDataModelManager getInstance() { + return instance; + } + + public void initializeModel(String clusterName, IProgressMonitor monitor) { + setClusterName(clusterName); + + model = fetchData(monitor); + } + + private GlusterDataModel fetchData(IProgressMonitor monitor) { + GlusterDataModel model = fetchModel(monitor); + + initializeAlerts(model.getCluster()); + initializeVolumeOptionsInfo(model.getCluster()); + + return model; + } + + public void refreshVolumeData(Volume oldVolume) { + VolumesClient volumeClient = new VolumesClient(); + Volume newVolume = volumeClient.getVolume(oldVolume.getName()); + if(!oldVolume.equals(newVolume)) { + volumeChanged(oldVolume, newVolume); + } + } + + private boolean isCancelled(IProgressMonitor monitor) { + if(monitor.isCanceled()) { + monitor.setTaskName("Data sync cancelled!"); + monitor.done(); + return true; + } else { + return false; + } + } + + public GlusterDataModel fetchModel(IProgressMonitor monitor) { + synchronized (syncInProgress) { + if(syncInProgress) { + logger.info("Previous data sync is still running. Skipping this one."); + return null; + } + syncInProgress = true; + } + + try { + logger.info("Starting data sync"); + GlusterDataModel model = new GlusterDataModel("Gluster Data Model"); + Cluster cluster = new Cluster(clusterName, model); + model.addCluster(cluster); + + monitor.beginTask("Data Sync", 6); + + monitor.setTaskName("Syncing servers..."); + initializeGlusterServers(cluster); + monitor.worked(1); + if(isCancelled(monitor)) { + return model; + } + + monitor.setTaskName("Syncing volumes..."); + initializeVolumes(cluster); + monitor.worked(1); + if(isCancelled(monitor)) { + return model; + } + + monitor.setTaskName("Syncing discovered servers..."); + initializeAutoDiscoveredServers(cluster); + monitor.worked(1); + if(isCancelled(monitor)) { + return model; + } + + monitor.setTaskName("Syncing tasks..."); + initializeTasks(cluster); + monitor.worked(1); + if(isCancelled(monitor)) { + return model; + } + + monitor.setTaskName("Syncing aggregated CPU stats..."); + initializeAggregatedCpuStats(cluster); + monitor.worked(1); + if(isCancelled(monitor)) { + return model; + } + + monitor.setTaskName("Syncing aggregated Network stats..."); + initializeAggregatedNetworkStats(cluster); + monitor.worked(1); + + monitor.done(); + return model; + } finally { + syncInProgress = false; + } + } + + public void updateModel(GlusterDataModel model) { + updateVolumes(model); + updateGlusterServers(model); + updateDiscoveredServers(model); + updateTasks(model); + updateAlerts(model); + updateServerStatistics(model); + } + + private void updateServerStatistics(GlusterDataModel newModel) { + model.getCluster().setAggregatedCpuStats(newModel.getCluster().getAggregatedCpuStats()); + model.getCluster().setAggregatedNetworkStats(newModel.getCluster().getAggregatedNetworkStats()); + for(ClusterListener listener : listeners) { + listener.aggregatedStatsChanged(); + } + } + + private void updateAlerts(GlusterDataModel newModel) { + model.getCluster().getAlerts().clear(); + + // generate alerts for "newModel" + initializeAlerts(newModel.getCluster()); + + // set the new alerts on "model" + model.getCluster().setAlerts(newModel.getCluster().getAlerts()); + + // fire event "alertsGenerated" + alertsGenerated(); + } + + private void updateTasks(GlusterDataModel newModel) { + List oldTasks = model.getCluster().getTaskInfoList(); + List newTasks = newModel.getCluster().getTaskInfoList(); + + Set addedTasks = GlusterCoreUtil.getAddedEntities(oldTasks, newTasks, true); + for(TaskInfo task : addedTasks) { + addTask(task); + } + + Set removedTasks = GlusterCoreUtil.getAddedEntities(newTasks, oldTasks, true); + for(TaskInfo task : removedTasks) { + removeTask(task); + } + + Map modifiedTasks = GlusterCoreUtil.getModifiedEntities(oldTasks, newTasks); + for(Entry entry : modifiedTasks.entrySet()) { + TaskInfo modifiedTask = entry.getKey(); + modifiedTask.copyFrom(entry.getValue()); + updateTask(modifiedTask); + } + } + + private void updateDiscoveredServers(GlusterDataModel newModel) { + List oldServers = model.getCluster().getAutoDiscoveredServers(); + List newServers = newModel.getCluster().getAutoDiscoveredServers(); + + Set addedServers = GlusterCoreUtil.getAddedEntities(oldServers, newServers, true); + for (Server addedServer : addedServers) { + addDiscoveredServer(addedServer); + } + + Set removedServers = GlusterCoreUtil.getAddedEntities(newServers, oldServers, true); + for (Server removedServer : removedServers) { + removeDiscoveredServer(removedServer); + } + + Map modifiedServers = GlusterCoreUtil.getModifiedEntities(oldServers, newServers); + for(Entry entry : modifiedServers.entrySet()) { + discoveredServerChanged(entry.getKey(), entry.getValue()); + } + } + + private void updateGlusterServers(GlusterDataModel newModel) { + List oldServers = model.getCluster().getServers(); + List newServers = newModel.getCluster().getServers(); + + Set addedServers = GlusterCoreUtil.getAddedEntities(oldServers, newServers, true); + for (GlusterServer addedServer : addedServers) { + addGlusterServer(addedServer); + } + + Set removedServers = GlusterCoreUtil.getAddedEntities(newServers, oldServers, true); + for (GlusterServer removedServer : removedServers) { + removeGlusterServer(removedServer); + } + + Map modifiedServers = GlusterCoreUtil.getModifiedEntities(oldServers, newServers); + for(Entry entry : modifiedServers.entrySet()) { + glusterServerChanged(entry.getKey(), entry.getValue()); + } + } + + public void glusterServerChanged(GlusterServer oldServer, GlusterServer newServer) { + oldServer.copyFrom(newServer); + for (ClusterListener listener : listeners) { + listener.serverChanged(oldServer, new Event(EVENT_TYPE.GLUSTER_SERVER_CHANGED, newServer)); + } + + updateDisks(oldServer, oldServer.getDisks(), newServer.getDisks()); + } + + private void updateDisks(Server server, List oldDisks, List newDisks) { + Set addedDisks = GlusterCoreUtil.getAddedEntities(oldDisks, newDisks, false); + addDisks(server, addedDisks); + + Set removedDisks = GlusterCoreUtil.getAddedEntities(newDisks, oldDisks, false); + removeDisks(server, removedDisks); + + Map modifiedDisks = GlusterCoreUtil.getModifiedEntities(oldDisks, newDisks); + disksChanged(server, modifiedDisks); + } + + private void disksChanged(Server server, Map modifiedDisks) { + if(modifiedDisks.size() == 0) { + return; + } + + for (Entry entry : modifiedDisks.entrySet()) { + entry.getKey().copyFrom(entry.getValue()); + } + for (ClusterListener listener : listeners) { + if (server instanceof GlusterServer) { + listener.serverChanged((GlusterServer) server, new Event(EVENT_TYPE.DEVICES_CHANGED, modifiedDisks)); + } else { + listener.discoveredServerChanged(server, new Event(EVENT_TYPE.DEVICES_CHANGED, modifiedDisks)); + } + } + } + + public void updateDeviceStatus(String serverName, String deviceName, DEVICE_STATUS status) { + GlusterServer server = model.getCluster().getServer(serverName); + Device device = getDeviceDetails(server, deviceName); + if (device != null) { + device.setStatus(status); + device.setType(DEVICE_TYPE.DATA); + for (ClusterListener listener : listeners) { + listener.serverChanged(server, new Event(EVENT_TYPE.DEVICES_CHANGED, device)); + } + } + } + + private Device getDeviceDetails(GlusterServer server, String deviceName) { + for (Disk disk : server.getDisks()) { + if (disk.hasPartitions()) { + for (Partition partition : disk.getPartitions()) { + if (partition.getName().equals(deviceName)) { + return partition; + } + } + } else { + if (disk.getName().equals(deviceName)) { + return (Device) disk; + } + } + } + return null; + } + + public void addDisks(Server server, Set disks) { + if(disks.size() == 0) { + return; + } + + server.addDisks(disks); + for (ClusterListener listener : listeners) { + if(server instanceof GlusterServer) { + listener.serverChanged((GlusterServer)server, new Event(EVENT_TYPE.DEVICES_ADDED, disks)); + } else { + listener.discoveredServerChanged(server, new Event(EVENT_TYPE.DEVICES_ADDED, disks)); + } + } + } + + public void removeDisks(Server server, Set disks) { + if(disks.size() == 0) { + return; + } + + for(Disk disk : disks) { + server.removeDisk(disk); + } + + for (ClusterListener listener : listeners) { + if(server instanceof GlusterServer) { + listener.serverChanged((GlusterServer)server, new Event(EVENT_TYPE.DEVICES_REMOVED, disks)); + } else { + listener.discoveredServerChanged(server, new Event(EVENT_TYPE.DEVICES_REMOVED, disks)); + } + } + } + + private void updateVolumes(GlusterDataModel newModel) { + List oldVolumes = model.getCluster().getVolumes(); + List newVolumes = newModel.getCluster().getVolumes(); + + Set addedVolumes = GlusterCoreUtil.getAddedEntities(oldVolumes, newVolumes, false); + for (Volume addedVolume : addedVolumes) { + addVolume(addedVolume); + } + + Set removedVolumes = GlusterCoreUtil.getAddedEntities(newVolumes, oldVolumes, false); + for (Volume removedVolume : removedVolumes) { + deleteVolume(removedVolume); + } + + Map modifiedVolumes = GlusterCoreUtil.getModifiedEntities(oldVolumes, newVolumes); + for(Entry entry : modifiedVolumes.entrySet()) { + volumeChanged(entry.getKey(), entry.getValue()); + } + } + + public void volumeChanged(Volume oldVolume, Volume newVolume) { + oldVolume.copyFrom(newVolume); + + if (oldVolume.getStatus() != newVolume.getStatus()) { + updateVolumeStatusAlert(newVolume, newVolume.getStatus()); + } + + for (ClusterListener listener : listeners) { + listener.volumeChanged(oldVolume, new Event(EVENT_TYPE.VOLUME_CHANGED, newVolume)); + } + updateBricks(oldVolume, oldVolume.getBricks(), newVolume.getBricks()); + } + + private void updateBricks(Volume volume, List oldBricks, List newBricks) { + Set addedBricks = GlusterCoreUtil.getAddedEntities(oldBricks, newBricks, false); + addBricks(volume, addedBricks); + + Set removedBricks = GlusterCoreUtil.getAddedEntities(newBricks, oldBricks, false); + removeBricks(volume, removedBricks); + + Map modifiedBricks = GlusterCoreUtil.getModifiedEntities(oldBricks, newBricks); + bricksChanged(volume, modifiedBricks); + } + + public void bricksChanged(Volume volume, Map modifiedBricks) { + if(modifiedBricks.size() == 0) { + return; + } + + for(Entry entry : modifiedBricks.entrySet()) { + entry.getKey().copyFrom(entry.getValue()); + } + + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_CHANGED, modifiedBricks)); + } + } + + private void initializeGlusterServers(Cluster cluster) { + cluster.setServers(new GlusterServersClient(cluster.getName()).getServers()); + } + + private void initializeAutoDiscoveredServers(Cluster cluster) { + cluster.setAutoDiscoveredServers(new DiscoveredServersClient(cluster.getName()).getDiscoveredServerDetails()); + } + + private void initializeVolumes(Cluster cluster) { + VolumesClient volumeClient = new VolumesClient(cluster.getName()); + cluster.setVolumes(volumeClient.getAllVolumes()); + } + + private void initializeVolumeOptionsInfo(Cluster cluster) { + if(cluster.getServers().isEmpty()) { + // cluster is empty. we won't be able to fetch the volume options information. + return; + } + this.volumeOptionsInfo = new VolumesClient(clusterName).getVolumeOptionsInfo(); + } + + private void initializeTasks(Cluster cluster) { + List taskInfoList = new TasksClient(cluster.getName()).getAllTasks(); + //List taskInfoList = getDummyTasks(); + cluster.setTaskInfoList(taskInfoList); + } + + public void initializeAggregatedCpuStats(Cluster cluster) { + IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD); + + cluster.setAggregatedCpuStats(new GlusterServersClient().getAggregatedCpuStats(cpuStatsPeriod)); + } + + public void initializeAggregatedNetworkStats(Cluster cluster) { + IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD); + + cluster.setAggregatedNetworkStats(new GlusterServersClient().getAggregatedNetworkStats(networkStatsPeriod)); + } + + private List getDummyTasks() { + List taskInfoList = new ArrayList(); + + // Task #1 + TaskInfo taskInfo = new TaskInfo(); + taskInfo.setType(TASK_TYPE.BRICK_MIGRATE); + taskInfo.setName("Migrate Brick-music"); + taskInfo.setPauseSupported(true); + taskInfo.setStopSupported(true); + taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_PAUSE, ""))); + + taskInfo.getStatus().setMessage("Paused"); + taskInfo.setDescription("Migrate Brick on volume [Movies] from /export/adb/music to /export/sdc/music."); + taskInfoList.add(taskInfo); + + // Task #2 + taskInfo = new TaskInfo(); + taskInfo.setType(TASK_TYPE.DISK_FORMAT); + taskInfo.setName("Initialize disk [KVM-GVSA1:sdc]"); + taskInfo.setPauseSupported(false); + taskInfo.setStopSupported(false); + taskInfo.setStatus( new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, ""))); + taskInfo.getStatus().setMessage("Format completed 80% ..."); + taskInfo.setDescription("Formatting disk [KVM-GVSA1:sdc]"); + taskInfoList.add(taskInfo); + + // Task #2 + taskInfo = new TaskInfo(); + taskInfo.setType(TASK_TYPE.VOLUME_REBALANCE); + taskInfo.setName("Rebalance volume [songs]"); + taskInfo.setPauseSupported(false); + taskInfo.setStopSupported(false); + taskInfo.setStatus( new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, ""))); + taskInfo.getStatus().setMessage("Rebalance step1: layout fix in progress"); + taskInfo.setDescription("Rebalance volume [songs]"); + taskInfoList.add(taskInfo); + + return taskInfoList; + } + + private List getDummyAlerts(Cluster cluster) { + List alerts = new ArrayList(); + for (Server server : cluster.getServers()) { + if (alerts.size() == 0) { + alerts.add(new Alert(ALERT_TYPES.CPU_USAGE_ALERT, server.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.CPU_USAGE_ALERT.ordinal()] + " [93.42 %] in " + + server.getName())); + continue; + } + + if (alerts.size() == 1) { + alerts.add(new Alert(ALERT_TYPES.MEMORY_USAGE_ALERT, server.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.MEMORY_USAGE_ALERT.ordinal()] + " [91.83 %] in " + + server.getName())); + continue; + } + + if (alerts.size() == 2) { + alerts.add(new Alert(ALERT_TYPES.OFFLINE_SERVERS_ALERT, server.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_SERVERS_ALERT.ordinal()] + " " + server.getName())); + continue; + } + + if (alerts.size() == 3) { + alerts.add(new Alert(ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT, "songs", + Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT.ordinal()] + + " [KVM-GVSA4:/export/hdb4/songs] in volume [songs]")); + continue; + } + } + return alerts; + } + + public void initializeAlerts(Cluster cluster) { + AlertsManager alertsManager = new AlertsManager(cluster); + alertsManager.buildAlerts(); + cluster.setAlerts( alertsManager.getAlerts() ); + //cluster.setAlerts( getDummyAlerts(cluster) ); + } + + public Volume addVolume(List volumes, String name, Cluster cluster, VOLUME_TYPE volumeType, + TRANSPORT_TYPE transportType, VOLUME_STATUS status) { + Volume volume = new Volume(name, cluster, volumeType, transportType, status); + volumes.add(volume); + + return volume; + } + +// private Device getDevice(String serverName, String deviceName) { +// List allDevices = getReadyDevicesOfAllServers(); +// for (Device device : allDevices) { +// if (device.getServerName().equals(serverName) && device.getName().equals(deviceName)) { +// return device; +// } +// } +// return null; +// } + + /* + * @param diskName (sda) + * + * @return The device object for given device name + */ + public Device getDeviceDetails(String deviceName) { + List allDevices = getReadyDevicesOfAllServers(); + for (Device device : allDevices) { + if (device.getName().equals(deviceName)) { + return device; + } + } + return null; + } + + + public Device getDeviceForBrickDir(Brick brick) { + Device brickDevice = null; + for (Device device : getReadyDevicesOfServer(brick.getServerName(), new ArrayList())) { + if (brick.getBrickDirectory().startsWith( device.getMountPoint() )) { + if (brickDevice == null || device.getMountPoint().length() > brickDevice.getMountPoint().length()) { + brickDevice = device; + } + } + } + return brickDevice; + } + + public List getDevicesOfVolume(Volume volume) { + Device device = null; + List volumeDevices = new ArrayList(); + for (Brick brick : volume.getBricks()) { + // device = getDevice(brick.getServerName(), brick.getDeviceName()); + device = getDeviceForBrickDir(brick); + if (device != null) { + volumeDevices.add(device); + } + } + return volumeDevices; + } + + public List getReadyDevicesOfAllServers() { + return getReadyDevicesOfAllServersExcluding(new ArrayList()); + } + + public List getReadyDevicesOfAllServersExcluding(List excludeDevices) { + List devices = new ArrayList(); + + for (Server server : model.getCluster().getServers()) { + devices.addAll( getReadyDevicesOfServer(server.getName(), excludeDevices) ); + } + return devices; + } + + public List getReadyDevicesOfServer(String serverName, List excludeDevices) { + List devices = new ArrayList(); + GlusterServer server = model.getCluster().getServer(serverName); + if (server == null || !server.isOnline()) { + return devices; + } + for (Disk disk : server.getDisks()) { + if (disk.hasPartitions()) { + for (Partition partition : disk.getPartitions()) { + if (partition.isReady() && !excludeDevices.contains(partition)) { + devices.add(partition); + } + } + } else if (disk.isReady() && !excludeDevices.contains(disk)) { + devices.add(disk); + } + } + return devices; + } + + public void addClusterListener(ClusterListener listener) { + listeners.add(listener); + } + + public void removeClusterListener(ClusterListener listener) { + listeners.remove(listener); + } + + public void addGlusterServer(GlusterServer server) { + Cluster cluster = model.getCluster(); + cluster.addServer(server); + + for (ClusterListener listener : listeners) { + listener.serverAdded(server); + } + + removeDiscoveredServer(server.getName()); + } + + public void addDiscoveredServer(Server server) { + Cluster cluster = model.getCluster(); + cluster.addDiscoveredServer(server); + + for (ClusterListener listener : listeners) { + listener.discoveredServerAdded(server); + } + } + + public void discoveredServerChanged(Server oldServer, Server newServer) { + oldServer.copyFrom(newServer); + for (ClusterListener listener : listeners) { + listener.discoveredServerChanged(oldServer, new Event(EVENT_TYPE.DISCOVERED_SERVER_CHANGED, newServer)); + } + updateDisks(oldServer, oldServer.getDisks(), newServer.getDisks()); + } + + public void removeDiscoveredServer(String serverName) { + Cluster cluster = model.getCluster(); + // TODO: Move auto-discovered servers outside the cluster + for(Server server : cluster.getAutoDiscoveredServers()) { + if(server.getName().toUpperCase().equals(serverName.toUpperCase())) { + removeDiscoveredServer(server); + return; + } + } + } + + public void removeDiscoveredServer(Server server) { + Cluster cluster = model.getCluster(); + cluster.removeDiscoveredServer(server); + + for (ClusterListener listener : listeners) { + listener.discoveredServerRemoved(server); + } + } + + public void removeGlusterServer(GlusterServer server) { + Cluster cluster = model.getCluster(); + cluster.removeServer(server); + + // can't use an iterator here. The method AbstractList.Itr#next checks for concurrent modification. + // Since listeners can end up creating new views, which add themselves as listeners, the listeners + // list can be concurrently modified which can result in an exception while using iterator. + // Hence we use List#get instead of the iterator + for(int i = 0; i < listeners.size(); i++) { + ClusterListener listener = listeners.get(i); + listener.serverRemoved(server); + } + + // add it to discovered servers list if it is online server + if (server.isOnline()) { + Server removedServer = new Server(); + removedServer.copyFrom(server); + removedServer.addDisks(server.getDisks()); + addDiscoveredServer(removedServer); + } + } + + public void deleteVolume(Volume volume) { + Cluster cluster = model.getCluster(); + cluster.deleteVolume(volume); + + // can't use an iterator here. The method AbstractList.Itr#next checks for concurrent modification. + // Since listeners can end up creating new views, which add themselves as listeners, the listeners + // list can be concurrently modified which can result in an exception while using iterator. + // Hence we use List#get instead of the iterator + for(int i = 0; i < listeners.size(); i++) { + ClusterListener listener = listeners.get(i); + listener.volumeDeleted(volume); + } + } + + public void updateVolumeStatus(Volume volume, VOLUME_STATUS newStatus) { + volume.setStatus(newStatus); + updateVolumeStatusAlert(volume, newStatus); + + if(newStatus == VOLUME_STATUS.OFFLINE) { + // mark as bricks also as offline + for(Brick brick : volume.getBricks()) { + brick.setStatus(BRICK_STATUS.OFFLINE); + } + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_CHANGED, volume.getBricks())); + } + } else { + Volume newVolume = new VolumesClient().getVolume(volume.getName()); //Getting latest brick info + updateBricks(volume, volume.getBricks(), newVolume.getBricks()); + } + + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_STATUS_CHANGED, newStatus)); + } + } + + private void updateVolumeStatusAlert(Volume volume, VOLUME_STATUS newStatus) { + Alert alert = null; + if (newStatus == VOLUME_STATUS.OFFLINE) { + alert = createOfflineVolumeAlert(volume); + for (ClusterListener listener : listeners) { + listener.alertCreated(alert); + } + } else { + alert = removeOfflineVolumeAlert(volume); + for (ClusterListener listener : listeners) { + listener.alertRemoved(alert); + } + } + } + + private Alert createOfflineVolumeAlert(Volume volume) { + Alert alert = new Alert(ALERT_TYPES.OFFLINE_VOLUME_ALERT, volume.getName(), + Alert.ALERT_TYPE_STR[ALERT_TYPES.OFFLINE_VOLUME_ALERT.ordinal()] + " [" + volume.getName() + "]"); + getModel().getCluster().addAlert(alert); + return alert; + } + + private Alert removeOfflineVolumeAlert(Volume volume) { + List clusterAlerts = getModel().getCluster().getAlerts(); + Alert removedAlert = null; + for (Alert alert : clusterAlerts) { + if (alert.getType().equals(ALERT_TYPES.OFFLINE_VOLUME_ALERT) + && alert.getReference().equals(volume.getName())) { + removedAlert = alert; + clusterAlerts.remove(alert); + break; + } + } + return removedAlert; + } + + public void resetVolumeOptions(Volume volume) { + volume.getOptions().clear(); + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTIONS_RESET, null)); + } + } + + public void addBricks(Volume volume, Set bricks) { + if(bricks.size() == 0) { + return; + } + + volume.addBricks(bricks); + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_ADDED, bricks)); + } + updateVolumeTypeByBricks(volume); + } + + public void removeBricks(Volume volume, Set bricks) { + if(bricks.size() == 0) { + return; + } + + // Remove the bricks from the volume object + for (Brick brick : bricks) { + volume.removeBrick(brick); + } + + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.BRICKS_REMOVED, bricks)); + } + updateVolumeTypeByBricks(volume); + } + + private void updateVolumeTypeByBricks(Volume volume) { + VOLUME_TYPE volumeType = volume.getVolumeType(); + if (volumeType.equals(VOLUME_TYPE.REPLICATE) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE)) { + if (volume.getBricks().size() > volume.getReplicaCount()) { + volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); + } else { + volume.setVolumeType(VOLUME_TYPE.REPLICATE); + } + } else if (volumeType.equals(VOLUME_TYPE.STRIPE) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE)) { + if (volume.getBricks().size() > volume.getStripeCount()) { + volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); + } else { + volume.setVolumeType(VOLUME_TYPE.STRIPE); + } + } + } + + public void setVolumeOption(Volume volume, String optionKey, String optionValue) { + volume.setOption(optionKey, optionValue); + for (ClusterListener listener : listeners) { + listener.volumeChanged(volume, new Event(EVENT_TYPE.VOLUME_OPTION_SET, optionKey)); + } + } + + public void addVolume(Volume volume) { + Cluster cluster = model.getCluster(); + cluster.addVolume(volume); + + for (ClusterListener listener : listeners) { + listener.volumeCreated(volume); + } + } + + public void addTask(TaskInfo taskInfo) { + Cluster cluster = model.getCluster(); + // To avoid duplicate task, Remove if already exist + TaskInfo existingTaskInfo = getTask(taskInfo.getName()); + if (getTask(taskInfo.getName()) != null) { + removeTask(existingTaskInfo); + } + cluster.addTaskInfo(taskInfo); + for (ClusterListener listener : listeners) { + listener.taskAdded(taskInfo); + } + } + + public TaskInfo getTask(String taskId) { + for (TaskInfo taskInfo: model.getCluster().getTaskInfoList()) { + if (taskInfo.getName().equals(taskId)) { + return taskInfo; + } + } + return null; + } + + public TaskInfo getTaskByReference(String reference) { + for (TaskInfo taskInfo: model.getCluster().getTaskInfoList()) { + if (taskInfo.getReference().equals(reference)) { + return taskInfo; + } + } + return null; + } + + // Updating the Task + public void updateTask(TaskInfo taskInfo) { + for (ClusterListener listener : listeners) { + listener.taskUpdated(taskInfo); + } + } + + public void removeTask(TaskInfo taskInfo) { + model.getCluster().removeTaskInfo(taskInfo); + for (ClusterListener listener : listeners) { + listener.taskRemoved(taskInfo); + } + } + + public void alertsGenerated() { + for (ClusterListener listener : listeners) { + listener.alertsGenerated(); + } + } + + public List getVolumeOptionsInfo() { + if(volumeOptionsInfo == null || volumeOptionsInfo.isEmpty()) { + initializeVolumeOptionsInfo(getModel().getCluster()); + } + return volumeOptionsInfo; + } + + public VolumeOptionInfo getVolumeOptionInfo(String optionKey) { + for (VolumeOptionInfo info : volumeOptionsInfo) { + if (info.getName().equals(optionKey)) { + return info; + } + } + throw new GlusterRuntimeException("Invalid option key [" + optionKey + + "] passed to GlusterDataModelManager#getVolumeOptionInfo"); + } + + public String getVolumeOptionDefaultValue(String optionKey) { + return getVolumeOptionInfo(optionKey).getDefaultValue(); + } + + public String getVolumeOptionDesc(String optionKey) { + return getVolumeOptionInfo(optionKey).getDescription(); + } + + public void setAccessControlList(Volume volume, String accessControlList) { + setVolumeOption(volume, Volume.OPTION_AUTH_ALLOW, accessControlList); + } + + public void setNfsEnabled(Volume volume, boolean enabled) { + setVolumeOption(volume, Volume.OPTION_NFS_DISABLE, (enabled) ? GlusterConstants.OFF : GlusterConstants.ON); + } + + public void setCifsConfig(Volume volume, boolean enabled, List cifsUsers) { + if (enabled) { + volume.enableCifs(); + volume.setCifsUsers(cifsUsers); + } else { + volume.disableCifs(); + } + } + + public Server getGlusterServer(String serverName) { + for (Server server : model.getCluster().getServers()) { + if (server.getName().equalsIgnoreCase(serverName)) { + return server; + } + } + return null; + } + + private Boolean isDeviceUsed(Volume volume, Device device) { + Device brickDevice = null; + for (Brick brick : volume.getBricks()) { + brickDevice = getDeviceForBrickDir(brick); + if (brickDevice != null && device.getName().equals(brickDevice.getName()) + && device.getServerName().equalsIgnoreCase(brick.getServerName())) { + return true; + } + } + return false; + } + + public boolean isDeviceUsed(Device device) { + if (device.getStatus() == DEVICE_STATUS.INITIALIZED) { + for (Volume volume : model.getCluster().getVolumes()) { + if (isDeviceUsed(volume, device)) { + return true; + } + } + } + return false; + } + + public List getVolumesOfServer(String serverName) { + List volumeNames = new ArrayList(); + Cluster cluster = model.getCluster(); + for (Volume volume : cluster.getVolumes()) { + for (Brick brick : volume.getBricks()) { + if (serverName.equalsIgnoreCase(brick.getServerName())) { + volumeNames.add(volume.getName()); + break; + } + } + } + return volumeNames; + } + + public List getOfflineServers() { + List offlineServers = new ArrayList(); + for(GlusterServer server : model.getCluster().getServers()) { + if (!server.isOnline()) { + offlineServers.add(server.getName()); + } + } + return offlineServers; + } + + public List getCifsEnabledVolumeNames(List selectedVolumes) { + List cifsVolumes = new ArrayList(); + for(Volume volume : selectedVolumes) { + if (volume.isCifsEnable()) { + cifsVolumes.add(volume.getName()); + } + } + return cifsVolumes; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterServerTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterServerTableLabelProvider.java new file mode 100644 index 00000000..3ea52446 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/GlusterServerTableLabelProvider.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.swt.graphics.Image; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.GlusterServersPage.GLUSTER_SERVER_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + + +public class GlusterServerTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof GlusterServer)) { + return null; + } + + GlusterServer server = (GlusterServer) element; + if(columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + SERVER_STATUS status = server.getStatus(); + if(status == SERVER_STATUS.ONLINE) { + return guiHelper.getImage(IImageKeys.STATUS_ONLINE_16x16); + } else { + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16); + } + } + + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof GlusterServer)) { + return null; + } + + GlusterServer server = (GlusterServer) element; + + if (server.getStatus() == SERVER_STATUS.OFFLINE + && columnIndex != GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() + && columnIndex != GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + return "NA"; + } + + return (columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() ? server.getName() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS.ordinal() ? server.getStatusStr() + // : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.PREFERRED_NETWORK.ordinal() ? server.getPreferredNetworkInterface().getName() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS.ordinal() ? "" + server.getNumOfCPUs() + //: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE.ordinal() ? "" + server.getCpuUsage() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY.ordinal() ? "" + NumberUtil.formatNumber((server.getTotalMemory() / 1024)) + //: columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE.ordinal() ? "" + server.getMemoryInUse() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_FREE_SPACE.ordinal() ? NumberUtil.formatNumber((server.getFreeDiskSpace() / 1024)) + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES.ordinal() ? server.getIpAddressesAsString() + : columnIndex == GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE.ordinal() ? NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)) + : "Invalid"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ICommandIds.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ICommandIds.java new file mode 100644 index 00000000..c7772a03 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ICommandIds.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +/** + * Interface defining the application's command IDs. + * Key bindings can be defined for specific commands. + * To associate an action with a command, use IAction.setActionDefinitionId(commandId). + * + * @see org.eclipse.jface.action.IAction#setActionDefinitionId(String) + */ +public interface ICommandIds { + + public static final String CMD_OPEN = "org.gluster.storage.management.console.open"; + public static final String CMD_OPEN_MESSAGE = "org.gluster.storage.management.console.openMessage"; + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IEntityListener.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IEntityListener.java new file mode 100644 index 00000000..e9e837ba --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IEntityListener.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.gluster.storage.management.core.model.Entity; + +/** + * Any class that is interested in changes to entities in application scope should implement this interface and register + * with the application using {@link Application#addEntityListener(IEntityListener)} + * + * @author root + * + */ +public interface IEntityListener { + /** + * This method is called whenever any attribute of an entity in application scope changes + * @param entity Entity that has changed + * @param paremeters List of attribute names that have changed. This can be null. + */ + public void entityChanged(Entity entity, String[] paremeters); +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IImageKeys.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IImageKeys.java new file mode 100644 index 00000000..eba97ccc --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/IImageKeys.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +public interface IImageKeys { + + + public static final String CLUSTER_16x16 = "icons/tango/16x16/cluster.png"; + + public static final String VOLUMES_16x16 = "icons/tango/16x16/volumes.png"; + public static final String VOLUME_16x16 = "icons/tango/16x16/volume.png"; + public static final String CREATE_VOLUME_32x32 = "icons/tango/32x32/create-volume.png"; + public static final String START_VOLUME_32x32 = "icons/tango/32x32/start-volume.png"; + public static final String STOP_VOLUME_32x32 = "icons/tango/32x32/stop-volume.png"; + public static final String RESET_VOLUME_OPTIONS_32x32 = "icons/tango/32x32/reset-volume-option.png"; + public static final String VOLUME_OPTIONS_16x16 = "icons/tango/16x16/volume-options.png"; + public static final String CREATE_VOLUME_48x48 = "icons/tango/48x48/create-volume.png"; + public static final String REMOVE_VOLUME_32x32 = "icons/tango/32x32/remove-volume.png"; + public static final String VOLUME_REBALANCE_32x32 = "icons/tango/32x32/volume-rebalance.png"; + public static final String VOLUME_REBALANCE_22x22 = "icons/tango/22x22/volume-rebalance.png"; + public static final String BRICK_MIGRATE_32x32 = "icons/tango/32x32/migrate-brick.png"; + public static final String BRICK_MIGRATE_22x22 = "icons/tango/22x22/migrate-brick.png"; + public static final String ADD_BRICK_32x32 = "icons/tango/32x32/add-brick.png"; + public static final String REMOVE_BRICK_32x32 = "icons/tango/32x32/remove-brick.png"; + public static final String BRICK_OFFLINE_22x22 = "icons/tango/22x22/offline-brick.png"; + public static final String BRICKS_16x16 = "icons/tango/16x16/bricks.png"; + public static final String BRICK_ONLINE_16x16 = "icons/tango/16x16/online-brick.png"; + public static final String BRICK_OFFLINE_16x16 = "icons/tango/16x16/offline-brick.png"; + public static final String VOLUME_OFFLINE_22x22 = "icons/tango/22x22/offline-volume.png"; + + public static final String SERVERS_16x16 = "icons/tango/16x16/servers.png"; + public static final String SERVER_16x16 = "icons/tango/16x16/server.png"; + public static final String SERVER_WARNING_22x22 = "icons/tango/22x22/server-warning.png"; + public static final String MEMORY_USAGE_ALERT_22x22 = "icons/tango/22x22/high-memory-usage.png"; + public static final String SERVER_OFFLINE_22x22 = "icons/tango/22x22/offline-server.png"; + public static final String ADD_SERVER_32x32 = "icons/tango/32x32/add-server.png"; + public static final String ADD_SERVER_48x48 = "icons/tango/48x48/add-server.png"; + public static final String REMOVE_SERVER_32x32 = "icons/tango/32x32/remove-server.png"; + + public static final String DISK_16x16 = "icons/tango/16x16/disk.png"; + public static final String DISKS_16x16 = "icons/tango/16x16/disk.png"; + public static final String DISK_UNINITIALIZED_16x16 = "icons/tango/16x16/disk-uninitialized.png"; + public static final String IO_ERROR_16x16 = "icons/tango/16x16/disk-error.png"; + public static final String DISK_AVAILABLE_16x16 = "icons/tango/16x16/disk-available.png"; + public static final String DISK_INITIALIZING_16x16 = "icons/tango/16x16/disk-initialisation.png"; + public static final String DISK_INITIALIZING_22x22 = "icons/tango/22x22/disk-initialisation.png"; + public static final String DISK_IN_USE_16x16 = "icons/tango/16x16/disk-inuse.png"; + public static final String LOW_DISK_SPACE_22x22 = "icons/tango/22x22/low-diskspace.png"; + + public static final String STATUS_OFFLINE_16x16 = "icons/tango/16x16/status-offline.png"; + public static final String STATUS_ONLINE_16x16 = "icons/tango/16x16/status-online.png"; + + public static final String HELP_16x16 = "icons/tango/16x16/question.png"; + public static final String SEARCH_22x22 = "icons/tango/22x22/system-search.png"; + public static final String ARROW_UP_16x16 = "icons/tango/16x16/arrow-up.png"; + public static final String ARROW_DOWN_16x16 = "icons/tango/16x16/arrow-down.png"; + + public static final String DOWNLOAD_LOG_32x32 = "icons/tango/32x32/download-log.png"; + + + public static final String PAUSE_TASK_32x32 = "icons/tango/32x32/pause.png"; + public static final String RESUME_TASK_32x32 = "icons/tango/32x32/start.png"; + public static final String STOP_TASK_32x32 = "icons/tango/32x32/stop.png"; + public static final String CLEAR_TASK_32x32 = "icons/tango/32x32/clear-task.png"; + public static final String COMMIT_TASK_32x32 = "icons/tango/32x32/commit-task.png"; + public static final String PAUSE_TASK_16x16 = "icons/tango/16x16/pause.png"; + public static final String RESUME_TASK_16x16 = "icons/tango/16x16/start.png"; + public static final String STOP_TASK_16x16 = "icons/tango/16x16/stop.png"; + public static final String CLEAR_TASK_16x16 = "icons/tango/16x16/close_task.png"; + public static final String COMPLETED_TASK_16x16 = "icons/tango/16x16/task-completed.png"; + + public static final String OVERLAY_OFFLINE_8x8 = "icons/tango/8x8/offline.png"; + public static final String OVERLAY_ONLINE_8x8 = "icons/tango/8x8/online.png"; + public static final String OVERLAY_STAR_8x8 = "icons/tango/8x8/star.png"; + + public static final String SPLASH_IMAGE = "splash.bmp"; + public static final String DIALOG_SPLASH_IMAGE = "images/splash-dialog.bmp"; + + public static final String GAUGE_SMALL = "images/gauge_small.png"; + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java new file mode 100644 index 00000000..53610c3b --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/NetworkInterfaceTableLabelProvider.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + + +import org.gluster.storage.management.console.views.GlusterServerSummaryView.NETWORK_INTERFACE_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.NetworkInterface; + + +public class NetworkInterfaceTableLabelProvider extends TableLabelProviderAdapter { + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof NetworkInterface)) { + return null; + } + + NetworkInterface networkInterface = (NetworkInterface) element; + String columnText = (columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.INTERFACE.ordinal() ? networkInterface.getName() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.MODEL.ordinal() ? networkInterface.getModel() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.SPEED.ordinal() ? networkInterface.getSpeed() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.IP_ADDRESS.ordinal() ? networkInterface.getIpAddress() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.NETMASK.ordinal() ? networkInterface.getNetMask() + : columnIndex == NETWORK_INTERFACE_TABLE_COLUMN_INDICES.GATEWAY.ordinal() ? networkInterface.getDefaultGateway() + : "Invalid"); + return ((columnText == null || columnText.trim().equals("")) ? CoreConstants.NA : columnText); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Perspective.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Perspective.java new file mode 100644 index 00000000..e2a867ed --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/Perspective.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class Perspective implements IPerspectiveFactory { + + /** + * The ID of the perspective as specified in the extension. + */ + public static final String ID = Perspective.class.getName(); + + public void createInitialLayout(IPageLayout layout) { + layout.setEditorAreaVisible(false); + //layout.addStandaloneView(ClusterView.ID, false, IPageLayout.LEFT, 0.30f, layout.getEditorArea()); + //layout.addStandaloneView(DetailsView.ID, false, IPageLayout.RIGHT, 0.70f, layout.getEditorArea()); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerDiskTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerDiskTableLabelProvider.java new file mode 100644 index 00000000..aa4c23c4 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerDiskTableLabelProvider.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.swt.graphics.Image; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.ServerDisksPage.SERVER_DISK_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + +import static org.gluster.storage.management.console.DeviceTableLabelProvider.DEVICE_COLUMN_INDICES; + + +public class ServerDiskTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + private GlusterDataModelManager glusterDataModelManager = GlusterDataModelManager.getInstance(); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof Device)) { + return null; + } + + Device device = (Device) element; + if (columnIndex == SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + DEVICE_STATUS status = device.getStatus(); + + if (status == null) { + return null; + } + + if(element instanceof Disk && ((Disk)element).hasPartitions()) { + // disk has partitions. so don't show status image at disk level. + return null; + } + + switch (status) { + case INITIALIZED: + if(glusterDataModelManager.isDeviceUsed(device)) { + return guiHelper.getImage(IImageKeys.DISK_IN_USE_16x16); + } else { + return guiHelper.getImage(IImageKeys.DISK_AVAILABLE_16x16); + } + case IO_ERROR: + return guiHelper.getImage(IImageKeys.IO_ERROR_16x16); + case UNINITIALIZED: + return guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED_16x16); + case INITIALIZING: + return guiHelper.getImage(IImageKeys.DISK_INITIALIZING_16x16); + default: + throw new GlusterRuntimeException("Invalid disk status [" + status + "]"); + } + } + + return null; + } + + private String getDeviceFreeSpace(Device device) { + if (device.hasErrors() || device.isUninitialized()) { + return "NA"; + } else { + return NumberUtil.formatNumber((device.getFreeSpace() / 1024)); + } + } + + private String getTotalDeviceSpace(Device device) { + if (device.hasErrors() || device.isUninitialized()) { + return "NA"; + } else { + return NumberUtil.formatNumber((device.getSpace() / 1024)); + } + } + + public String getColumnText(Object element, int columnIndex) { + Device device = (Device) element; + if (columnIndex == DEVICE_COLUMN_INDICES.DISK.ordinal()) { + // show value in "disk" column only if it's a disk + if (device instanceof Disk) { + return device.getName(); + } else { + return ""; + } + } + + if(element instanceof Disk && ((Disk)element).hasPartitions()) { + // disk has partitions. so don't show any other details + return ""; + } + + if (columnIndex == DEVICE_COLUMN_INDICES.FREE_SPACE.ordinal()) { + return "" + getDeviceFreeSpace(device); + } else if (columnIndex == DEVICE_COLUMN_INDICES.SPACE_IN_USE.ordinal()) { + return "" + getTotalDeviceSpace(device); + } else if (columnIndex == DEVICE_COLUMN_INDICES.PARTITION.ordinal()) { + if (device instanceof Partition) { + return device.getName(); + } else { + return ""; + } + } else if (columnIndex == DEVICE_COLUMN_INDICES.STATUS.ordinal()) { + if(device.isUninitialized()) { + return ""; + } + if(glusterDataModelManager.isDeviceUsed(device)) { + return "In Use"; + } else { + return device.getStatusStr(); + } + } else { + return ""; + } + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerTableLabelProvider.java new file mode 100644 index 00000000..1afbddac --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/ServerTableLabelProvider.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.ServersPage.SERVER_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.utils.NumberUtil; + + +public class ServerTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Server)) { + return null; + } + + Server server = (Server) element; + return (columnIndex == SERVER_TABLE_COLUMN_INDICES.NAME.ordinal() ? server.getName() + : columnIndex == SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES.ordinal() ? server.getIpAddressesAsString() + : columnIndex == SERVER_TABLE_COLUMN_INDICES.NUM_OF_DISKS.ordinal() ? "" + + server.getNumOfDisks() : columnIndex == SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE + .ordinal() ? NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)) + // : columnIndex == SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS.ordinal() ? "" + + // server.getNumOfCPUs() + // : columnIndex == SERVER_TABLE_COLUMN_INDICES.CPU_USAGE.ordinal() ? "" + server.getCpuUsage() + // : columnIndex == SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY.ordinal() ? "" + + // server.getTotalMemory() + // : columnIndex == SERVER_TABLE_COLUMN_INDICES.MEMORY_IN_USE.ordinal() ? "" + + // server.getMemoryInUse() + // : columnIndex == SERVER_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE.ordinal() ? "" + + // server.getDiskSpaceInUse() + : "Invalid"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TableLabelProviderAdapter.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TableLabelProviderAdapter.java new file mode 100644 index 00000000..622d3dfc --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TableLabelProviderAdapter.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Image; + +public class TableLabelProviderAdapter implements ITableLabelProvider { + + @Override + public void addListener(ILabelProviderListener listener) { + // do nothing + + } + + @Override + public void dispose() { + // do nothing + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return true; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + // do nothing + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + return null; + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TasksTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TasksTableLabelProvider.java new file mode 100644 index 00000000..ad2a8a7d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/TasksTableLabelProvider.java @@ -0,0 +1,71 @@ +/** + * TasksTableLabelProvider.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console; + +import org.eclipse.swt.graphics.Image; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.TasksPage.TASK_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; + + + +public class TasksTableLabelProvider extends TableLabelProviderAdapter { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public Image getColumnImage(Object element, int columnIndex) { + + if (!(element instanceof TaskInfo)) { + return null; + } + + TaskInfo taskInfo = (TaskInfo) element; + if (columnIndex == TASK_TABLE_COLUMN_INDICES.STATUS.ordinal()) { + int statusCode = taskInfo.getStatus().getCode(); + + switch (statusCode) { + case Status.STATUS_CODE_SUCCESS: + return guiHelper.getImage(IImageKeys.COMPLETED_TASK_16x16); + case Status.STATUS_CODE_PAUSE: + return guiHelper.getImage(IImageKeys.PAUSE_TASK_16x16); + case Status.STATUS_CODE_RUNNING: + return guiHelper.getImage(IImageKeys.RESUME_TASK_16x16); + case Status.STATUS_CODE_FAILURE: + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16); + default: + break; + } + } + + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof TaskInfo)) { + return null; + } + + TaskInfo taskInfo = (TaskInfo) element; + return (columnIndex == TASK_TABLE_COLUMN_INDICES.TASK.ordinal()) ? taskInfo.getDescription().trim() : taskInfo.getStatus().getMessage().trim(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeLogTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeLogTableLabelProvider.java new file mode 100644 index 00000000..246bd7ca --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeLogTableLabelProvider.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + + +import org.gluster.storage.management.console.views.pages.VolumeLogsPage.LOG_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.VolumeLogMessage; +import org.gluster.storage.management.core.utils.DateUtil; + + +public class VolumeLogTableLabelProvider extends TableLabelProviderAdapter { + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof VolumeLogMessage)) { + return null; + } + + VolumeLogMessage logMessage = (VolumeLogMessage) element; + return (columnIndex == LOG_TABLE_COLUMN_INDICES.DATE.ordinal() ? DateUtil.formatDate(logMessage.getTimestamp()) + : columnIndex == LOG_TABLE_COLUMN_INDICES.TIME.ordinal() ? DateUtil.formatTime(logMessage.getTimestamp()) + : columnIndex == LOG_TABLE_COLUMN_INDICES.BRICK.ordinal() ? logMessage.getBrick() + : columnIndex == LOG_TABLE_COLUMN_INDICES.SEVERITY.ordinal() ? "" + logMessage.getSeverity() + : columnIndex == LOG_TABLE_COLUMN_INDICES.MESSAGE.ordinal() ? logMessage.getMessage() : "Invalid"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsContentProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsContentProvider.java new file mode 100644 index 00000000..0cc0b536 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsContentProvider.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.gluster.storage.management.core.model.VolumeOptions; + + +/** + * @author root + * + */ +public class VolumeOptionsContentProvider implements IStructuredContentProvider { + + @Override + public void dispose() { + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof VolumeOptions) { + return ((VolumeOptions) inputElement).getOptions().toArray(); + } + return null; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java new file mode 100644 index 00000000..250066bc --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeOptionsTableLabelProvider.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import java.util.Map.Entry; + +import org.gluster.storage.management.console.views.pages.VolumeOptionsPage.OPTIONS_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.VolumeOption; + + +public class VolumeOptionsTableLabelProvider extends TableLabelProviderAdapter { + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Entry)) { + return null; + } + + VolumeOption option = (VolumeOption)element; + return (columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal() ? option.getKey() + : columnIndex == OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal() ? option.getValue() + : "Invalid"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeTableLabelProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeTableLabelProvider.java new file mode 100644 index 00000000..e19a40b1 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/VolumeTableLabelProvider.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Image; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.VolumesPage.VOLUME_TABLE_COLUMN_INDICES; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; + + +public class VolumeTableLabelProvider implements ITableLabelProvider { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + + @Override + public Image getColumnImage(Object element, int columnIndex) { + if (!(element instanceof Volume)) { + return null; + } + + Volume volume = (Volume) element; + if(columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS.ordinal()) { + VOLUME_STATUS status = volume.getStatus(); + if(status == VOLUME_STATUS.ONLINE) { + return guiHelper.getImage(IImageKeys.STATUS_ONLINE_16x16); + } else { + return guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16); + } + } + + return null; + } + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Volume)) { + return null; + } + + Volume volume = (Volume) element; + return (columnIndex == VOLUME_TABLE_COLUMN_INDICES.NAME.ordinal() ? volume.getName() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_TYPE.ordinal() ? volume.getVolumeTypeStr() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.TRANSPORT_TYPE.ordinal() ? volume.getTransportTypeStr() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.NUM_OF_BRICKS.ordinal() ? "" + volume.getNumOfBricks() + : columnIndex == VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS.ordinal() ? volume.getStatusStr() : "Invalid"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractActionDelegate.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractActionDelegate.java new file mode 100644 index 00000000..efff2a3d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractActionDelegate.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.internal.UIPlugin; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.core.model.Entity; + + +/** + * All action delegates in the application should extend from this class. It provides common functionality of grabbing + * the Window object on initialization and extracting the selected entity in case of selection change on the navigation + * tree. + */ +@SuppressWarnings("restriction") +public abstract class AbstractActionDelegate implements IWorkbenchWindowActionDelegate { + protected IWorkbenchWindow window; + protected static final GlusterLogger logger = GlusterLogger.getInstance(); + + // the latest selected entity + protected Entity selectedEntity; + + @Override + public void run(final IAction action) { + try { + performAction(action); + } catch (final Exception e) { + final String actionDesc = action.getDescription(); + logger.error("Exception while running action [" + actionDesc + "]", e); + showErrorDialog(actionDesc, e.getMessage()); + } + } + + abstract protected void performAction(final IAction action); + + @Override + public void selectionChanged(IAction action, ISelection selection) { + if (selection instanceof StructuredSelection) { + Entity selectedEntity = (Entity) ((StructuredSelection) selection).getFirstElement(); + + if (this.selectedEntity == selectedEntity) { + // entity selection has not changed. do nothing. + return; + } + + if (selectedEntity != null) { + this.selectedEntity = selectedEntity; + } + } + } + + @Override + public void init(IWorkbenchWindow window) { + this.window = window; + } + + protected Shell getShell() { + return getWindow().getShell(); + } + + protected IWorkbenchWindow getWindow() { + return window == null ? UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow() : window; + } + + protected void showInfoDialog(final String title, final String message) { + MessageDialog.openInformation(getShell(), title, message); + } + + protected void showWarningDialog(final String title, final String message) { + MessageDialog.openWarning(getShell(), title, message); + } + + protected void showErrorDialog(final String title, final String message) { + MessageDialog.openError(getShell(), title, message); + } + + protected boolean showConfirmDialog(final String title, final String message) { + return MessageDialog.openQuestion(getShell(), title, message); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java new file mode 100644 index 00000000..00972f9f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.gluster.storage.management.console.ConsoleConstants; + + +/** + * Any action that can potentially run for a long time, and supports monitoring and progress dialog should extend from + * this class + */ +public abstract class AbstractMonitoredActionDelegate extends AbstractActionDelegate { + /* (non-Javadoc) + * @see org.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) + */ + @Override + protected void performAction(final IAction action) { + try { + new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() { + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + performAction(action, monitor); + } + }); + } catch (Exception e) { + String errMsg = "Exception while performing action [" + action.getDescription() + "] : [" + e.getMessage() + "]"; + logger.error(errMsg, e); + showErrorDialog(ConsoleConstants.CONSOLE_TITLE, errMsg); + } + } + + abstract void performAction(IAction action, IProgressMonitor monitor); +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ActionConstants.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ActionConstants.java new file mode 100644 index 00000000..bde96570 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ActionConstants.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +public class ActionConstants { + public static final String ACTION_SET_CLUSTER = "org.gluster.storage.management.console.actionsets.gluster"; + public static final String ACTION_SET_VOLUMES = "org.gluster.storage.management.console.actionsets.volumes"; + public static final String ACTION_SET_VOLUME = "org.gluster.storage.management.console.actionsets.volume"; + public static final String ACTION_SET_DISKS = "org.gluster.storage.management.console.actionsets.disks"; + public static final String ACTION_SET_DISK = "org.gluster.storage.management.console.actionsets.disk"; + public static final String ACTION_SET_GLUSTER_SERVERS = "org.gluster.storage.management.console.actionsets.glusterservers"; + public static final String ACTION_SET_GLUSTER_SERVER = "org.gluster.storage.management.console.actionsets.glusterserver"; + public static final String ACTION_SET_DISCOVERED_SERVERS = "org.gluster.storage.management.console.actionsets.serversdiscovered"; + public static final String ACTION_SET_DISCOVERED_SERVER = "org.gluster.storage.management.console.actionsets.serverdiscovered"; + public static final String ACTION_SET_TASK = "org.gluster.storage.management.console.actionsets.task"; + public static final String ACTION_SET_EDIT = "org.gluster.storage.management.console.actionsets.edit"; + + public static final String COMMAND_CREATE_VOLUME = "org.gluster.storage.management.console.commands.CreateVolume"; + public static final String COMMAND_ADD_SERVER = "org.gluster.storage.management.console.commands.AddServer"; +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddBrickAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddBrickAction.java new file mode 100644 index 00000000..e67cf9ab --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddBrickAction.java @@ -0,0 +1,64 @@ +/** + * AddBrickAction.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ + +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.dialogs.AddBrickWizard; +import org.gluster.storage.management.core.model.Volume; + + +public class AddBrickAction extends AbstractActionDelegate { + private Volume volume; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + public void dispose() { + window = null; + } + + @Override + protected void performAction(IAction action) { + // TODO: open a dialog box + // MessageDialog.openInformation(getShell(), "Action captured", action.getDescription() + "\n" + + // volume.getName()); + AddBrickWizard wizard = new AddBrickWizard(volume); // Also add single page + + WizardDialog dialog = new WizardDialog(getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(1024, 600); + dialog.open(); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + + if (selectedEntity instanceof Volume) { + this.volume = (Volume) selectedEntity; + // action.setEnabled(volume.getStatus() == VOLUME_STATUS.ONLINE); + } + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddServerAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddServerAction.java new file mode 100644 index 00000000..2a622384 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/AddServerAction.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.gluster.storage.management.client.GlusterServersClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.dialogs.ServerAdditionDialog; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Server; + + +public class AddServerAction extends AbstractMonitoredActionDelegate { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + protected void performAction(final IAction action, IProgressMonitor monitor) { + GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + GlusterServersClient glusterServersClient = new GlusterServersClient(); + + Set selectedServers = GUIHelper.getInstance().getSelectedEntities(getWindow(), Server.class); + Set successServers = new HashSet(); + Set partSuccessServers = new HashSet(); + String errMsg = ""; + String partErrMsg = ""; + + if (selectedServers.isEmpty()) { + monitor.beginTask("Starting Manual Server Addition", 1); + addServerManually(); + monitor.worked(1); + monitor.done(); + return; + } + + monitor.beginTask("Adding Selected Servers...", selectedServers.size()); + for (Server server : selectedServers) { + if(monitor.isCanceled()) { + break; + } + + monitor.setTaskName("Adding server [" + server.getName() + "]..."); + + try { + URI newServerURI = glusterServersClient.addServer(server.getName()); + modelManager.addGlusterServer(glusterServersClient.getGlusterServer(newServerURI)); + successServers.add(server); + } catch (Exception e) { + if (!errMsg.isEmpty()) { + errMsg += CoreConstants.NEWLINE; + } + errMsg += "Server " + server.getName() + ". Error: [" + e.getMessage() + "]"; + } + monitor.worked(1); + } + monitor.done(); + + showStatusMessage(action.getDescription(), selectedServers, successServers, partSuccessServers, errMsg, + partErrMsg); + } + + private void addServerManually() { + try { + // To open a dialog for server addition + ServerAdditionDialog dialog = new ServerAdditionDialog(getShell()); + dialog.open(); + } catch (Exception e) { + logger.error("Error in Manual server addition", e); + showErrorDialog("Add server", "Add server failed! [" + e.getMessage() + "]"); + } + } + + private void showStatusMessage(String dialogTitle, Set selectedServers, Set successServers, + Set partSuccessServers, String errMsg, String partErrMsg) { + if (successServers.size() == selectedServers.size()) { + if (selectedServers.size() == 1) { + showInfoDialog(dialogTitle, "Server [" + selectedServers.iterator().next() + "] added successfully!"); + } else { + showInfoDialog(dialogTitle, "Following servers added successfully!" + CoreConstants.NEWLINE + + selectedServers); + } + return; + } + + String finalMsg = ""; + if (successServers.size() == 0 && partSuccessServers.size() == 0) { + finalMsg = "Server Addition Failed! Error(s):" + CoreConstants.NEWLINE + errMsg; + } else { + finalMsg = (successServers.isEmpty() ? "" : "Following servers added successfully : " + + CoreConstants.NEWLINE + successServers + CoreConstants.NEWLINE) + + (partSuccessServers.isEmpty() ? "" : "Following servers were added to cluster, but with some errors: " + + CoreConstants.NEWLINE + partErrMsg + CoreConstants.NEWLINE) + + (errMsg.isEmpty() ? "" : CoreConstants.NEWLINE + + "Following errors occurred on other selected servers: " + CoreConstants.NEWLINE + errMsg); + } + showErrorDialog(dialogTitle, finalMsg); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ChangePasswordAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ChangePasswordAction.java new file mode 100644 index 00000000..07d59332 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ChangePasswordAction.java @@ -0,0 +1,23 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.gluster.storage.management.console.dialogs.ChangePasswordDialog; + + +public class ChangePasswordAction extends AbstractActionDelegate { + + @Override + protected void performAction(IAction action) { + try { + // To open a dialog for change password + ChangePasswordDialog dialog = new ChangePasswordDialog(getShell()); + dialog.open(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void dispose() { + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ClearTaskAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ClearTaskAction.java new file mode 100644 index 00000000..fcdb67ee --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ClearTaskAction.java @@ -0,0 +1,46 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; + + +public class ClearTaskAction extends AbstractActionDelegate { + private TaskInfo taskInfo; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + + try { + new TasksClient().deleteTask(taskInfo.getName()); // taskId + modelManager.removeTask(taskInfo); + action.setEnabled(false); // TODO disable other task buttons + } catch (Exception e) { + showErrorDialog(actionDesc, + "Task [" + taskInfo.getName() + "] could not be cleared! Error: [" + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + action.setEnabled(false); + if (selectedEntity instanceof TaskInfo) { + taskInfo = (TaskInfo) selectedEntity; + action.setEnabled(taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS + || taskInfo.getStatus().getCode() == Status.STATUS_CODE_FAILURE); + } else { + action.setEnabled(false); + } + } + + @Override + public void dispose() { + + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CommitTaskAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CommitTaskAction.java new file mode 100644 index 00000000..3fb59f91 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CommitTaskAction.java @@ -0,0 +1,72 @@ +package org.gluster.storage.management.console.actions; + + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Display; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.Volume; + + +public class CommitTaskAction extends AbstractActionDelegate { + private TaskInfo taskInfo; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + try { + new TasksClient().commitTask(taskInfo.getName()); + taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_SUCCESS, "Committed"))); + modelManager.removeTask(taskInfo); + showInfoDialog(actionDesc, "Commit successful"); + } catch (Exception e) { + showErrorDialog(actionDesc, + "Task [" + taskInfo.getName() + "] could not be Committed! Error: [" + e.getMessage() + "]"); + return; // Prevent to update model + } + + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override + public void run() { + try { + String volumeName = taskInfo.getReference().split("#")[0]; //Extract volume name from reference + Volume oldVolume = modelManager.getModel().getCluster().getVolume(volumeName); + Volume newVolume = (new VolumesClient()).getVolume(volumeName); + + modelManager.volumeChanged(oldVolume, newVolume); + } catch (Exception e) { + String errMsg = "Volume brick update failed! [" + e.getMessage() + "]"; + logger.error(errMsg, e); + showInfoDialog(actionDesc, errMsg); + } + } + }); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + action.setEnabled(false); + if (selectedEntity instanceof TaskInfo) { + taskInfo = (TaskInfo) selectedEntity; + action.setEnabled(taskInfo.getCommitSupported() + && taskInfo.getStatus().getCode() == Status.STATUS_CODE_COMMIT_PENDING); + } + } + + public void updateVolume(String volumeName) { + + } + + @Override + public void dispose() { + + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CreateVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CreateVolumeAction.java new file mode 100644 index 00000000..55d10eda --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/CreateVolumeAction.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.gluster.storage.management.console.dialogs.CreateVolumeWizard; + + +public class CreateVolumeAction extends AbstractActionDelegate { + @Override + protected void performAction(IAction action) { + CreateVolumeWizard wizard = new CreateVolumeWizard(); + + WizardDialog dialog = new WizardDialog(getShell(), wizard) { + @Override + protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { + Button button = super.createButton(parent, id, label, defaultButton); + if (id == IDialogConstants.FINISH_ID) { + button.setText("&Create"); + } + return button; + } + }; + dialog.create(); + dialog.getShell().setSize(510, 620); + dialog.open(); + } + + @Override + public void dispose() { + window = null; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DeleteVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DeleteVolumeAction.java new file mode 100644 index 00000000..fb9e4cc2 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DeleteVolumeAction.java @@ -0,0 +1,210 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; + + +public class DeleteVolumeAction extends AbstractMonitoredActionDelegate { + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private List selectedVolumes = new ArrayList(); + private List selectedVolumeNames = new ArrayList(); + private List onlineVolumeNames = new ArrayList(); + private List deletedVolumeNames = new ArrayList(); + private List failedVolumes = new ArrayList(); + + @Override + protected void performAction(final IAction action, IProgressMonitor monitor) { + final String actionDesc = action.getDescription(); + + collectVolumeNames(); + String warningMessage; + List cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); + List offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { + Integer userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + if (userAction != 1) { + return; // Do not delete volume services + } + } + + if (onlineVolumeNames.size() > 0) { // Getting confirmation for stop and delete + warningMessage = "Following volume(s) " + onlineVolumeNames + " are online, " + CoreConstants.NEWLINE + + "Are you sure to continue?" + CoreConstants.NEWLINE + selectedVolumeNames; + } else { + warningMessage = "Are you sure to delete the volumes " + selectedVolumeNames + " ?"; + } + + final Integer deleteOption = new MessageDialog(getShell(), "Delete Volume", GUIHelper.getInstance() + .getImage(IImageKeys.VOLUME_16x16), warningMessage, MessageDialog.QUESTION, new String[] { "Cancel", + "Delete volume and data", "Delete volume, keep data" }, -1).open(); + if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) + return; + } + + String errorMessage = deleteVolumes(selectedVolumes, deleteOption, monitor); + + // Display the success or failure info + if (deletedVolumeNames.size() == 0) { // No volume(s) deleted successfully + showErrorDialog(actionDesc, "Volume(s) could not be deleted! " + CoreConstants.NEWLINE + errorMessage); + } else { + String info = "Volume(s) " + deletedVolumeNames + " deleted successfully!"; + if (!failedVolumes.isEmpty()) { + info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes + + " could not be deleted!" + CoreConstants.NEWLINE + errorMessage; + } + + if (selectedVolumes.size() == deletedVolumeNames.size()) { + showInfoDialog(actionDesc, info); + } else { + showWarningDialog(actionDesc, info); + } + } + } + + private String deleteVolumes(List volumes, final Integer deleteOption, IProgressMonitor monitor) { + deletedVolumeNames.clear(); + failedVolumes.clear(); + VolumesClient vc = new VolumesClient(); + boolean confirmDeleteDir = (deleteOption == 1) ? true : false; + + String errorMessage = ""; + + // To calculate the total work we need to sum volumes size + online volumes (because we treat stop and delete as + // separate steps) + List onlineVolumes = getOnlineVolumes(volumes); + monitor.beginTask("Deleting Selected Volumes...", volumes.size() + onlineVolumes.size()); + + // Deletion of a volume results in changes to the model, and ultimately updates the "selectedVolumes" list, + // over which we are iterating, thus resulting in ConcurrentModificationException. To avoid this, we iterate + // over an array obtained from the list. + for (Volume volume : volumes.toArray(new Volume[0])) { + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { // stop if online volume + monitor.setTaskName("Stopping volume [" + volume.getName() + "]"); + try { + vc.stopVolume(volume.getName(), false); + } catch (Exception e1) { + // try again with force = true + try { + vc.stopVolume(volume.getName(), true); + } catch(Exception e2) { + // force stop also failed. + // Mark as deletion failed, append error message. + errorMessage += CoreConstants.NEWLINE + "Stop [" + volume.getName() + "] : [" + e2.getMessage() + + "]"; + failedVolumes.add(volume); + // since we are not going to perform delete on this volume, + // mark the deletion task as worked + monitor.worked(1); + + // continue to next volume without trying to delete this one + continue; + } + } finally { + // worked for "stop" operation + monitor.worked(1); + } + } + + monitor.setTaskName("Deleting volume [" + volume.getName() + "]"); + try { + vc.deleteVolume(volume.getName(), confirmDeleteDir); + modelManager.deleteVolume(volume); + deletedVolumeNames.add(volume.getName()); + } catch (Exception e) { + // Volume delete succeeded and post delete operation (directory cleanup, CIFS etc) may fail + if (vc.volumeExists(volume.getName())) { + errorMessage += CoreConstants.NEWLINE + "Delete [" + volume.getName() + "] : [" + e.getMessage() + "]"; + failedVolumes.add(volume); + } else { + errorMessage += CoreConstants.NEWLINE + "Volume [" + volume.getName() + + "] deleted, but following error occured: [" + e.getMessage() + "]"; + modelManager.deleteVolume(volume); + deletedVolumeNames.add(volume.getName()); + } + } finally { + monitor.worked(1); + } + } + monitor.done(); + return errorMessage; + } + + private List getOnlineVolumes(List volumes) { + List onlineVolumes = new ArrayList(); + for (Volume volume : volumes) { + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + onlineVolumes.add(volume); + } + } + return onlineVolumes; + } + + private void collectVolumeNames() { + selectedVolumeNames.clear(); + onlineVolumeNames.clear(); + for (Volume volume : selectedVolumes) { + selectedVolumeNames.add(volume.getName()); + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + onlineVolumeNames.add(volume.getName()); + } + } + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + Set selectedVolumeSet = GUIHelper.getInstance().getSelectedEntities(getWindow(), Volume.class); + selectedVolumes.clear(); + if (selectedVolumeSet == null || selectedVolumeSet.isEmpty()) { + super.selectionChanged(action, selection); + if (selectedEntity instanceof Volume) { + selectedVolumes.add((Volume) selectedEntity); + } + } else { + selectedVolumes.addAll(selectedVolumeSet); //TODO reverse the collection to maintain the selected order + } + + action.setEnabled( (selectedVolumes.size() > 0) ); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java new file mode 100644 index 00000000..b67e0b2e --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/DownloadVolumeLogsAction.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Volume; + + +/** + * + */ +public class DownloadVolumeLogsAction extends AbstractActionDelegate { + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + public void dispose() { + } + + @Override + protected void performAction(IAction action) { + final VolumesClient client = new VolumesClient(); + Volume volume = guiHelper.getSelectedEntity(getWindow(), Volume.class); + + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + dialog.setFilterNames(new String[] { "GZipped Tar (*.tar.gz)" }); + dialog.setFilterExtensions(new String[] { "*.tar.gz" }); + String filePath = dialog.open(); + + if (filePath == null) { + return; + } + + String title = "Download Volume Logs [" + volume.getName() + "]"; + try { + client.downloadLogs(volume.getName(), filePath); + showInfoDialog(title, "Volume logs downloaded successfully to [" + filePath + "]"); + } catch (Exception e) { + showErrorDialog(title, e.getMessage()); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/EditVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/EditVolumeAction.java new file mode 100644 index 00000000..efb7b780 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/EditVolumeAction.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; + +public class EditVolumeAction extends AbstractActionDelegate { + @Override + protected void performAction(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ExportSshKeysAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ExportSshKeysAction.java new file mode 100644 index 00000000..a4b57800 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ExportSshKeysAction.java @@ -0,0 +1,61 @@ +/** + * ExportSshKeysAction.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.gluster.storage.management.client.KeysClient; + + +/** + * @author root + * + */ +public class ExportSshKeysAction extends AbstractActionDelegate { + + @Override + protected void performAction(IAction action) { + final KeysClient client = new KeysClient(); + FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); + dialog.setFilterNames(new String[] { "Tar (*.tar)" }); + dialog.setFilterExtensions(new String[] { "*.tar" }); + String filePath = dialog.open(); + + if (filePath == null) { + return; + } + + String title = "Export SSH Keys"; + try { + client.exportSshKeys(filePath); + showInfoDialog(title, "SSH keys exported successfully to [" + filePath + "]"); + } catch (Exception e) { + showErrorDialog(title, e.getMessage()); + } + } + + + @Override + public void dispose() { + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ForceStartVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ForceStartVolumeAction.java new file mode 100644 index 00000000..3c57256a --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ForceStartVolumeAction.java @@ -0,0 +1,71 @@ +package org.gluster.storage.management.console.actions; + +import java.util.Set; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.VolumeBricksView; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.utils.StringUtil; + + +public class ForceStartVolumeAction extends AbstractActionDelegate { + + private Volume volume; + private GUIHelper guiHelper = GUIHelper.getInstance(); + private Set bricks; + + @Override + public void dispose() { + + } + + @Override + protected void performAction(IAction action) { + // volume brick service will be started, do you want to continue? + final String actionDesc = action.getDescription(); + boolean confirmed = showConfirmDialog( + actionDesc, + "The offline Bricks [" + StringUtil.collectionToString(bricks, ", ") + "] of Volume [" + + volume.getName() + "] will be started. Are you sure you want to continue?"); + if (!confirmed) { + return; + } + try { + new VolumesClient().startVolume(volume.getName(), true); + showInfoDialog(actionDesc, "Offline Bricks of Volume [" + volume.getName() + "] started successfully!"); + } catch (Exception e) { + showErrorDialog(actionDesc, e.getMessage()); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + action.setEnabled(false); + volume = guiHelper.getSelectedEntity(window, Volume.class); + if (volume != null) { + // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view + IWorkbenchPart view = guiHelper.getActiveView(); + if (view instanceof VolumeBricksView) { + // volume bricks view is open. check if any offline brick is selected + bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); + for (Brick brick : bricks) { + if (brick.getStatus() == BRICK_STATUS.OFFLINE) { + action.setEnabled(true); + } else { + // if any one of the selected brick is online, the disable the button + action.setEnabled(false); + break; + } + } + } + } + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ImportSshKeysAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ImportSshKeysAction.java new file mode 100644 index 00000000..083cf193 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ImportSshKeysAction.java @@ -0,0 +1,44 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.gluster.storage.management.client.KeysClient; + + +public class ImportSshKeysAction extends AbstractActionDelegate { + + @Override + protected void performAction(IAction action) { + final KeysClient client = new KeysClient(); + + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); + dialog.setText("Open"); + dialog.setFilterNames(new String[] { "ssh-keys (*.tar)" }); + dialog.setFilterExtensions(new String[] { "*.tar" }); + + String selectedFile = dialog.open(); + if (selectedFile == null) { + return; + } + + String title = "Import SSH Keys"; + try { + client.importSshKeys(selectedFile); + showInfoDialog(title, "SSH keys imported successfully!"); + } catch (Exception e) { + showErrorDialog(title, e.getMessage()); + } + } + }); + } + + @Override + public void dispose() { + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateBrickAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateBrickAction.java new file mode 100644 index 00000000..01cc837c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateBrickAction.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.util.Set; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.gluster.storage.management.console.dialogs.MigrateBrickWizard; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Volume; + + +public class MigrateBrickAction extends AbstractActionDelegate { + private Volume volume; + private Brick brick; + + @Override + protected void performAction(IAction action) { + MigrateBrickWizard wizard = new MigrateBrickWizard(volume, brick); + + WizardDialog dialog = new WizardDialog(window.getShell(), wizard); + dialog.create(); + dialog.getShell().setSize(1024, 600); + dialog.open(); + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + Set bricks; + if (selectedEntity instanceof Volume) { + volume = (Volume) selectedEntity; + } + + action.setEnabled(false); + if (selectedEntity instanceof Brick) { + bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); + if ( bricks.iterator().hasNext()) { + brick = bricks.iterator().next(); + } else { + brick = null; + } + action.setEnabled(brick != null); + } + } + + @Override + public void dispose() { + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateVolumeAction.java new file mode 100644 index 00000000..ed4b47f6 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/MigrateVolumeAction.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; + +public class MigrateVolumeAction extends AbstractActionDelegate { + @Override + protected void performAction(IAction action) { + System.out.println("Running [" + this.getClass().getSimpleName() + "]"); + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PauseTaskAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PauseTaskAction.java new file mode 100644 index 00000000..675095ee --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PauseTaskAction.java @@ -0,0 +1,67 @@ +/** + * PauseTaskAction.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; + + + +public class PauseTaskAction extends AbstractActionDelegate { + private TaskInfo taskInfo; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + + try { + new TasksClient().pauseTask(taskInfo.getName()); + taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_PAUSE, "Paused"))); + modelManager.updateTask(taskInfo); + } catch (Exception e) { + showErrorDialog(actionDesc, + "Task [" + taskInfo.getDescription() + "] could not be Paused! Error: [" + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + action.setEnabled(false); + if (selectedEntity instanceof TaskInfo) { + taskInfo = (TaskInfo) selectedEntity; + action.setEnabled(taskInfo.getPauseSupported() && taskInfo.getStatus().getCode() == Status.STATUS_CODE_RUNNING); + } + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PreferencesAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PreferencesAction.java new file mode 100644 index 00000000..11db53e0 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/PreferencesAction.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.actions.ActionFactory; + +public class PreferencesAction extends AbstractActionDelegate { + + @Override + public void dispose() { + + } + + @Override + protected void performAction(IAction action) { + ActionFactory.PREFERENCES.create(window).run(); + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RebalanceVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RebalanceVolumeAction.java new file mode 100644 index 00000000..beae73c6 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RebalanceVolumeAction.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.net.URI; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.Volume; + + +public class RebalanceVolumeAction extends AbstractActionDelegate { + private Volume volume; + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + try { + TaskInfo existingTaskInfo = GlusterDataModelManager.getInstance().getTaskByReference(volume.getName()); + if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS + && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { + showInfoDialog(actionDesc, "Volume [" + volume.getName() + + "] rebalance is already in progress! Try later."); + return; + } + + URI uri = new VolumesClient().rebalanceStart(volume.getName(), false, false, false); + // Add the task to model + TasksClient taskClient = new TasksClient(); + TaskInfo taskInfo = taskClient.getTaskInfo(uri); + if (taskInfo != null) { + GlusterDataModelManager.getInstance().addTask(taskInfo); + } + showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] rebalance started successfully!"); + guiHelper.showTaskView(); + } catch (Exception e) { + showErrorDialog(actionDesc, "Volume rebalance could not be started on [" + volume.getName() + "]! Error: [" + + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + + Volume selectedVolume = guiHelper.getSelectedEntity(getWindow(), Volume.class); + if (selectedVolume != null) { + volume = selectedVolume; + action.setEnabled(true); + } else { + action.setEnabled(false); + } + } + + @Override + public void dispose() { + System.out.println("Disposing [" + this.getClass().getSimpleName() + "]"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RefreshDataAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RefreshDataAction.java new file mode 100644 index 00000000..5e791768 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RefreshDataAction.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.gluster.storage.management.console.jobs.DataSyncJob; + + +/** + * + */ +public class RefreshDataAction extends AbstractActionDelegate { + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + @Override + public void dispose() { + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) + */ + @Override + protected void performAction(IAction action) { + new DataSyncJob("Retrieving Management Info").schedule(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveBrickAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveBrickAction.java new file mode 100644 index 00000000..658394ed --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveBrickAction.java @@ -0,0 +1,91 @@ +package org.gluster.storage.management.console.actions; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbenchPart; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.VolumeBricksView; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.utils.StringUtil; + + +public class RemoveBrickAction extends AbstractActionDelegate { + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private GUIHelper guiHelper = GUIHelper.getInstance(); + private Set bricks; + private Volume volume; + boolean confirmDelete = false; + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + List brickList = getBrickList(bricks); + Integer deleteOption = new MessageDialog(getShell(), "Remove Bricks(s)", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), "Are you sure you want to remove following bricks from volume [" + volume.getName() + + "] ? " + CoreConstants.NEWLINE + StringUtil.collectionToString(brickList, ", "), MessageDialog.QUESTION, new String[] { + "Cancel", "Remove bricks, delete data", "Remove bricks, keep data" }, -1).open(); + if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1) + return; + } + + if (deleteOption == 1) { + confirmDelete = true; + } + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + public void run() { + VolumesClient client = new VolumesClient(); + try { + client.removeBricks(volume.getName(), bricks, confirmDelete); + // Update model with removed bricks in the volume + modelManager.removeBricks(volume, bricks); + + showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] bricks(s) removed successfully!"); + } catch (Exception e) { + showErrorDialog(actionDesc, "Volume [" + volume.getName() + + "] bricks(s) could not be removed! Error: [" + e.getMessage() + "]"); + } + } + }); + } + + @Override + public void dispose() { + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + + action.setEnabled(false); + volume = guiHelper.getSelectedEntity(window, Volume.class); + if (volume != null) { + // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view + IWorkbenchPart view = guiHelper.getActiveView(); + if (view instanceof VolumeBricksView) { + // volume bricks view is open. check if any brick is selected + bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); + action.setEnabled(bricks.size() > 0); + } + } + } + + private List getBrickList(Set bricks) { + List brickList = new ArrayList(); + for (Brick brick : bricks) { + brickList.add(brick.getServerName() + ":" + brick.getBrickDirectory()); + } + return brickList; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveServerAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveServerAction.java new file mode 100644 index 00000000..94f69be8 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/RemoveServerAction.java @@ -0,0 +1,159 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.GlusterServersClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.GlusterServer; + + +public class RemoveServerAction extends AbstractMonitoredActionDelegate { + private static final GlusterLogger logger = GlusterLogger.getInstance(); + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private GUIHelper guiHelper = GUIHelper.getInstance(); + + @Override + protected void performAction(final IAction action, IProgressMonitor monitor) { + final String actionDesc = action.getDescription(); + + Set selectedServers = guiHelper.getSelectedEntities(getWindow(), GlusterServer.class); + + if (!validate(action, selectedServers)) { + return; + } + + boolean confirmed = showConfirmDialog(actionDesc, "Are you sure you want to remove the server(s) " + + selectedServers + " ?"); + if (!confirmed) { + return; + } + + Set successServers = new HashSet(); + String errMsg = ""; + monitor.beginTask("Removing Selected Servers...", selectedServers.size()); + for (GlusterServer server : selectedServers) { + monitor.setTaskName("Removing server [" + server.getName() + "]..."); + + GlusterServersClient client = new GlusterServersClient(); + try { + client.removeServer(server.getName()); + GlusterServer glusterServer = server; + modelManager.removeGlusterServer(glusterServer); + successServers.add(server); + } catch (Exception e) { + if (!serverExists(server.getName())) { + modelManager.removeGlusterServer(server); + } + errMsg += "[" + server.getName() + "] : " + e.getMessage() + CoreConstants.NEWLINE; + } + monitor.worked(1); + } + monitor.done(); + showStatusMessage(action.getDescription(), selectedServers, successServers, errMsg); + } + + private Boolean serverExists(String serverName) { + try { + GlusterServersClient client = new GlusterServersClient(); + GlusterServer server = client.getGlusterServer(serverName); + return (server != null && server.getName().length() > 0); + } catch (Exception e) { + logger.error("Error while getting server info", e); + return false; + } + } + + private void showStatusMessage(String dialogTitle, Set selectedServers, Set successServers, + String errMsg) { + if (successServers.size() == selectedServers.size()) { + if(selectedServers.size() == 1) { + showInfoDialog(dialogTitle, "Server [" + selectedServers.iterator().next() + "] removed successfully!"); + } else { + showInfoDialog(dialogTitle, "Following servers removed successfully: " + CoreConstants.NEWLINE + + selectedServers + CoreConstants.NEWLINE + errMsg); + } + return; + } + + if (successServers.size() == 0) { + errMsg = "Server Removal Failed! Error(s):" + CoreConstants.NEWLINE + errMsg; + } else { + errMsg = "Following servers removed successfully : " + CoreConstants.NEWLINE + successServers + + CoreConstants.NEWLINE + "Following errors occurred on other selected servers: " + + CoreConstants.NEWLINE + errMsg; + } + showErrorDialog(dialogTitle, errMsg); + } + + private boolean validate(IAction action, Set selectedServers) { + Map> usedServers = new HashMap>(); + for (GlusterServer server : selectedServers) { + List configuredVolumes = modelManager.getVolumesOfServer(server.getName()); + + if (configuredVolumes.size() > 0) { + usedServers.put(server, configuredVolumes); + } + } + + if (usedServers.size() > 0) { + if (usedServers.size() == 1) { + showErrorDialog(action.getDescription(), "Server [" + usedServers.keySet().iterator().next() + + "] cannot be removed as it is being used by volume(s): " + CoreConstants.NEWLINE + + usedServers.values().iterator().next() ); + } else { + String serverList = ""; + for (Entry> entry : usedServers.entrySet()) { + serverList += entry.getKey() + " -> " + entry.getValue() + CoreConstants.NEWLINE; + } + showErrorDialog(action.getDescription(), + "Following servers cannot be removed as they are being used by volume(s): " + + CoreConstants.NEWLINE + serverList ); + } + return false; + } + return true; + } + + public void dispose() { + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + Set selectedServers = GUIHelper.getInstance().getSelectedEntities(getWindow(), + GlusterServer.class); + if(selectedServers == null || selectedServers.isEmpty()) { + action.setEnabled(false); + } else { + action.setEnabled(true); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java new file mode 100644 index 00000000..ef21aac7 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResetVolumeOptionsAction.java @@ -0,0 +1,62 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Display; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Volume; + + +public class ResetVolumeOptionsAction extends AbstractActionDelegate { + private Volume volume; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + public void dispose() { + } + + @Override + protected void performAction(final IAction action) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + final String actionDesc = action.getDescription(); + + boolean confirmed = showConfirmDialog(actionDesc, + "Are you sure you want to reset all options of the volume [" + volume.getName() + "] ?"); + if (!confirmed) { + return; + } + + try { + new VolumesClient().resetVolumeOptions(volume.getName()); + showInfoDialog(actionDesc, "Volume options for [" + volume.getName() + "] reset successfully!"); + modelManager.resetVolumeOptions(volume); + } catch (Exception e) { + showErrorDialog(actionDesc, "Volume options for [" + volume.getName() + + "] could not be reset! Error: [" + e.getMessage() + "]"); + } + } + }); + } + + /* + * (non-Javadoc) + * + * @see + * org.gluster.storage.management.console.actions.AbstractActionDelegate#selectionChanged(org.eclipse.jface.action.IAction + * , org.eclipse.jface.viewers.ISelection) + */ + @Override + public void selectionChanged(IAction action, ISelection selection) { + volume = GUIHelper.getInstance().getSelectedEntity(getWindow(), Volume.class); + if (volume != null) { + action.setEnabled(volume.getOptions().size() > 0); + } else { + action.setEnabled(false); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResumeTaskAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResumeTaskAction.java new file mode 100644 index 00000000..4ecb283d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ResumeTaskAction.java @@ -0,0 +1,45 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; + + +public class ResumeTaskAction extends AbstractActionDelegate { + private TaskInfo taskInfo; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + + try { + new TasksClient().resumeTask(taskInfo.getName()); + taskInfo.setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, "Resumed"))); + modelManager.updateTask(taskInfo); + } catch (Exception e) { + showErrorDialog(actionDesc, + "Task [" + taskInfo.getDescription() + "] could not be Resumed! Error: [" + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + action.setEnabled(false); + if (selectedEntity instanceof TaskInfo) { + taskInfo = (TaskInfo) selectedEntity; + action.setEnabled(taskInfo.getStatus().getCode() == Status.STATUS_CODE_PAUSE); + } + } + + @Override + public void dispose() { + + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ServerAdditionAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ServerAdditionAction.java new file mode 100644 index 00000000..c0ed3beb --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/ServerAdditionAction.java @@ -0,0 +1,28 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.gluster.storage.management.console.dialogs.ServerAdditionDialog; +import org.gluster.storage.management.console.utils.GlusterLogger; + + +public class ServerAdditionAction extends AbstractActionDelegate { + private static final GlusterLogger logger = GlusterLogger.getInstance(); + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + + @Override + protected void performAction(IAction action) { + try { + // To open a dialog for server addition + ServerAdditionDialog dialog = new ServerAdditionDialog(getShell()); + dialog.open(); + } catch (Exception e) { + logger.error("Error in Manual server addition", e); + e.printStackTrace(); + } + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StartVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StartVolumeAction.java new file mode 100644 index 00000000..4a8db975 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StartVolumeAction.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.osgi.internal.signedcontent.Base64; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.AlertsManager; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Alert.ALERT_TYPES; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; + + +public class StartVolumeAction extends AbstractMonitoredActionDelegate { + //private Volume volume; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private List selectedVolumes = new ArrayList(); + private List selectedVolumeNames = new ArrayList(); + private List offlineVolumeNames = new ArrayList(); + + @Override + protected void performAction(IAction action, IProgressMonitor monitor) { + final String actionDesc = action.getDescription(); + + collectVolumeNames(); + + if (offlineVolumeNames.size() == 0) { + showWarningDialog(actionDesc, "Volumes " + selectedVolumeNames + " already started!"); + return; // Volume already started. Don't do anything. + } + + VolumesClient vc = new VolumesClient(); + Volume newVolume = new Volume(); + List startedVolumes = new ArrayList(); + List failedVolumes = new ArrayList(); + String errorMessage = ""; + List cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); + List offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { + Integer userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + if (userAction != 1) { + return; // Do not start volume services + } + } + + monitor.beginTask("Starting Selected Volumes...", selectedVolumes.size()); + // Starting of a volume results in changes to the model, and ultimately updates the "selectedVolumes" list, + // over which we are iterating, thus resulting in ConcurrentModificationException. To avoid this, we iterate + // over an array obtained from the list. + for (Volume volume : selectedVolumes.toArray(new Volume[0])) { + if(monitor.isCanceled()) { + break; + } + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + monitor.worked(1); + continue; // skip if already started + } + try { + monitor.setTaskName("Starting volume [" + volume.getName() + "]"); + vc.startVolume(volume.getName(), false); + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE); + startedVolumes.add(volume.getName()); + } catch (Exception e) { + failedVolumes.add(volume.getName()); + // If any post volume start activity failed, update the volume status + if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.ONLINE) { + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE); + } + errorMessage += e.getMessage() + CoreConstants.NEWLINE; + } + + // Update the model by fetching latest volume info (NOT JUST STATUS) + try { + modelManager.refreshVolumeData(volume); + } catch (Exception e) { + errorMessage += "Updating volume info failed on UI. [" + e.getMessage() + "]"; + } + monitor.worked(1); + } + monitor.done(); + + // Display the success or failure info + if (startedVolumes.size() == 0) { // No volume(s) started successfully + showErrorDialog(actionDesc, "Volume(s) " + failedVolumes + " could not be started!" + + CoreConstants.NEWLINE + "Error: [" + errorMessage + "]"); + } else { + String info = "Volume(s) " + startedVolumes + " started successfully!"; + if (!errorMessage.equals("")) { + info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes + + " failed to start! [" + errorMessage + "]"; + } + if (selectedVolumes.size() == startedVolumes.size()) { + showInfoDialog(actionDesc, info); + } else { + showWarningDialog(actionDesc, info); + } + } + } + + private void collectVolumeNames() { + selectedVolumeNames.clear(); + offlineVolumeNames.clear(); + for (Volume volume : selectedVolumes) { + selectedVolumeNames.add(volume.getName()); + if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { + offlineVolumeNames.add(volume.getName()); + } + } + } + + @Override + public void dispose() { + + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + Set selectedVolumeNames = GUIHelper.getInstance().getSelectedEntities(getWindow(), Volume.class); + selectedVolumes.clear(); + if (selectedVolumeNames == null || selectedVolumeNames.isEmpty()) { + super.selectionChanged(action, selection); + if (selectedEntity instanceof Volume) { + selectedVolumes.add((Volume) selectedEntity); + } + } else { + selectedVolumes.addAll(selectedVolumeNames); //TODO reverse the collection to maintain the selected order + } + + action.setEnabled(false); + // To enable the action + for (Volume volume : selectedVolumes) { + if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { + action.setEnabled(true); + break;// If find an online volume, enable the action + } + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopTaskAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopTaskAction.java new file mode 100644 index 00000000..e5ba017d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopTaskAction.java @@ -0,0 +1,46 @@ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; + + +public class StopTaskAction extends AbstractActionDelegate { + private TaskInfo taskInfo; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + @Override + protected void performAction(final IAction action) { + final String actionDesc = action.getDescription(); + + try { + new TasksClient().stopTask(taskInfo.getName()); + // On successful stop clear from the task list + modelManager.removeTask(taskInfo); + action.setEnabled(false); // TODO disable other task buttons + } catch (Exception e) { + showErrorDialog(actionDesc, + "Task [" + taskInfo.getDescription() + "] could not be Stopped! Error: [" + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + action.setEnabled(false); + if (selectedEntity instanceof TaskInfo) { + taskInfo = (TaskInfo) selectedEntity; + action.setEnabled(taskInfo.getStopSupported() + && (taskInfo.getStatus().getCode() == Status.STATUS_CODE_PAUSE + || taskInfo.getStatus().getCode() == Status.STATUS_CODE_RUNNING)); + } + } + + @Override + public void dispose() { + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopVolumeAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopVolumeAction.java new file mode 100644 index 00000000..e1b67c1d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/StopVolumeAction.java @@ -0,0 +1,229 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; + + +public class StopVolumeAction extends AbstractMonitoredActionDelegate { + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private List selectedVolumes = new ArrayList(); + private List selectedVolumeNames = new ArrayList(); + private List onlineVolumeNames = new ArrayList(); + private List stoppedVolumes = new ArrayList(); + private List failedVolumes = new ArrayList(); + private String errorMessage = null; + + @Override + protected void performAction(final IAction action, IProgressMonitor monitor) { + collectVolumeNames(); + + if (onlineVolumeNames.size() == 0) { + showWarningDialog(action.getDescription(), "Volumes " + selectedVolumeNames + " already stopped!"); + return; // Volumes already stopped, Don't do anything. + } + + Integer userAction = new MessageDialog(getShell(), "Stop Volume", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), "Are you sure you want to stop the following volumes?" + + CoreConstants.NEWLINE + onlineVolumeNames, MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + + if (userAction <= 0) { // user select cancel or pressed escape key + return; + } + + List cifsVolumes = GlusterDataModelManager.getInstance().getCifsEnabledVolumeNames(selectedVolumes); + List offlineServers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (cifsVolumes != null && cifsVolumes.size() > 0 && offlineServers != null && offlineServers.size() > 0) { + userAction = new MessageDialog(getShell(), "CIFS configuration", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, + new String[] { "No", "Yes" }, -1).open(); + if (userAction != 1) { + return; // Do not stop volume services + } + } + + stopVolumes(selectedVolumes, false, monitor); + + // Check for errors, trying to force stop in case of errors + checkForErrors(action, monitor, true); + } + + private void checkForErrors(final IAction action, IProgressMonitor monitor, boolean tryForceStop) { + String message = null; + if (stoppedVolumes.size() == 0) { // No volume(s) stopped successfully + message = "Volume(s) " + failedVolumes + " could not be stopped! " + CoreConstants.NEWLINE + + "Error: [" + errorMessage + "]"; + if(tryForceStop) { + forceStopVolumes(action.getDescription(), message + CoreConstants.NEWLINE + + "Do you want to stop forcefully?", monitor); + // check for errors without trying to force stop in case of errors + checkForErrors(action, monitor, false); + return; + } else { + showErrorDialog(action.getDescription(), message); + return; + } + } else { + message = "Volume(s) " + stoppedVolumes + " stopped successfully!"; + if (!errorMessage.isEmpty()) { + if (failedVolumes.size() > 0) { + message = message + CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volume(s) " + + failedVolumes + " could not be stopped! [" + errorMessage + "]"; + if(tryForceStop) { + forceStopVolumes(action.getDescription(), message + CoreConstants.NEWLINE + + "Do you want to stop forcefully?", monitor); + // check for errors without trying to force stop in case of errors + checkForErrors(action, monitor, false); + return; + } + } else { // Stop volume success, but post stop volume fails, append the error message + message += CoreConstants.NEWLINE + CoreConstants.NEWLINE + errorMessage; + } + } + + if (errorMessage.isEmpty()) { + showInfoDialog(action.getDescription(), message); + } else { + showWarningDialog(action.getDescription(), message); + } + } + } + + private void forceStopVolumes(String actionDesc, String message, IProgressMonitor monitor) { + boolean forceStop = showConfirmDialog(actionDesc, message); + if (!forceStop) { + return; + } + stopVolumes(failedVolumes, true, monitor); + } + + private void stopVolumes(List volumes, Boolean force, IProgressMonitor monitor) { + VolumesClient vc = new VolumesClient(); + Volume newVolume = new Volume(); + stoppedVolumes.clear(); + failedVolumes.clear(); + errorMessage = ""; + + monitor.beginTask("Stopping Selected Volumes...", volumes.size()); + // Stopping of a volume results in changes to the model, and ultimately updates the "selectedVolumes" list, + // over which we are iterating, thus resulting in ConcurrentModificationException. To avoid this, we iterate + // over an array obtained from the list. + for (Volume volume : volumes.toArray(new Volume[0])) { + if(monitor.isCanceled()) { + break; + } + + if (volume.getStatus() == VOLUME_STATUS.OFFLINE) { + monitor.worked(1); + continue; // skip if already stopped + } + try { + monitor.setTaskName("Stopping volume [" + volume.getName() + "]"); + vc.stopVolume(volume.getName(), force); + stoppedVolumes.add(volume.getName()); + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); + } catch (Exception e) { + // If any post volume stop activity failed, update the volume status + if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.OFFLINE) { + // stop volume succeed, so add it to stoppedVolumes + stoppedVolumes.add(volume.getName()); + modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); + errorMessage += "Volume [" + volume.getName() + "] stopped, but following error occured: [" + + e.getMessage() + "]"; + } else { + failedVolumes.add(volume); + errorMessage += "[" + volume.getName() + "] : " + e.getMessage() + CoreConstants.NEWLINE; + } + } + + // Update the model by fetching latest volume info (NOT JUST STATUS) + try { + modelManager.refreshVolumeData(volume); + } catch (Exception e) { + errorMessage += "Failed to update volume info on UI. [" + e.getMessage() + "]"; + } + monitor.worked(1); + } + monitor.done(); + } + + private void collectVolumeNames() { + selectedVolumeNames.clear(); + onlineVolumeNames.clear(); + for (Volume volume : selectedVolumes) { + selectedVolumeNames.add(volume.getName()); + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + onlineVolumeNames.add(volume.getName()); + } + } + } + + @Override + public void dispose() { + } + + /* + * (non-Javadoc) + * + * @see + * org.gluster.storage.management.console.actions.AbstractActionDelegate#selectionChanged(org.eclipse.jface.action.IAction + * , org.eclipse.jface.viewers.ISelection) + */ + @Override + public void selectionChanged(IAction action, ISelection selection) { + Set selectedVolumeNames = GUIHelper.getInstance().getSelectedEntities(getWindow(), Volume.class); + selectedVolumes.clear(); + if (selectedVolumeNames == null || selectedVolumeNames.isEmpty()) { + super.selectionChanged(action, selection); + if (selectedEntity instanceof Volume) { + selectedVolumes.add((Volume) selectedEntity); + } + } else { + selectedVolumes.addAll(selectedVolumeNames); //TODO reverse the collection to maintain the selected order + } + + action.setEnabled(false); + // To enable the action + for (Volume volume : selectedVolumes) { + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + action.setEnabled(true); + break; // If find an online volume, enable the action + } + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/SupportAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/SupportAction.java new file mode 100644 index 00000000..9b698df9 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/SupportAction.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.gluster.storage.management.console.dialogs.GlusterSupportDialog; + + +/** + * + */ +public class SupportAction extends AbstractActionDelegate { + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) + */ + @Override + protected void performAction(IAction action) { + GlusterSupportDialog dialog = new GlusterSupportDialog(getShell()); + dialog.create(); + dialog.getShell().setSize(770, 430); + dialog.open(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + @Override + public void dispose() { + + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TerminalAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TerminalAction.java new file mode 100644 index 00000000..433bff69 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TerminalAction.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.gluster.storage.management.console.utils.GUIHelper; + + +/** + * + */ +public class TerminalAction extends AbstractActionDelegate { + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() + */ + @Override + public void dispose() { + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction) + */ + @Override + protected void performAction(IAction action) { + GUIHelper.getInstance().showTerminalView(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TestPopupMenuAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TestPopupMenuAction.java new file mode 100644 index 00000000..dfb2af2f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/TestPopupMenuAction.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; + +public class TestPopupMenuAction implements IObjectActionDelegate { + + private Shell shell; + + /** + * Constructor for Action1. + */ + public TestPopupMenuAction() { + super(); + } + + /** + * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) + */ + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + shell = targetPart.getSite().getShell(); + } + + /** + * @see IActionDelegate#run(IAction) + */ + public void run(IAction action) { + MessageDialog.openInformation( + shell, + "glustersp-gui", + "New Action was executed."); + } + + /** + * @see IActionDelegate#selectionChanged(IAction, ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/VolumeLogRotateAction.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/VolumeLogRotateAction.java new file mode 100644 index 00000000..7477358c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/actions/VolumeLogRotateAction.java @@ -0,0 +1,64 @@ +package org.gluster.storage.management.console.actions; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.VolumeBricksView; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; + + + +public class VolumeLogRotateAction extends AbstractActionDelegate { + + private Volume volume; + private GUIHelper guiHelper = GUIHelper.getInstance(); + private Set bricks; + + @Override + public void dispose() { + } + + @Override + protected void performAction(IAction action) { + final String actionDesc = action.getDescription(); + List selectedBricks = new ArrayList(); + boolean confirmed = showConfirmDialog(actionDesc, + "Are you sure you want to Rotate logs for volume [" + volume.getName() + "] ? "); + if (!confirmed) { + return; + } + + if (bricks != null) { + selectedBricks = GlusterCoreUtil.getQualifiedBrickList(bricks); + } + try { + new VolumesClient().volumeLogRotate(volume.getName(), selectedBricks); + showInfoDialog(actionDesc, "Volume logs for [" + volume.getName() + "] rotated successfully!"); + } catch (Exception e) { + showErrorDialog(actionDesc, "Volume [" + volume.getName() + "] log rotation failed! Error: [" + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + volume = guiHelper.getSelectedEntity(window, Volume.class); + + if (volume != null) { + // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view + IWorkbenchPart view = guiHelper.getActiveView(); + if (view instanceof VolumeBricksView) { + // volume bricks view is open. check if any brick is selected + bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); + } + } + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickPage.java new file mode 100644 index 00000000..df42f12a --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickPage.java @@ -0,0 +1,171 @@ +/** + * AddDiskPage.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.dialogs; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; + +import com.richclientgui.toolbox.duallists.DualListComposite.ListContentChangedListener; +import com.richclientgui.toolbox.duallists.IRemovableContentProvider; + +/** + * @author root + * + */ +public class AddBrickPage extends WizardPage { + private List availableDevices = new ArrayList(); + private List selectedDevices = new ArrayList(); + private Volume volume = null; + private BricksSelectionPage page = null; + + + public static final String PAGE_NAME = "add.disk.volume.page"; + + /** + * @param pageName + */ + protected AddBrickPage(Volume volume) { + super(PAGE_NAME); + this.volume = volume; + setTitle("Add Brick"); + + String description = "Add bricks to [" + volume.getName() + "] "; + if ( volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { + description += "(in multiples of " + volume.getReplicaCount() + ")"; + } else if (volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + description += "(in multiples of " + volume.getStripeCount() + ")"; + } + setDescription(description); + + availableDevices = getAvailableDevices(volume); + + setPageComplete(false); + setErrorMessage("Please select bricks to be added to the volume [" + volume.getName() +"]"); + } + + + private boolean isDeviceUsed(Volume volume, Device device){ + for (Brick volumeBrick : volume.getBricks()) { + if ( device.getQualifiedBrickName(volume.getName()).equals(volumeBrick.getQualifiedName())) { + return true; + } + } + return false; + } + + protected List getAvailableDevices(Volume volume) { + List availableDevices = new ArrayList(); + for (Device device : GlusterDataModelManager.getInstance().getReadyDevicesOfAllServers()) { + if ( ! isDeviceUsed(volume, device) ) { + availableDevices.add(device); + } + } + return availableDevices; + } + + public Set getChosenDevices() { + return new HashSet(page.getChosenDevices()); + } + + public Set getChosenBricks( String volumeName ) { + return page.getChosenBricks(volumeName); + } + + private boolean isValidDiskSelection(int diskCount) { + if ( diskCount == 0) { + return false; + } + switch (volume.getVolumeType()) { + case DISTRIBUTED_REPLICATE: + return (diskCount % volume.getReplicaCount() == 0); + case DISTRIBUTED_STRIPE: + return (diskCount % volume.getStripeCount() == 0); + } + return true; + } + + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createControl(Composite parent) { + getShell().setText("Add Brick"); + List chosenDevices = new ArrayList(); // or volume.getDisks(); + + page = new BricksSelectionPage(parent, SWT.NONE, availableDevices, chosenDevices, volume.getName()); + page.addDiskSelectionListener(new ListContentChangedListener() { + @Override + public void listContentChanged(IRemovableContentProvider contentProvider) { + List newChosenDevices = page.getChosenDevices(); + + // validate chosen disks + if(isValidDiskSelection(newChosenDevices.size())) { + clearError(); + } else { + setError(); + } + } + }); + setControl(page); + } + + private void setError() { + String errorMessage = null; + if ( volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTE) { + errorMessage = "Please select at least one brick!"; + } else if( volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { + errorMessage = "Please select bricks in multiples of " + volume.getReplicaCount(); + } else { + errorMessage = "Please select bricks in multiples of " + volume.getStripeCount(); + } + + setPageComplete(false); + setErrorMessage(errorMessage); + } + + private void clearError() { + setErrorMessage(null); + setPageComplete(true); + } + + public BricksSelectionPage getDialogPage() { + return this.page; + } + + public void setPageComplete() { + + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java new file mode 100644 index 00000000..da40f1d9 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/AddBrickWizard.java @@ -0,0 +1,96 @@ +/** + * AddDiskWizard.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.dialogs; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.Wizard; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.utils.StringUtil; + + +/** + * + */ +public class AddBrickWizard extends Wizard { + private AddBrickPage page; + private Volume volume; + + public AddBrickWizard(Volume volume) { + setWindowTitle("Gluster Management Console - Add Brick"); + setHelpAvailable(false); // TODO: Introduce wizard help + this.volume = volume; + } + + public void addPages() { + page = new AddBrickPage(volume); + addPage(page); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + @Override + public boolean performFinish() { + Set bricks = page.getChosenBricks(volume.getName()); + VolumesClient volumeClient = new VolumesClient(); + try { + Set brickList = getBrickList(bricks); + + volumeClient.addBricks(volume.getName(), brickList); + + // Update model with new bricks in the volume + GlusterDataModelManager.getInstance().addBricks(volume, bricks); + + MessageDialog.openInformation(getShell(), "Add brick(s) to Volume", "Volume [" + volume.getName() + + "] is expanded with bricks [" + StringUtil.collectionToString(brickList, ", ") + "]"); + return true; + } catch (Exception e) { + MessageDialog.openError(getShell(), "Add brick(s) to Volume", e.getMessage()); + return false; + } + } + + private Set getBrickList(Set bricks) { + Set brickList = new HashSet(); + for(Brick brick : bricks) { + brickList.add(brick.getServerName() + ":" + brick.getBrickDirectory()); + } + return brickList; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.wizard.Wizard#canFinish() + */ + @Override + public boolean canFinish() { + return super.canFinish() && page.isPageComplete(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/BricksSelectionPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/BricksSelectionPage.java new file mode 100644 index 00000000..99f6d201 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/BricksSelectionPage.java @@ -0,0 +1,336 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.TableLabelProviderAdapter; +import org.gluster.storage.management.console.utils.EntityViewerFilter; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + +import com.richclientgui.toolbox.duallists.CustomTableDualListComposite; +import com.richclientgui.toolbox.duallists.DualListComposite.ListContentChangedListener; +import com.richclientgui.toolbox.duallists.IRemovableContentProvider; +import com.richclientgui.toolbox.duallists.RemovableContentProvider; +import com.richclientgui.toolbox.duallists.TableColumnData; + +public class BricksSelectionPage extends Composite { + private enum DISK_TABLE_COLUMN_INDICES { + SERVER, BRICK_DIRECTORY, FREE_SPACE, TOTAL_SPACE + } + + private static final String[] DISK_TABLE_COLUMNS_NAMES = { "Server", "Brick Directory", "Free Space (GB)", + "Total Space (GB)" }; + + private GUIHelper guiHelper = GUIHelper.getInstance(); + private CustomTableDualListComposite dualTableViewer; + private Text filterText; + // This list keeps track of the order of the disks as user changes the same by clicking on up/down arrow buttons + private List chosenDevices = new ArrayList(); + + private IRemovableContentProvider chosenBricksContentProvider; + + private Button btnUp; + + private Button btnDown; + + public BricksSelectionPage(final Composite parent, int style, List allDevices, List selectedDevices, + String volumeName) { + super(parent, style); + + createPage(allDevices, selectedDevices, volumeName); + + parent.layout(); + } + + public void addDiskSelectionListener(ListContentChangedListener listener) { + dualTableViewer.addChosenListChangedSelectionListener(listener); + } + + private TableLabelProviderAdapter getDiskLabelProvider(final String volumeName) { + return new TableLabelProviderAdapter() { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Device)) { + return null; + } + + Device device = (Device) element; + return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? device.getServerName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY.ordinal() ? device.getMountPoint() + + "/" + volumeName + : columnIndex == DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? NumberUtil + .formatNumber((device.getFreeSpace() / 1024)) + : columnIndex == DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? NumberUtil + .formatNumber((device.getSpace() / 1024)) : "Invalid"); + } + }; + } + + private int indexOf(List disks, Disk searchDisk) { + for (Disk disk : disks) { + if (disk.getQualifiedName().equals(searchDisk.getQualifiedName())) { + return disks.indexOf(disk); + } + } + return -1; + } + + private void createPage(List allDevice, List selectedDevice, String volumeName) { + setupPageLayout(); + + filterText = guiHelper.createFilterText(this); + new Label(this, SWT.NONE); + + createDualTableViewer(allDevice, selectedDevice, volumeName); + createFilter(filterText, false); // attach filter text to the dual table viewer for auto-filtering + + Composite buttonContainer = new Composite(this, SWT.NONE); + buttonContainer.setLayout(new GridLayout(1, false)); + GridData buttonContainerData = new GridData(SWT.FILL, SWT.CENTER, true, true); + buttonContainerData.minimumWidth = 40; + buttonContainer.setLayoutData(buttonContainerData); + + btnUp = new Button(buttonContainer, SWT.PUSH); + GridData btnUpData = new GridData(SWT.LEFT, SWT.BOTTOM, true, false); + btnUpData.minimumWidth = 30; + btnUp.setLayoutData(btnUpData); + btnUp.setImage(guiHelper.getImage(IImageKeys.ARROW_UP_16x16)); + btnUp.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + chosenDevices = getChosenDevices(); + List selectedDevices = getSelectedChosenDevices(); + + chosenBricksContentProvider.removeElements(chosenDevices); + for (Device device : selectedDevices) { + int index = chosenDevices.indexOf(device); + Device deviceAbove = chosenDevices.get(index - 1); + chosenDevices.set(index - 1, device); + chosenDevices.set(index, deviceAbove); + } + chosenBricksContentProvider.addElements(chosenDevices); + dualTableViewer.refreshChosenViewer(); + updateButtons(); + } + }); + + btnDown = new Button(buttonContainer, SWT.PUSH); + GridData btnDownData = new GridData(SWT.LEFT, SWT.TOP, true, false); + btnDownData.minimumWidth = 30; + btnDown.setLayoutData(btnDownData); + btnDown.setImage(guiHelper.getImage(IImageKeys.ARROW_DOWN_16x16)); + btnDown.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + + chosenDevices = getChosenDevices(); + List selectedDevices = getSelectedChosenDevices(); + + chosenBricksContentProvider.removeElements(chosenDevices); + for (Device disk : selectedDevices) { + int index = chosenDevices.indexOf(disk); + Device deviceBelow = chosenDevices.get(index + 1); + chosenDevices.set(index + 1, disk); + chosenDevices.set(index, deviceBelow); + } + chosenBricksContentProvider.addElements(chosenDevices); + dualTableViewer.refreshChosenViewer(); + updateButtons(); + + } + }); + } + + private List getSelectedChosenDevices() { + TableItem[] selectedItems = dualTableViewer.getChosenTable().getSelection(); + List selectedDevices = new ArrayList(); + for (TableItem item : selectedItems) { + selectedDevices.add((Device) item.getData()); + } + return selectedDevices; + } + + private void createFilter(final Text filterText, boolean caseSensitive) { + final String initialFilterString = filterText.getText(); + + final EntityViewerFilter filter = new EntityViewerFilter(initialFilterString, caseSensitive); + // On every keystroke inside the text field, update the filter string + filterText.addKeyListener(new KeyAdapter() { + private String filterString = initialFilterString; + + @Override + public void keyReleased(KeyEvent e) { + String enteredString = filterText.getText(); + if (enteredString.equals(filterString)) { + // Filter string has not changed. don't do anything + return; + } + + // Update filter string + filterString = enteredString; + filter.setFilterString(filterString); + + // Refresh viewer with newly filtered content + dualTableViewer.refreshAvailableViewer(); + dualTableViewer.refreshChosenViewer(); + } + }); + + dualTableViewer.setAvailableViewerFilter(filter); + dualTableViewer.setChosenViewerFilter(filter); + } + + private void createDualTableViewer(List allDevices, List selectedDevices, String volumeName) { + TableColumnData[] columnData = createColumnData(); + ITableLabelProvider diskLabelProvider = getDiskLabelProvider(volumeName); + + dualTableViewer = new CustomTableDualListComposite(this, SWT.NONE, columnData, columnData); + + dualTableViewer.setViewerLabels("Available:", "Selected:"); + + dualTableViewer.setAvailableTableLinesVisible(false); + dualTableViewer.setAvailableTableHeaderVisible(true); + dualTableViewer.setAvailableContentProvider(new RemovableContentProvider(getAvailableDevice(allDevices, + selectedDevices))); + dualTableViewer.setAvailableLabelProvider(diskLabelProvider); + + dualTableViewer.setChosenTableLinesVisible(true); + dualTableViewer.setChosenTableHeaderVisible(true); + + chosenBricksContentProvider = new RemovableContentProvider(selectedDevices); + dualTableViewer.setChosenContentProvider(chosenBricksContentProvider); + dualTableViewer.setChosenLabelProvider(diskLabelProvider); + + dualTableViewer.getChosenTable().addSelectionListener(new SelectionAdapter() { + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected(SelectionEvent e) { + updateButtons(); + } + }); + } + + private void updateButtons() { + btnUp.setEnabled(true); + btnDown.setEnabled(true); + List selectedChosenDevices = getSelectedChosenDevices(); + List chosenDevices = getChosenDevices(); + for (Device device : selectedChosenDevices) { + int index = chosenDevices.indexOf(device); + if (index == 0) { + btnUp.setEnabled(false); + } + if (index == chosenDevices.size() - 1) { + btnDown.setEnabled(false); + } + } + } + + /** + * @param allDevices + * @param selectedDevices + * @return + */ + private List getAvailableDevice(List allDevices, List selectedDevices) { + List availableDevices = new ArrayList(); + for (Device device : allDevices) { + if (!selectedDevices.contains(device)) { + availableDevices.add(device); + } + } + return availableDevices; + } + + private TableColumnData[] createColumnData() { + DISK_TABLE_COLUMN_INDICES[] columns = DISK_TABLE_COLUMN_INDICES.values(); + TableColumnData[] columnData = new TableColumnData[columns.length]; + int columnNum; + for (DISK_TABLE_COLUMN_INDICES column : columns) { + columnNum = column.ordinal(); + columnData[columnNum] = new TableColumnData(columnNum, DISK_TABLE_COLUMNS_NAMES[columnNum], 100); + } + return columnData; + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(2, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + + setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + } + + public List getChosenDevices() { + Object[] devicesArr = chosenBricksContentProvider.getElements(dualTableViewer); + if (devicesArr != null) { + List devices = new ArrayList(); + for (Object device : devicesArr) { + devices.add((Device) device); + } + return devices; + } + return null; + } + + public Set getChosenBricks(String volumeName) { + Object[] bricksArr = chosenBricksContentProvider.getElements(dualTableViewer); + + if (bricksArr != null) { + Set bricks = new HashSet(); + for (Object device : bricksArr) { + bricks.add(new Brick(((Device) device).getServerName(), BRICK_STATUS.ONLINE, ((Device) device) + .getMountPoint() + "/" + volumeName)); // Assumption mount point is not having trailing "/" + } + return bricks; + } + return null; + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ChangePasswordDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ChangePasswordDialog.java new file mode 100644 index 00000000..09b4b08c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ChangePasswordDialog.java @@ -0,0 +1,284 @@ +/** + * ChangePasswordDialog.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.dialogs; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.beans.PojoProperties; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.client.UsersClient; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.validators.StringRequiredValidator; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.ConnectionDetails; + + +public class ChangePasswordDialog extends Dialog { + public static final int RETURN_CODE_ERROR = 2; + private Text oldPassword; + private Text newPassword; + private Text confirmPassword; + private Button okButton; + + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Composite composite; + + private final ConnectionDetails connectionDetails = new ConnectionDetails("gluster", ""); + + public ChangePasswordDialog(Shell shell) { + super(shell); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText("Gluster Management Console"); + addEscapeListener(newShell); + } + + private void addEscapeListener(Shell shell) { + shell.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.ESC) { + cancelPressed(); + } + } + }); + } + + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + + guiHelper.centerShellInScreen(getShell()); + } + + private void configureDialogLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.numColumns = 2; + layout.marginLeft = 20; + layout.marginRight = 20; + layout.marginTop = 20; + layout.horizontalSpacing = 20; + layout.verticalSpacing = 20; + } + + // ------------------------------------------ + + private void createLabel(Composite composite, String label) { + Label passwordLabel = new Label(composite, SWT.NONE); + passwordLabel.setText(label); + passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private Text createPasswordText(Composite composite) { + Text field = new Text(composite, SWT.BORDER | SWT.PASSWORD); + GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); + layoutData.widthHint = convertWidthInCharsToPixels(32); + field.setLayoutData(layoutData); + return field; + } + + @Override + protected Control createDialogArea(Composite parent) { + // parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); + parent.setBackgroundMode(SWT.INHERIT_FORCE); + + composite = (Composite) super.createDialogArea(parent); + configureDialogLayout(composite); + + createLabel(composite, "Old Password:"); + oldPassword = createPasswordText(composite); + + createLabel(composite, "New Password:"); + newPassword = createPasswordText(composite); + + createLabel(composite, "Confirm Password:"); + confirmPassword = createPasswordText(composite); + + createListeners(); + + return composite; + } + + /** + * + */ + private void createListeners() { + ModifyListener listener = new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + updateButtonStatus(); + } + }; + + oldPassword.addModifyListener(listener); + newPassword.addModifyListener(listener); + confirmPassword.addModifyListener(listener); + } + + private void updateButtonStatus() { + String oldPwd = oldPassword.getText(); + String newPwd = newPassword.getText(); + String confirmPwd = confirmPassword.getText(); + if(oldPwd.isEmpty() || newPwd.isEmpty() || confirmPwd.isEmpty()) { + okButton.setEnabled(false); + return; + } + + if(!newPwd.equals(confirmPwd)) { + okButton.setEnabled(false); + return; + } + + if (confirmPwd.equals(CoreConstants.DEFAULT_PASSWORD) || isContainsWhiteSpace(confirmPwd)) { + okButton.setEnabled(false); + return; + } + + if (newPwd.length() < 4 ) { // Minimum password length is 4 + okButton.setEnabled(false); + return; + } + + okButton.setEnabled(true); + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + okButton = createButton(parent, IDialogConstants.OK_ID, "&Change", true); + okButton.setEnabled(false); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + + setupDataBinding(); + } + + public boolean isContainsWhiteSpace(String text) { + return text.matches(".*[\\s\\\\].*"); // White space or backslash + } + + public class ConfirmPasswordValidator extends StringRequiredValidator { + public ConfirmPasswordValidator(String errorText, ControlDecoration controlDecoration, Control linkedControl) { + super(errorText, controlDecoration, linkedControl); + } + + @Override + public IStatus validate(Object value) { + + IStatus status = super.validate(value); + if (status.isOK()) { + String errMsg = null; + if (errMsg == null && isContainsWhiteSpace( newPassword.getText())) { + errMsg = "Password should not contain space or back slash characters"; + } + + if (!value.equals(newPassword.getText())) { + errMsg = "Passwords mismatched"; + } + + if (errMsg == null && value.equals(CoreConstants.DEFAULT_PASSWORD)) { + errMsg = "New password should not be a default password"; + } + + if(errMsg != null) { + controlDecoration.setDescriptionText(errMsg); + controlDecoration.show(); + linkedControl.setEnabled(false); + return ValidationStatus.error(errMsg); + } + } + return status; + } + }; + + private void setupDataBinding() { + DataBindingContext dataBindingContext = new DataBindingContext(SWTObservables.getRealm(Display.getCurrent())); + UpdateValueStrategy passwordBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + UpdateValueStrategy newPwdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + UpdateValueStrategy confirmPwdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + + // The Validator shows error decoration and disables OK button on + // validation failure + passwordBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter old password!", + guiHelper.createErrorDecoration(oldPassword), null)); + + dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(oldPassword), + PojoProperties.value("password").observe(connectionDetails), passwordBindingStrategy, + passwordBindingStrategy); + + newPwdBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter new password!", guiHelper + .createErrorDecoration(newPassword), null)); + + dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(newPassword), + PojoProperties.value("newPassword").observe(connectionDetails), newPwdBindingStrategy, + newPwdBindingStrategy); + + confirmPwdBindingStrategy.setBeforeSetValidator(new ConfirmPasswordValidator("Please enter confirm password!", + guiHelper.createErrorDecoration(confirmPassword), null)); + + dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(confirmPassword), + PojoProperties.value("confirmNewPassword").observe(connectionDetails), confirmPwdBindingStrategy, + confirmPwdBindingStrategy); + } + + protected void okPressed() { + String user = connectionDetails.getUserId(); + String oldPassword = connectionDetails.getPassword(); + String newPassword = connectionDetails.getNewPassword(); + + UsersClient usersClient = new UsersClient(); + try { + usersClient.changePassword(user, oldPassword, newPassword); + MessageDialog.openInformation(getShell(), "Change password", "Password changed successfully!"); + this.close(); + } catch (Exception e) { + MessageDialog.openError(getShell(), "Change password Failed", e.getMessage()); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java new file mode 100644 index 00000000..44b9e963 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ClusterSelectionDialog.java @@ -0,0 +1,474 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StackLayout; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.ShellAdapter; +import org.eclipse.swt.events.ShellEvent; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.console.Activator; +import org.gluster.storage.management.console.ConsoleConstants; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.console.utils.GUIHelper; + + +/** + * Cluster selection dialog, which prompts for the cluster name to be managed + */ +public class ClusterSelectionDialog extends Dialog { + private static final String MESSAGE_SELECT_CLUSTER = "Select the Cluster you want to manage in this session."; + private static final String MESSAGE_CREATE_CLUSTER = "Create an empty Cluster and start adding servers to it."; + private static final String MESSAGE_REGISTER_CLUSTER = "Register an existing Cluster with the Management Gateway and start managing it using the Management Console."; + + protected enum CLUSTER_MODE { SELECT, CREATE, REGISTER }; + + private Combo clusterNameCombo = null; + private Text newClusterNameText = null; + private Text existingClusterNameText = null; + private Text serverNameText = null; + private Button okButton; + + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Composite composite; + private ControlDecoration newClusterNameErrorDecoration; + private ControlDecoration existingClusterNameErrorDecoration; + private ControlDecoration serverNameErrorDecoration; + private List clusters; + private Button selectButton; + private Button createButton; + private Button registerButton; + private Composite clusterSelectionComposite; + private Composite clusterCreationComposite; + private Composite clusterRegisterComposite; + private StackLayout stackLayout; + + private String clusterName; + private CLUSTER_MODE clusterMode; + private String serverName; + private Button dontAskAgainButton; + IPreferenceStore preferenceStore; + + public ClusterSelectionDialog(Shell parentShell, List clusters) { + super(parentShell); + this.clusters = clusters; + preferenceStore = Activator.getDefault().getPreferenceStore(); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText("Gluster Management Console - Select Cluster"); + addEscapeListener(newShell); + } + + private void addEscapeListener(Shell shell) { + shell.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.ESC) { + cancelPressed(); + } + } + }); + } + + private void createClusterNameLabel(Composite composite) { + Label clusterNameLabel = new Label(composite, SWT.NONE); + clusterNameLabel.setText("Cluster &Name:"); + clusterNameLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private void createClusterNameCombo(Composite composite) { + clusterNameCombo = new Combo(composite, SWT.READ_ONLY); + clusterNameCombo.setItems(clusters.toArray(new String[0])); + clusterNameCombo.select(0); + + String clusterName = preferenceStore.getString(PreferenceConstants.P_DEFAULT_CLUSTER_NAME); + if(clusterName != null && !clusterName.isEmpty()) { + selectCluster(clusterName); + } + } + + public void selectCluster(String clusterName) { + for(int i = 0; i < clusters.size(); i++) { + if(clusterNameCombo.getItem(i).equals(clusterName)) { + clusterNameCombo.select(i); + break; + } + } + } + + private void configureDialogLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.numColumns = 3; + layout.marginLeft = 20; + layout.marginRight = 20; + layout.marginTop = 20; + layout.horizontalSpacing = 20; + layout.verticalSpacing = 20; + } + + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + + guiHelper.centerShellInScreen(getShell()); + } + + @Override + protected Control createDialogArea(Composite parent) { + //parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); + // Makes sure that child composites inherit the same background + parent.setBackgroundMode(SWT.INHERIT_FORCE); + + composite = (Composite) super.createDialogArea(parent); + configureDialogLayout(composite); + + createRadioButtons(); + createSubComposites(); + + setupAutoSelectionIfRequired(); + + return composite; + } + + private void setupAutoSelectionIfRequired() { + if (clusters.size() == 0) { + return; + } + + final String clusterName = System.getProperty(ConsoleConstants.PROPERTY_AUTO_CLUSTER_NAME, null); + if (clusterName == null) { + return; + } + + getShell().addShellListener(new ShellAdapter() { + @Override + public void shellActivated(ShellEvent e) { + super.shellActivated(e); + clusterNameCombo.setText(clusterName); + okPressed(); + } + }); + } + + + private void createSubComposites() { + Composite subComposite = new Composite(composite, SWT.NONE); + GridData data = new GridData(); + data.horizontalSpan = 3; + subComposite.setLayoutData(data); + stackLayout = new StackLayout(); + subComposite.setLayout(stackLayout); + + createClusterSelectionComposite(subComposite, stackLayout); + createClusterCreationComposite(subComposite); + createClusterRegisterComposite(subComposite); + + createRadioButtonListeners(subComposite); + if(clusters.size() > 0) { + selectButton.setSelection(true); + stackLayout.topControl = clusterSelectionComposite; + clusterNameCombo.setFocus(); + } else { + createButton.setSelection(true); + stackLayout.topControl = clusterCreationComposite; + newClusterNameText.setFocus(); + } + subComposite.layout(); + } + + private void createClusterRegisterComposite(Composite composite) { + clusterRegisterComposite = new Composite(composite, SWT.NONE); + GridLayout layout = new GridLayout(2, false); + layout.horizontalSpacing = 15; + clusterRegisterComposite.setLayout(layout); + + createClusterNameLabel(clusterRegisterComposite); + existingClusterNameText = createText(clusterRegisterComposite); + existingClusterNameText.setToolTipText("Enter a name for the cluster being registered."); + existingClusterNameErrorDecoration = createErrorDecoration(existingClusterNameText, "Please enter a cluster name!"); + existingClusterNameErrorDecoration.show(); + + createClusterServerLabel(clusterRegisterComposite); + serverNameText = createText(clusterRegisterComposite); + serverNameText.setToolTipText("Enter host name / IP address of one of the servers of the cluster."); + serverNameErrorDecoration = createErrorDecoration(serverNameText, "Please enter a server name!"); + serverNameErrorDecoration.show(); + } + + private void createClusterServerLabel(Composite composite) { + Label serverNameLabel = new Label(composite, SWT.NONE); + serverNameLabel.setText("Server Na&me:"); + serverNameLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private void createClusterCreationComposite(Composite subComposite) { + clusterCreationComposite = new Composite(subComposite, SWT.NONE); + GridLayout layout = new GridLayout(2, false); + layout.horizontalSpacing = 15; + clusterCreationComposite.setLayout(layout); + + createClusterNameLabel(clusterCreationComposite); + newClusterNameText = createText(clusterCreationComposite); + newClusterNameText.setToolTipText("Enter name of the cluster to be created"); + newClusterNameErrorDecoration = createErrorDecoration(newClusterNameText, "Please enter cluster name!"); + newClusterNameErrorDecoration.show(); + } + + private Text createText(Composite parent) { + Text text = new Text(parent, SWT.NONE); + GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); + int width = convertWidthInCharsToPixels(32); + layoutData.widthHint = width; + layoutData.minimumWidth = width; + text.setLayoutData(layoutData); + + text.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + return text; + } + + private void createClusterSelectionComposite(Composite subComposite, StackLayout stackLayout) { + clusterSelectionComposite = new Composite(subComposite, SWT.NONE); + GridLayout layout = new GridLayout(2, false); + clusterSelectionComposite.setLayout(layout); + + createClusterNameLabel(clusterSelectionComposite); + createClusterNameCombo(clusterSelectionComposite); + createPreferenceCheckbox(clusterSelectionComposite); + + stackLayout.topControl = clusterSelectionComposite; + } + + private void createPreferenceCheckbox(Composite composite) { + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); + layoutData.verticalIndent = 5; + layoutData.horizontalSpan = 2; + + dontAskAgainButton = new Button(composite, SWT.CHECK); + dontAskAgainButton.setLayoutData(layoutData); + dontAskAgainButton.setText("&Don't ask again"); + dontAskAgainButton.setEnabled(true); + dontAskAgainButton.setSelection(false); + dontAskAgainButton.setToolTipText("Always manage the selected cluster without showing this dialog box." + + "This preference can later be changed from the \"Settings\" menu."); + } + + private void createRadioButtons() { + { + if (clusters.size() > 0) { + selectButton = new Button(composite, SWT.RADIO); + selectButton.setText("&Select"); + selectButton.setToolTipText(MESSAGE_SELECT_CLUSTER); + } + } + { + createButton = new Button(composite, SWT.RADIO); + createButton.setText("&Create"); + createButton.setToolTipText(MESSAGE_CREATE_CLUSTER); + } + { + registerButton = new Button(composite, SWT.RADIO); + registerButton.setText("&Register"); + registerButton.setToolTipText(MESSAGE_REGISTER_CLUSTER); + } + } + + private void validate() { + okButton.setEnabled(false); + + if(selectButton != null && selectButton.getSelection()) { + okButton.setEnabled(true); + return; + } + + if(createButton.getSelection()) { + String newClusterName = newClusterNameText.getText().trim(); + if(newClusterName.isEmpty()) { + newClusterNameErrorDecoration.setDescriptionText("Please enter a cluster name!"); + newClusterNameErrorDecoration.show(); + } else if(clusters.contains(newClusterName)) { + newClusterNameErrorDecoration.setDescriptionText("Cluster [" + newClusterName + "] already exists!"); + newClusterNameErrorDecoration.show(); + } else { + okButton.setEnabled(true); + newClusterNameErrorDecoration.hide(); + } + } + + if(registerButton.getSelection()) { + okButton.setEnabled(true); + String clusterName = existingClusterNameText.getText().trim(); + if(existingClusterNameText.getText().trim().isEmpty()) { + existingClusterNameErrorDecoration.setDescriptionText("Please enter a cluster name!"); + existingClusterNameErrorDecoration.show(); + okButton.setEnabled(false); + } else if(clusters.contains(clusterName)) { + existingClusterNameErrorDecoration.setDescriptionText("Cluster [" + clusterName + "] already exists!"); + existingClusterNameErrorDecoration.show(); + okButton.setEnabled(false); + } else { + existingClusterNameErrorDecoration.hide(); + } + + if(serverNameText.getText().trim().isEmpty()) { + serverNameErrorDecoration.show(); + okButton.setEnabled(false); + } else { + serverNameErrorDecoration.hide(); + } + } + } + + private void createRadioButtonListeners(final Composite parent) { + if (clusters.size() > 0) { + selectButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + stackLayout.topControl = clusterSelectionComposite; + clusterNameCombo.select(0); + validate(); + parent.layout(); + clusterNameCombo.setFocus(); + } + }); + } + createButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + stackLayout.topControl = clusterCreationComposite; + validate(); + parent.layout(); + newClusterNameText.setFocus(); + } + }); + registerButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + stackLayout.topControl = clusterRegisterComposite; + validate(); + parent.layout(); + existingClusterNameText.setFocus(); + } + }); + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + + setupDataBinding(); + } + + private ControlDecoration createErrorDecoration(Text text, String message) { + ControlDecoration errorDecoration = guiHelper.createErrorDecoration(text); + errorDecoration.setDescriptionText(message); + errorDecoration.hide(); + return errorDecoration; + } + + /** + * Sets up data binding between the text fields and the connection details object. Also attaches a "string required" + * validator to the "password" text field. This validator is configured to do the following on validation failure
    + *
  • show an ERROR decorator
  • disable the "Login" button + */ + private void setupDataBinding() { + clusterNameCombo.addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + if(clusterNameCombo.getText().trim().isEmpty()) { + okButton.setEnabled(false); + newClusterNameErrorDecoration.show(); + } else { + okButton.setEnabled(true); + newClusterNameErrorDecoration.hide(); + } + } + }); + } + + @Override + protected void okPressed() { + if(selectButton != null && selectButton.getSelection()) { + clusterMode = CLUSTER_MODE.SELECT; + clusterName = clusterNameCombo.getText(); + + if(dontAskAgainButton.getSelection()) { + preferenceStore.setValue(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, false); + preferenceStore.setValue(PreferenceConstants.P_DEFAULT_CLUSTER_NAME, clusterName); + } else { + preferenceStore.setValue(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, true); + } + } else if(createButton.getSelection()) { + clusterMode = CLUSTER_MODE.CREATE; + clusterName = newClusterNameText.getText().trim(); + } else if(registerButton.getSelection()) { + clusterMode = CLUSTER_MODE.REGISTER; + clusterName = existingClusterNameText.getText().trim(); + serverName = serverNameText.getText().trim(); + } + super.okPressed(); + } + + public String getClusterName() { + return clusterName; + } + + public CLUSTER_MODE getClusterMode() { + return clusterMode; + } + + public String getServerName() { + return serverName; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumePage1.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumePage1.java new file mode 100644 index 00000000..9f1ec929 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumePage1.java @@ -0,0 +1,473 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; +import org.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.utils.ValidationUtil; + + +public class CreateVolumePage1 extends WizardPage { + public static final String PAGE_NAME = "create.volume.page.1"; + private Text txtName; + private ComboViewer typeComboViewer; + private Text txtAccessControl; + private Text txtCifsUsers; + private Volume volume = new Volume(); + private Button btnNfs; + private Button btnCIFS; + private Button btnStartVolume; + private Link linkCustomize; + private List allDevices; + private List selectedDevices; + + /** + * Create the wizard. + */ + public CreateVolumePage1() { + super(PAGE_NAME); + setTitle("Create Volume"); + setDescription("Create a new Volume by choosing bricks from the cluster servers and configuring the volume properties."); + + // by default, we create volume with all available disks + allDevices = GlusterDataModelManager.getInstance().getReadyDevicesOfAllServers(); + selectedDevices = allDevices; // volume.setDisks(allDisks); + } + + /** + * Create contents of the wizard. + * @param parent + */ + public void createControl(Composite parent) { + setPageComplete(false); + Composite container = createContainer(parent); + + createEmptyRow(container); + + createNameLabel(container); + createNameText(container); + + createTypeLabel(container); + createTypeCombo(container); + +// createTransportTypeLabel(container); +// createTransportTypeValueLabel(container); + + createDisksLabel(container); + createDisksCustomizeLink(container); + + createNasProtocolLabel(container); + createNasProtocolCheckboxes(container); + + createCifsUserLabel(container); + createCifsUserText(container); + + createEmptyLabel(container); + createCifsUserInfoLabel(container); + + createAccessControlLabel(container); + createAccessControlText(container); + + createEmptyLabel(container); + createAccessControlInfoLabel(container); + + createStartVolumeLabel(container); + createStartVolumeCheckbox(container); + } + + private void createStartVolumeCheckbox(Composite container) { + btnStartVolume = new Button(container, SWT.CHECK); + btnStartVolume.setSelection(true); + } + + private void createStartVolumeLabel(Composite container) { + Label lblStartVolume = new Label(container, SWT.NONE); + lblStartVolume.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblStartVolume.setText("Start Volume: "); + } + + private void createCifsUserInfoLabel(Composite container) { + Label lblCifsUserInfo = new Label(container, SWT.TOP); + lblCifsUserInfo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblCifsUserInfo.setText("(Comma separated list user names)"); + } + + private void createAccessControlInfoLabel(Composite container) { + Label lblAccessControlInfo = new Label(container, SWT.TOP); + lblAccessControlInfo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); + lblAccessControlInfo.setText("(Comma separated list of IP addresses/hostnames)"); + } + + private void createEmptyLabel(Composite container) { + new Label(container, SWT.NONE); + } + + private void createAccessControlText(Composite container) { + txtAccessControl = new Text(container, SWT.BORDER); + txtAccessControl.setText("*"); + GridData accessControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + accessControlData.widthHint = 300; + txtAccessControl.setLayoutData(accessControlData); + txtAccessControl.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + validateForm(); + } + }); + } + + private void createAccessControlLabel(Composite container) { + Label lblAccessControl = new Label(container, SWT.NONE); + lblAccessControl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblAccessControl.setText("Allow Access From: "); + } + + private void createCifsUserLabel(Composite container) { + Label lblAccessControl = new Label(container, SWT.NONE); + lblAccessControl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblAccessControl.setText("CIFS Users: "); + } + + private void createCifsUserText(Composite container) { + txtCifsUsers = new Text(container, SWT.BORDER); +// txtCifsUsers.setText("testuser1,testuser2,testuser3"); + GridData cifsControlData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + cifsControlData.widthHint = 300; + txtCifsUsers.setLayoutData(cifsControlData); + txtCifsUsers.addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + validateForm(); + } + }); + } + + private void createNasProtocolCheckboxes(Composite container) { + Button btnGluster = new Button(container, SWT.CHECK); + btnGluster.setEnabled(false); + btnGluster.setSelection(true); + btnGluster.setText("Gluster"); + createEmptyLabel(container); + + btnNfs = new Button(container, SWT.CHECK); + btnNfs.setEnabled(true); + btnNfs.setSelection(true); + btnNfs.setText("NFS"); + createEmptyLabel(container); + + btnCIFS = new Button(container, SWT.CHECK); + btnCIFS.setEnabled(true); + btnCIFS.setSelection(false); + btnCIFS.setText("CIFS"); + btnCIFS.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + validateForm(); + } + @Override + public void widgetDefaultSelected(SelectionEvent e) { + validateForm(); + } + }); + } + + private void createNasProtocolLabel(Composite container) { + Label lblNasProtocol = new Label(container, SWT.RIGHT); + lblNasProtocol.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblNasProtocol.setText("Access Protocol: "); + } + + private void createDisksCustomizeLink(Composite container) { + linkCustomize = new Link(container, SWT.UNDERLINE_LINK); + linkCustomize.setText("All Brick(s) (customize)" ); + linkCustomize.setEnabled(false); + linkCustomize.addListener (SWT.Selection, new Listener () { + public void handleEvent(Event event) { + Display.getDefault().asyncExec(new Runnable() { + + @Override + public void run() { + SelectDisksDialog dialog = new SelectDisksDialog(getShell(), allDevices, selectedDevices, txtName.getText().trim()); + + dialog.create(); + if(dialog.open() == Window.OK) { + // user has customized disks. get them from the dialog box. + selectedDevices = dialog.getSelectedDevices(); + linkCustomize.setText("" + selectedDevices.size() + " Brick(s) (customize)"); + validateForm(); + } + } + }); + } + }); + } + + private void createDisksLabel(Composite container) { + Label lblDisks = new Label(container, SWT.RIGHT); + lblDisks.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblDisks.setText("Bricks: "); + } + + private void createTypeCombo(Composite container) { + typeComboViewer = new ComboViewer(container, SWT.READ_ONLY); + Combo typeCombo = typeComboViewer.getCombo(); + GridData typeComboData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + typeCombo.setLayoutData(typeComboData); + typeComboViewer.setContentProvider(new ArrayContentProvider()); + + VOLUME_TYPE[] volumeTypes = new VOLUME_TYPE[3]; + volumeTypes[0] = VOLUME_TYPE.DISTRIBUTE; + volumeTypes[1] = VOLUME_TYPE.REPLICATE; + volumeTypes[2] = VOLUME_TYPE.STRIPE; + + typeComboViewer.setInput(volumeTypes); + typeCombo.select(0); // default type = Plain Distribute + typeComboViewer.setLabelProvider(new LabelProvider() { + @Override + public String getText(Object element) { + return Volume.getVolumeTypeStr((VOLUME_TYPE)element); + } + }); + typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + validateForm(); + } + }); + } + + private void createTypeLabel(Composite container) { + Label lblType = new Label(container, SWT.NONE); + lblType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblType.setText("Type: "); + } + + private void createNameText(Composite container) { + txtName = new Text(container, SWT.BORDER); + GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + txtNameData.widthHint = 300; + txtName.setTextLimit(32); + txtName.setLayoutData(txtNameData); + txtName.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + validateForm(); + } + }); + } + + private void createNameLabel(Composite container) { + Label lblName = new Label(container, SWT.NONE); + lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblName.setText("Name: "); + } + + private void createEmptyRow(Composite container) { + createEmptyLabel(container); + createEmptyLabel(container); + } + + private Composite createContainer(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + setControl(container); + + GridLayout gl_container = new GridLayout(2, false); + gl_container.verticalSpacing = 10; + gl_container.marginHeight = 10; + gl_container.marginLeft = 20; + gl_container.horizontalSpacing = 10; + container.setLayout(gl_container); + return container; + } + + public Volume getVolume() { + volume.setName(txtName.getText()); + + IStructuredSelection selection = (IStructuredSelection)typeComboViewer.getSelection(); + volume.setVolumeType((VOLUME_TYPE)selection.getFirstElement()); + volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); + volume.setStripeCount(Volume.DEFAULT_STRIPE_COUNT); + + volume.setTransportType(TRANSPORT_TYPE.ETHERNET); // Support only for Ethernet + Set nasProtocols = new HashSet(); + nasProtocols.add(NAS_PROTOCOL.GLUSTERFS); + nasProtocols.add(NAS_PROTOCOL.NFS); + + volume.setAccessControlList(txtAccessControl.getText()); + + if (btnNfs.getSelection()) { + volume.enableNFS(); + } else { + volume.disableNFS(); + } + + if (btnCIFS.getSelection()) { + volume.enableCifs(); + volume.setCifsUsers(Arrays.asList(txtCifsUsers.getText().split(","))); + } else { + volume.disableCifs(); + } + + addVolumeBricks(); + return volume; + } + + private void addVolumeBricks() { + // first clear existing bricks, if any + volume.getBricks().clear(); + + for (Device device : selectedDevices) { + Brick brick = new Brick(device.getServerName(), BRICK_STATUS.ONLINE, device.getMountPoint() + "/" + + volume.getName()); + volume.addBrick(brick); + } + } + + public Boolean startVolumeAfterCreation() { + return btnStartVolume.getSelection(); + } + + public Boolean volumeExists(String volumeName) { + List volumes = GlusterDataModelManager.getInstance().getModel().getCluster().getVolumes(); + for (Volume volume : volumes) { + if (volume.getName().equals(volumeName)) { + setErrorMessage("Volume name already exists."); + return false; + } + } + return true; + } + + private void validateForm() { + clearErrors(); + validateVolumeName(); + validateCifsUsers(); + validateAccessControl(); + validateDisks(); + } + + private void validateDisks() { + int diskCount = selectedDevices.size(); + + if(diskCount < 1) { + setError("At least one brick must be selected!"); + } + + VOLUME_TYPE volumeType = (VOLUME_TYPE) ((IStructuredSelection) typeComboViewer + .getSelection()).getFirstElement(); + if ((volumeType == VOLUME_TYPE.DISTRIBUTED_REPLICATE || volumeType == VOLUME_TYPE.REPLICATE ) && diskCount % 2 != 0) { + setError("Mirror type volume requires bricks in multiples of two"); + } else if ((volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE || volumeType == VOLUME_TYPE.STRIPE) && diskCount % 4 != 0) { + setError("Stripe type volume requires bricks in multiples of four"); + } + } + + private void validateAccessControl() { + String accessControl = txtAccessControl.getText().trim(); + if (accessControl.length() == 0) { + setError("Please enter Access Control"); + return; + } + + if (!ValidationUtil.isValidAccessControl(accessControl)) { + setError("Invalid IP address/Host name [" + ValidationUtil.getInvalidIpOrHostname(accessControl) + + "]. Please enter a valid value!"); + } + } + + + private void validateCifsUsers() { + if (btnCIFS.getSelection()) { + String cifsUserList = txtCifsUsers.getText().trim(); + if (cifsUserList.length() == 0) { + setError("Please enter cifs user name"); + return; + } + } + } + + private void validateVolumeName() { + String volumeName = txtName.getText().trim(); + String volumeNameToken = "^[a-zA-Z][a-zA-Z0-9\\-]*"; + + if (volumeName.length() > 0) { + linkCustomize.setEnabled(true); + } + + if(volumeName.length() == 0) { + setError("Please enter Volume Name"); + linkCustomize.setEnabled(false); + } + + if (!volumeName.matches(volumeNameToken)) { + setError("Please enter valid Volume Name"); + } + + if(!volumeExists(volumeName)) { + setError("Volume [" + volumeName + "] already exists!"); + } + } + + private void clearErrors() { + setErrorMessage(null); + setPageComplete(true); + } + + private void setError(String errorMsg) { + setPageComplete(false); + setErrorMessage(errorMsg); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumeWizard.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumeWizard.java new file mode 100644 index 00000000..6aa81b7f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/CreateVolumeWizard.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.Wizard; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; + + +public class CreateVolumeWizard extends Wizard { + private static final String title = "Gluster Management Console - Create Volume"; + private CreateVolumePage1 page; + + public CreateVolumeWizard() { + setWindowTitle(title); + setHelpAvailable(false); // TODO: Introduce wizard help + } + + @Override + public void addPages() { + page = new CreateVolumePage1(); + addPage(page); + } + + @Override + public boolean performFinish() { + Volume newVolume = page.getVolume(); + VolumesClient volumesClient = new VolumesClient(); + + try { + List servers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (newVolume.isCifsEnable() && servers != null && servers.size() > 0) { + Integer userAction = new MessageDialog(getShell(), "Create Volume", GUIHelper.getInstance().getImage( + IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, new String[] { "No", + "Yes" }, -1).open(); + if (userAction != 1) { + return false; // To stay on the create dialog + } + } + + volumesClient.createVolume(newVolume); + + // Set proper volume type before assign to model + VOLUME_TYPE volumetype = newVolume.getVolumeType(); + if (volumetype == VOLUME_TYPE.REPLICATE && newVolume.getBricks().size() > newVolume.getReplicaCount()) { + newVolume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); + } else if (volumetype == VOLUME_TYPE.STRIPE && newVolume.getBricks().size() > newVolume.getStripeCount()) { + newVolume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); + } + + handleSuccess(newVolume, volumesClient); + } catch (Exception e) { + String errMsg = e.getMessage(); + // the error could be in to post-volume-create processing. check if this is the case. + if (volumesClient.volumeExists(newVolume.getName())) { + handlePartSuccess(newVolume, volumesClient, errMsg); + } else { + MessageDialog.openError(getShell(), title, "Volume creation failed! Error: " + errMsg); + return false; + } + } + + return true; + } + + public void handleSuccess(Volume newVolume, VolumesClient volumesClient) { + String message = "Volume created successfully!"; + newVolume.setStatus(VOLUME_STATUS.OFFLINE); + boolean warning = false; + if (page.startVolumeAfterCreation()) { + try { + volumesClient.startVolume(newVolume.getName(), false); + newVolume.setStatus(VOLUME_STATUS.ONLINE); + message = "Volume created and started successfully!"; + } catch(Exception e) { + message = "Volume created successfuly, but couldn't be started. Error: " + e.getMessage(); + warning = true; + } + } + + // update the model + GlusterDataModelManager.getInstance().addVolume(newVolume); + if (warning) { + MessageDialog.openWarning(getShell(), title, message); + } else { + MessageDialog.openInformation(getShell(), title, message); + } + } + + public void handlePartSuccess(Volume newVolume, VolumesClient volumesClient, String errMsg) { + // volume exists. error was in post-volume-create + newVolume.setStatus(VOLUME_STATUS.OFFLINE); + boolean error = false; + String message1 = null; + if (page.startVolumeAfterCreation()) { + if (MessageDialog.openConfirm(getShell(), title, "Volume created, but following error(s) occured: " + + errMsg + CoreConstants.NEWLINE + CoreConstants.NEWLINE + + "Do you still want to start the volume [" + newVolume.getName() + "]?")) { + try { + volumesClient.startVolume(newVolume.getName(), false); + newVolume.setStatus(VOLUME_STATUS.ONLINE); + message1 = "Volume [" + newVolume.getName() + "] started successfully!"; // Only start operation + } catch(Exception e1) { + message1 = "Volume couldn't be started. Error: " + e1.getMessage(); + error = true; + } + } + + if (error) { + MessageDialog.openWarning(getShell(), title, message1); + } else if (message1.trim().length() > 0) { + MessageDialog.openInformation(getShell(), title, message1); + } + } else { // Start volume is not checked + MessageDialog.openWarning(getShell(), title, + "Volume created, but following error(s) occured: " + errMsg); + } + + // Fetching actual volume info (because of partial success) + Volume volume = newVolume; + try { + volume = volumesClient.getVolume(newVolume.getName()); + }catch (Exception e) { + GlusterLogger.getInstance().error("Fetching volume details failed:" + e.getMessage()); + } + GlusterDataModelManager.getInstance().addVolume(volume); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/GlusterSupportDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/GlusterSupportDialog.java new file mode 100644 index 00000000..6eb414f5 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/GlusterSupportDialog.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.FormDialog; +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormText; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.gluster.storage.management.console.utils.GUIHelper; + + +public class GlusterSupportDialog extends FormDialog { + + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private FormToolkit toolkit; + private ScrolledForm form; + private Composite parent; + + public GlusterSupportDialog(Shell shell) { + super(shell); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + this.parent = newShell; + newShell.setText("Gluster Management Console - Support Information"); + } + + protected void createFormContent(IManagedForm mform) { + form = mform.getForm(); + toolkit = mform.getToolkit(); + form.getBody().setLayout(new GridLayout()); + createSections(); + } + + private void createSections() { + contactGlusterSupportSection(); + commingSoonSection(); + form.layout(); + form.getParent().layout(); + } + + + private void contactGlusterSupportSection() { + Composite section = guiHelper.createSection(form, toolkit, "Contact Gluster Support", null, 1, false); + + FormText formText = toolkit.createFormText(section, false); + toolkit.createLabel(section, "Call 1-800-805-5215", SWT.NONE); + toolkit.createLabel(section, "or", SWT.NONE); + toolkit.createLabel(section, "Email:support@gluster.com", SWT.NONE); +// String supportInfo = "
    " + +// "Call 1-800-805-5215
    " + +// "or
    " + +// "Email:support@gluster.com" + +// "
    "; +// formText.setText(supportInfo, true, true); + GridData layoutData = new GridData(); + layoutData.widthHint = 730; + layoutData.grabExcessHorizontalSpace = true; + formText.setLayoutData(layoutData); + } + + private void commingSoonSection() { + Composite section = guiHelper.createSection(form, toolkit, "Coming Soon", null, 7, false); + FormText formText = toolkit.createFormText(section, true); + String commingSoonInfo = "
    " + + "The following features of GlusterFS will soon be supported in upcoming releases of Gluster Management Console " + + "
  • Geo-replication
  • " + + "
  • Directory Quota
  • " + + "
  • Top and Profile
  • " + + "
  • POSIX ACLs Support

  • " + + "More information about these features can be found at
    " + + "http://www.gluster.com/community/documentation/index.php/Gluster_3.2:_What_is_New_in_this_Release" + + "
    "; + formText.setText(commingSoonInfo, true, true); + GridData layoutData = new GridData(); + layoutData.widthHint = 700; + layoutData.grabExcessHorizontalSpace = true; + formText.setLayoutData(layoutData); + formText.addHyperlinkListener(new HyperlinkAdapter() { + public void linkActivated(HyperlinkEvent e) { + System.out.println("Link activated: " + e.getHref()); + try { + PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() + .openURL(new URL((String) e.getHref())); + } catch (PartInitException e1) { + e1.printStackTrace(); + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + } + }); + } + + @Override + protected Control createButtonBar(Composite parent) { + return null; + } + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + guiHelper.centerShellInScreen(getShell()); + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/InitDiskDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/InitDiskDialog.java new file mode 100644 index 00000000..4d06fd3a --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/InitDiskDialog.java @@ -0,0 +1,212 @@ +/******************************************************************************* + * + * InitializeDiskTypeSelection.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.gluster.storage.management.console.utils.GUIHelper; + + +public class InitDiskDialog extends Dialog { + + private Combo formatTypeCombo = null; + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Composite initializeDiskTypeComposite; + private Composite composite; + private String fsType; + private String mountPoint; + private Text mountPointText; + private String deviceName; + private List fsTypes; + private static final String DEFAULT_MOUNT_POINT = "/export/"; + + public InitDiskDialog(Shell parentShell, String deviceName, List fsTypes) { + super(parentShell); + this.fsTypes = fsTypes; + this.deviceName = deviceName; + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText("Gluster Management Console - Select File System Type"); + addEscapeListener(newShell); + } + + private void addEscapeListener(Shell shell) { + shell.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.ESC) { + cancelPressed(); + } + } + }); + } + + @Override + protected Control createDialogArea(Composite parent) { + // Makes sure that child composites inherit the same background + parent.setBackgroundMode(SWT.INHERIT_FORCE); + + composite = (Composite) super.createDialogArea(parent); + configureDialogLayout(composite); + createComposite(composite); + return composite; + } + + private void configureDialogLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.numColumns = 3; + layout.marginLeft = 20; + layout.marginRight = 20; + layout.marginTop = 20; + layout.horizontalSpacing = 20; + layout.verticalSpacing = 20; + } + + private void createComposite(Composite composite) { + initializeDiskTypeComposite = new Composite(composite, SWT.NONE); + GridLayout layout = new GridLayout(3, false); + initializeDiskTypeComposite.setLayout(layout); + + createLabel(initializeDiskTypeComposite, "File system "); + createFormatTypeCombo(initializeDiskTypeComposite); + createLabel(initializeDiskTypeComposite, "Mount point "); + createMountPointText(initializeDiskTypeComposite); + createChangeLink(initializeDiskTypeComposite); + } + + private void createLabel(Composite composite, String labelText) { + Label formatTypeLabel = new Label(composite, SWT.NONE); + formatTypeLabel.setText(labelText); + formatTypeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false)); + } + + private void createFormatTypeCombo(Composite composite) { + formatTypeCombo = new Combo(composite, SWT.READ_ONLY); + formatTypeCombo.setItems(fsTypes.toArray(new String[0])); + formatTypeCombo.select(0); + new Label(composite, SWT.NONE); + } + + private void createMountPointText(Composite container) { + mountPointText = new Text(container, SWT.BORDER); + GridData txtNameData = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + txtNameData.widthHint = 400; + mountPointText.setTextLimit(100); + mountPointText.setLayoutData(txtNameData); + mountPointText.setText(DEFAULT_MOUNT_POINT + deviceName); + mountPointText.setEnabled(false); + mountPointText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + validateMountPoint(); + } + }); + } + + private void createChangeLink(Composite container) { + final Hyperlink changeLink = new Hyperlink(container, SWT.UNDERLINE_SINGLE); + changeLink.setText("change"); + changeLink.setUnderlined(true); + changeLink.setForeground(new Color(Display.getDefault(), 0, 0, 255)); + + changeLink.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { + if (!mountPointText.isEnabled()) { + changeLink.setVisible(false); + mountPointText.setEnabled(true); + } + } + }); + } + + @Override + protected void okPressed() { + fsType = formatTypeCombo.getText().trim(); + mountPoint = mountPointText.getText().trim(); + if (validateForm()) { + super.okPressed(); + } else { + MessageDialog.openError(getShell(), "Initialize Disk - Error", "Please enter a valid mount point"); + } + } + + @Override + public void cancelPressed() { + super.cancelPressed(); + } + + private boolean validateMountPoint() { + String mountPoint = mountPointText.getText().trim(); + if (mountPoint.isEmpty()) { + return false; + } + return mountPoint.matches("^/.+"); + } + + private boolean validateForm() { + return (!formatTypeCombo.getText().trim().isEmpty() && validateMountPoint()); + } + + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + + guiHelper.centerShellInScreen(getShell()); + } + + public String getFSType() { + return fsType; + } + + public String getMountPoint() { + return mountPoint; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/LoginDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/LoginDialog.java new file mode 100644 index 00000000..ccbea44f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/LoginDialog.java @@ -0,0 +1,359 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.beans.PojoProperties; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.databinding.swt.SWTObservables; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ShellAdapter; +import org.eclipse.swt.events.ShellEvent; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.client.ClustersClient; +import org.gluster.storage.management.client.UsersClient; +import org.gluster.storage.management.console.Activator; +import org.gluster.storage.management.console.ConsoleConstants; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.dialogs.ClusterSelectionDialog.CLUSTER_MODE; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.validators.StringRequiredValidator; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.ConnectionDetails; + + +/** + * Login dialog, which prompts for the user's account info, and has Login and Cancel buttons. + */ +public class LoginDialog extends Dialog { + public static final int RETURN_CODE_ERROR = 2; + private Text userIdText = null; + private Text passwordText = null; + private Button okButton; + + private final ConnectionDetails connectionDetails = new ConnectionDetails("gluster", ""); + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Composite composite; + + public LoginDialog(Shell parentShell) { + super(parentShell); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText("Gluster Management Console"); + addEscapeListener(newShell); + } + + private void addEscapeListener(Shell shell) { + shell.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.ESC) { + cancelPressed(); + } + } + }); + } + + private void createUserIdLabel(Composite composite) { + Label userIdLabel = new Label(composite, SWT.NONE); + userIdLabel.setText("&User ID:"); + userIdLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private void createUserIdText(Composite composite) { + userIdText = new Text(composite, SWT.BORDER); + userIdText.setText("gluster"); + userIdText.setEnabled(false); + + GridData layoutData = new GridData(convertWidthInCharsToPixels(32), 15); + userIdText.setLayoutData(layoutData); + } + + private void createPasswordLabel(Composite composite) { + Label passwordLabel = new Label(composite, SWT.NONE); + passwordLabel.setText("&Password:"); + passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private void createPasswordText(Composite composite) { + passwordText = new Text(composite, SWT.BORDER | SWT.PASSWORD); + + GridData layoutData = new GridData(convertWidthInCharsToPixels(32), 15); + passwordText.setLayoutData(layoutData); + } + + private void configureDialogLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.numColumns = 2; + layout.marginLeft = 10; + layout.marginRight = 10; + layout.marginTop = 30; + layout.marginBottom = 0; + layout.horizontalSpacing = 20; + layout.verticalSpacing = 10; + } + + private void configureButtonCompositeLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.marginLeft = 20; + layout.marginRight = 20; + layout.marginTop = 0; + layout.horizontalSpacing = 10; + layout.verticalSpacing = 10; + } + + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + + getShell().setSize(390, 240); + guiHelper.centerShellInScreen(getShell()); + } + + @Override + protected Control createDialogArea(Composite parent) { + parent.setBackgroundImage(guiHelper.getImage(IImageKeys.DIALOG_SPLASH_IMAGE)); + // Makes sure that child composites inherit the same background + parent.setBackgroundMode(SWT.INHERIT_FORCE); + + composite = (Composite) super.createDialogArea(parent); + configureDialogLayout(composite); + GridData layoutData = new GridData(390, 110); + composite.setLayoutData(layoutData); + + createUserIdLabel(composite); + createUserIdText(composite); + + createPasswordLabel(composite); + createPasswordText(composite); + + setupAutoLoginIfRequired(); + return composite; + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + configureButtonCompositeLayout(parent); + + GridData layoutData = new GridData(390, 130); + layoutData.horizontalAlignment = SWT.CENTER; + layoutData.verticalAlignment = SWT.TOP; + layoutData.grabExcessHorizontalSpace = true; + parent.setLayoutData(layoutData); + + layoutData = new GridData(); + layoutData.widthHint = 70; + layoutData.horizontalAlignment = SWT.RIGHT; + layoutData.grabExcessHorizontalSpace = true; + + Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", false); + cancelButton.setLayoutData(layoutData); + + layoutData = new GridData(); + layoutData.widthHint = 70; + layoutData.horizontalAlignment = SWT.LEFT; + layoutData.grabExcessHorizontalSpace = true; + + okButton = createButton(parent, IDialogConstants.OK_ID, "&Login", true); + okButton.setLayoutData(layoutData); + + setupDataBinding(); + } + + private void setupAutoLoginIfRequired() { + final String password = System.getProperty(ConsoleConstants.PROPERTY_AUTO_LOGIN_PASSWORD, null); + if (password == null) { + return; + } + getShell().addShellListener(new ShellAdapter() { + @Override + public void shellActivated(ShellEvent e) { + super.shellActivated(e); + + if (passwordText.getText().isEmpty()) { + // Check whether the password has been passed as system parameter. This can be used for avoiding + // human intervention on login dialog while running SWTBot automated tests. + passwordText.setText(password); + okPressed(); + } + } + }); + } + + /** + * Sets up data binding between the text fields and the connection details object. Also attaches a "string required" + * validator to the "password" text field. This validator is configured to do the following on validation failure
    + *
  • show an ERROR decorator
  • disable the "Login" button + */ + private void setupDataBinding() { + DataBindingContext dataBindingContext = new DataBindingContext(SWTObservables.getRealm(Display.getCurrent())); + UpdateValueStrategy passwordBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + + // The Validator shows error decoration and disables OK button on + // validation failure + passwordBindingStrategy.setBeforeSetValidator(new StringRequiredValidator("Please enter password!", guiHelper + .createErrorDecoration(passwordText), okButton)); + + dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(passwordText), + PojoProperties.value("password").observe(connectionDetails), passwordBindingStrategy, + passwordBindingStrategy); + + UpdateValueStrategy userIdBindingStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); + dataBindingContext + .bindValue(WidgetProperties.text(SWT.Modify).observe(userIdText), PojoProperties.value("userId") + .observe(connectionDetails), userIdBindingStrategy, userIdBindingStrategy); + } + + protected void okPressed() { + String user = connectionDetails.getUserId(); + String password = connectionDetails.getPassword(); + + UsersClient usersClient = new UsersClient(); + try { + usersClient.authenticate(user, password); + } catch(Exception e) { + MessageDialog.openError(getShell(), "Authentication Failed", e.getMessage()); + setReturnCode(RETURN_CODE_ERROR); + return; + } + + // authentication successful. close the login dialog and open the next one. + close(); + + IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + boolean showClusterSelectionDialog = preferenceStore.getBoolean(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG); + + // If the password is default, Let user to change the password + if (password.equalsIgnoreCase(CoreConstants.DEFAULT_PASSWORD)) { + String oldSecurityTokeString = GlusterDataModelManager.getInstance().getSecurityToken(); + ChangePasswordDialog dialog = new ChangePasswordDialog(getShell()); + + if (dialog.open() == Dialog.CANCEL) { + MessageDialog.openError(getShell(), "Change password Cancelled", + "Password must be changed on first login!" + CoreConstants.NEWLINE + "Application will close."); + cancelPressed(); + return; + } + + // after first login, cluster selection dialog must be shown. + showClusterSelectionDialog = true; + } + + ClustersClient clustersClient = new ClustersClient(); + + CLUSTER_MODE mode; + String clusterName = null; + if (!showClusterSelectionDialog) { + clusterName = preferenceStore.getString(PreferenceConstants.P_DEFAULT_CLUSTER_NAME); + if (clusterName == null || clusterName.isEmpty()) { + // Cluster name not available in preferences. Hence we must show the cluster selection dialog. + showClusterSelectionDialog = true; + } else { + mode = CLUSTER_MODE.SELECT; + } + } + + String serverName = null; + + if (showClusterSelectionDialog) { + ClusterSelectionDialog clusterDialog = new ClusterSelectionDialog(getParentShell(), + clustersClient.getClusterNames()); + int userAction = clusterDialog.open(); + if (userAction == Window.CANCEL) { + MessageDialog.openError(getShell(), "Login Cancelled", + "User cancelled login at cluster selection. Application will close!"); + cancelPressed(); + return; + } + mode = clusterDialog.getClusterMode(); + clusterName = clusterDialog.getClusterName(); + serverName = clusterDialog.getServerName(); + } else { + mode = CLUSTER_MODE.SELECT; + } + + try { + createOrRegisterCluster(clustersClient, clusterName, serverName, mode); + + final String clusterName1 = clusterName; + new ProgressMonitorDialog(getShell()).run(true, false, new IRunnableWithProgress() { + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + GlusterDataModelManager.getInstance().initializeModel(clusterName1, monitor); + } + }); + super.okPressed(); + } catch (Exception e) { + String errMsg; + if(e instanceof InvocationTargetException) { + errMsg = ((InvocationTargetException) e).getTargetException().getMessage(); + } else { + errMsg = e.getMessage(); + } + setReturnCode(RETURN_CODE_ERROR); + MessageDialog.openError(getShell(), "Gluster Management Console", errMsg); + } + } + + public void createOrRegisterCluster(ClustersClient clustersClient, String clusterName, String serverName, + CLUSTER_MODE mode) { + switch (mode) { + case SELECT: + return; + case CREATE: + clustersClient.createCluster(clusterName); + break; + case REGISTER: + clustersClient.registerCluster(clusterName, serverName); + break; + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickPage1.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickPage1.java new file mode 100644 index 00000000..80265949 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickPage1.java @@ -0,0 +1,302 @@ +/** + * MigrateBrickPage1.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ + +package org.gluster.storage.management.console.dialogs; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.TableLabelProviderAdapter; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.utils.NumberUtil; + + +public class MigrateBrickPage1 extends WizardPage { + private static final String PAGE_NAME = "migrate.disk.page.1"; + + private enum DISK_TABLE_COLUMN_INDICES { + SERVER, BRICK_DIRECTORY, FREE_SPACE, TOTAL_SPACE + } + + private static final String[] DISK_TABLE_COLUMN_NAMES = { "Server", "Brick Directory", "Free Space (GB)", "Total Space (GB)" }; + + private Volume volume; + private Brick fromBrick; + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private TableViewer tableViewerTo; + + private TableViewer tableViewerFrom; + + private Button autoCompleteCheckbox; + + private ITableLabelProvider getBrickLabelProvider(final String volumeName) { + return new TableLabelProviderAdapter() { + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Brick)) { + return null; + } + Brick brick = (Brick) element; + GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + Device device = modelManager.getDeviceForBrickDir(brick); + // convert MB to GB + String freeSpace = (device == null ? "NA" : NumberUtil.formatNumber(device.getFreeSpace() / 1024)); + String totalSpace = (device == null ? "NA" : NumberUtil.formatNumber(device.getSpace() / 1024)); + return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? brick.getServerName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY.ordinal() ? brick.getBrickDirectory() + : columnIndex == DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? freeSpace + : columnIndex == DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? totalSpace + : "Invalid"); + } + }; + } + + private ITableLabelProvider getDiskLabelProvider(final String volumeName) { + return new TableLabelProviderAdapter() { + + @Override + public String getColumnText(Object element, int columnIndex) { + if (!(element instanceof Device)) { + return null; + } + Device device = (Device) element; + return (columnIndex == DISK_TABLE_COLUMN_INDICES.SERVER.ordinal() ? device.getServerName() + : columnIndex == DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY.ordinal() ? device.getMountPoint() + "/" + volumeName + : columnIndex == DISK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal() ? NumberUtil.formatNumber(device.getFreeSpace() / 1024 ) /* Coverted to GB */ + : columnIndex == DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal() ? NumberUtil.formatNumber(device.getSpace() / 1024) : "Invalid"); + } + }; + } + + private void setupDiskTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, DISK_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.SERVER, SWT.CENTER, 100); + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.BRICK_DIRECTORY, SWT.CENTER, 100); + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.FREE_SPACE, SWT.CENTER, 90); + setColumnProperties(table, DISK_TABLE_COLUMN_INDICES.TOTAL_SPACE, SWT.CENTER, 90); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, DISK_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + /** + * Create the wizard. + */ + public MigrateBrickPage1(Volume volume, Brick brick) { + super(PAGE_NAME); + this.volume = volume; + this.fromBrick = brick; + setTitle("Migrate Brick [" + volume.getName() + "]"); + setPageDescription(fromBrick.getQualifiedName(), null); + setPageComplete(false); + } + + private void setPageDescription(String source, String target) { + if (source == null) { + source = ""; + } + if (target == null) { + target = ""; + } + setDescription("Migrate data from \"" + source + "\" to \"" + target + "\""); + } + + private Object getSelectedItem(TableViewer tableViewer) { + TableItem[] selectedItems = tableViewer.getTable().getSelection(); + Object selectedDevice = null; + for (TableItem item : selectedItems) { + selectedDevice = item.getData(); + } + return selectedDevice; + } + + private void setupPageLayout(Composite container) { + final GridLayout layout = new GridLayout(2, false); + layout.verticalSpacing = 10; + layout.horizontalSpacing = 10; + layout.marginTop = 10; + layout.marginLeft = 10; + layout.marginRight = 10; + container.setLayout(layout); + } + + private Composite createTableViewerComposite(Composite parent) { + Composite tableViewerComposite = new Composite(parent, SWT.NONE); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + return tableViewerComposite; + } + + public String getSourceBrickDir() { + Brick sourceBrick = (Brick)getSelectedItem(tableViewerFrom); + return sourceBrick.getQualifiedName(); + } + + public String getTargetBrickDir() { + Device targetDevice = (Device)getSelectedItem(tableViewerTo); + if (targetDevice == null) { + return ""; + } + return targetDevice.getQualifiedBrickName(volume.getName()); + } + + public Boolean getAutoCommitSelection() { + return autoCompleteCheckbox.getSelection(); + } + + /** + * Create contents of the wizard. + * + * @param parent + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + setControl(container); + + setupPageLayout(container); + + GridData labelLayoutData = new GridData(SWT.LEFT, SWT.BOTTOM, true, false); + labelLayoutData.minimumWidth = 100; + labelLayoutData.verticalAlignment = SWT.BOTTOM; + //labelLayoutData.verticalIndent = 10; + + Label lblFromDisk = new Label(container, SWT.NONE); + lblFromDisk.setText("From Brick:"); + lblFromDisk.setLayoutData(labelLayoutData); + Label lblToDisk = new Label(container, SWT.NONE); + lblToDisk.setText("To Brick:"); + lblToDisk.setLayoutData(labelLayoutData); + + Text txtFilterFrom = guiHelper.createFilterText(container); + Text txtFilterTo = guiHelper.createFilterText(container); + + GlusterDataModelManager glusterDataModelManager = GlusterDataModelManager.getInstance(); + List fromBricks = volume.getBricks(); + List toDevices = glusterDataModelManager.getReadyDevicesOfAllServersExcluding(glusterDataModelManager + .getDevicesOfVolume(volume)); + + tableViewerFrom = createTableViewer(container, getBrickLabelProvider(volume.getName()), fromBricks, + txtFilterFrom); + + if(fromBrick != null) { + setFromDisk(tableViewerFrom, fromBrick); + } + tableViewerTo = createTableViewer(container, getDiskLabelProvider(volume.getName()), toDevices, txtFilterTo); + tableViewerTo.setSelection(new StructuredSelection(fromBrick)); + + // Auto commit selection field + Composite autoCommitContainer = new Composite(container, SWT.NONE); + GridData data = new GridData(); + data.horizontalSpan = 2; + autoCommitContainer.setLayoutData(data); + autoCompleteCheckbox = new Button(autoCommitContainer, SWT.CHECK); + autoCompleteCheckbox.setSelection(true); + Label lblAutoComplete = new Label(autoCommitContainer, SWT.NONE); + lblAutoComplete.setText("Auto commit on migration complete"); + autoCommitContainer.setLayout( container.getLayout()); + } + + private void setFromDisk(TableViewer tableViewer, Brick brickToSelect) { + Table table = tableViewer.getTable(); + for (int i = 0; i < table.getItemCount(); i++) { + TableItem item = table.getItem(i); + if (item.getData() == brickToSelect) { + table.select(i); + return; + } + } + } + + private void refreshButtonStatus() { + if(tableViewerFrom.getSelection().isEmpty() || tableViewerTo.getSelection().isEmpty()) { + setPageComplete(false); + } else { + setPageComplete(true); + } + } + + private TableViewer createTableViewer(Composite container, ITableLabelProvider diskLabelProvider, + List bricks, Text txtFilterText) { + Composite tableViewerComposite = createTableViewerComposite(container); + + TableViewer tableViewer = new TableViewer(tableViewerComposite, SWT.SINGLE); + tableViewer.setContentProvider(new ArrayContentProvider()); + tableViewer.setLabelProvider(diskLabelProvider); + + setupDiskTable(tableViewerComposite, tableViewer.getTable()); + guiHelper.createFilter(tableViewer, txtFilterText, false); + + tableViewer.setInput(bricks.toArray()); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + @Override + public void selectionChanged(SelectionChangedEvent event) { + refreshButtonStatus(); + setPageDescription(getSourceBrickDir(), getTargetBrickDir()); + } + }); + return tableViewer; + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickWizard.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickWizard.java new file mode 100644 index 00000000..f5cc0249 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/MigrateBrickWizard.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.net.URI; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.wizard.Wizard; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.Volume; + + +public class MigrateBrickWizard extends Wizard { + private Volume volume; + private Brick brick; + private MigrateBrickPage1 page; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private Cluster cluster = modelManager.getModel().getCluster(); + + public MigrateBrickWizard(Volume volume, Brick brick) { + setWindowTitle("Gluster Management Console - Migrate Brick [" + volume.getName() + "]"); + this.volume = volume; + this.brick = brick; + setHelpAvailable(false); // TODO: Introduce wizard help + } + + @Override + public void addPages() { + page = new MigrateBrickPage1(volume, brick); + addPage(page); + } + + @Override + public boolean performFinish() { + + String sourceDir = page.getSourceBrickDir(); + String targetDir = page.getTargetBrickDir(); + Boolean autoCommit = page.getAutoCommitSelection(); + VolumesClient volumesClient = new VolumesClient(); + String dialogTitle = "Brick migration"; + + try { + String reference = volume.getName() + "-" + sourceDir + "-" + targetDir; + TaskInfo existingTaskInfo = GlusterDataModelManager.getInstance().getTaskByReference(reference); + if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS + && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { + MessageDialog.openInformation(getShell(), dialogTitle, "Volume brick [" + reference + + "] migration is already in progress! Try later."); + return true; + } + + URI uri = volumesClient.startMigration(volume.getName(), sourceDir, targetDir, autoCommit); + + // To get the object + TasksClient taskClient = new TasksClient(); + TaskInfo taskInfo = taskClient.getTaskInfo(uri); + if (taskInfo != null) { + // cluster.addTaskInfo(taskInfo); + String volumeName = taskInfo.getReference().split("#")[0]; + modelManager.addTask(taskInfo); + modelManager.refreshVolumeData(cluster.getVolume(volumeName)); + + // If auto commit selected and migration operation complete immediately, + if (taskInfo.getStatus().getCode() == TaskStatus.STATUS_CODE_SUCCESS) { + Volume oldVolume = cluster.getVolume(volumeName); + Volume newVolume = (new VolumesClient()).getVolume(volumeName); + + modelManager.volumeChanged(oldVolume, newVolume); + + MessageDialog.openInformation(getShell(), dialogTitle, "Brick migration completed successfully"); + return true; + } + } + MessageDialog.openInformation(getShell(), dialogTitle, "Brick migration started successfully"); + GUIHelper.getInstance().showTaskView(); + + } catch (Exception e) { + MessageDialog.openError(getShell(), dialogTitle, "Brick Migration failed! [" + e.getMessage() + "]"); + } + return true; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/SelectDisksDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/SelectDisksDialog.java new file mode 100644 index 00000000..cc6eb83b --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/SelectDisksDialog.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.dialogs; + +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Device; + + +public class SelectDisksDialog extends Dialog { + + private BricksSelectionPage disksPage; + private List allDevices; + private List selectedDevices; + private String volumeName; + + /** + * Create the dialog. + * + * @param parentShell + */ + public SelectDisksDialog(Shell parentShell, List allDevices, List selectedDevices, String volumeName) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); + this.allDevices = allDevices; + this.selectedDevices = selectedDevices; + this.volumeName = volumeName; + } + + /** + * Create contents of the dialog. + * + * @param parent + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + GridLayout containerLayout = new GridLayout(2, false); + container.setLayout(containerLayout); + GridData containerLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + container.setLayoutData(containerLayoutData); + + getShell().setText("Create Volume - Select Bricks"); + + disksPage = new BricksSelectionPage(container, SWT.NONE, allDevices, selectedDevices, volumeName); + return container; + } + + /** + * Create contents of the button bar. + * + * @param parent + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + /** + * Return the initial size of the dialog. + */ + @Override + protected Point getInitialSize() { + return new Point(1024, 600); + } + + + @Override + protected void okPressed() { + if (this.getSelectedDevices().size() == 0) { + MessageDialog.openError(getShell(), "Select Brick(s)", "Please select atlease one brick"); + } else { + super.okPressed(); + } + } + + public List getSelectedDevices() { + return disksPage.getChosenDevices(); + } + + public Set getSelectedBricks(String volumeName) { + return disksPage.getChosenBricks(volumeName); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ServerAdditionDialog.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ServerAdditionDialog.java new file mode 100644 index 00000000..99d056e6 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/ServerAdditionDialog.java @@ -0,0 +1,197 @@ +/** + * ServerAdditionDialog.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.dialogs; + +import java.net.URI; +import java.util.List; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.gluster.storage.management.client.GlusterServersClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.GlusterServer; + + +public class ServerAdditionDialog extends Dialog { + public static final int RETURN_CODE_ERROR = 2; + private Text serverName; + private Button addButton; + + private GUIHelper guiHelper = GUIHelper.getInstance(); + private ControlDecoration errDecoration; + + private Composite composite; + + public ServerAdditionDialog(Shell shell) { + super(shell); + } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + + newShell.setText("Gluster Management Console - Add Server"); + addEscapeListener(newShell); + } + + private void addEscapeListener(Shell shell) { + shell.addTraverseListener(new TraverseListener() { + + @Override + public void keyTraversed(TraverseEvent e) { + if (e.keyCode == SWT.ESC) { + cancelPressed(); + } + } + }); + } + + /** + * Overriding to make sure that the dialog is centered in screen + */ + @Override + protected void initializeBounds() { + super.initializeBounds(); + + guiHelper.centerShellInScreen(getShell()); + } + + private void configureDialogLayout(Composite composite) { + GridLayout layout = (GridLayout) composite.getLayout(); + layout.numColumns = 2; + layout.marginLeft = 20; + layout.marginRight = 20; + layout.marginTop = 20; + layout.horizontalSpacing = 20; + layout.verticalSpacing = 20; + } + + // ------------------------------------------ + + private void createLabel(Composite composite, String label) { + Label passwordLabel = new Label(composite, SWT.NONE); + passwordLabel.setText(label); + passwordLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false)); + } + + private Text createServerNameText(Composite composite) { + Text field = new Text(composite, SWT.BORDER ); + GridData layoutData = new GridData(SWT.FILL, GridData.FILL, true, false); + layoutData.widthHint = convertWidthInCharsToPixels(32); + field.setLayoutData(layoutData); + return field; + } + + @Override + protected Control createDialogArea(Composite parent) { + composite = (Composite) super.createDialogArea(parent); + configureDialogLayout(composite); + + createLabel(composite, "Server Name:"); + serverName = createServerNameText(composite); + errDecoration = guiHelper.createErrorDecoration(serverName); + + createListeners(); + + return composite; + } + + private void createListeners() { + ModifyListener listener = new ModifyListener() { + + @Override + public void modifyText(ModifyEvent e) { + updateButtonStatus(); + } + }; + + serverName.addModifyListener(listener); + } + + private void updateButtonStatus() { + addButton.setEnabled(true); + errDecoration.hide(); + + if(!serverExists(serverName.getText())) { + addButton.setEnabled(false); + errDecoration.setDescriptionText("Server name already exists."); + errDecoration.show(); + } + + if(serverName.getText().isEmpty()) { + addButton.setEnabled(false); + errDecoration.setDescriptionText("Please enter server name!"); + errDecoration.show(); + } + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + addButton = createButton(parent, IDialogConstants.OK_ID, "&Add Server", true); + addButton.setEnabled(false); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + public Boolean serverExists(String serverName) { + List servers = GlusterDataModelManager.getInstance().getModel().getCluster().getServers(); + for (GlusterServer server : servers) { + if (server.getName().equalsIgnoreCase(serverName)) { + return false; + } + } + return true; + } + + protected void okPressed() { + GlusterServersClient serversClient = new GlusterServersClient(); + GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + try { + String serverNameText = serverName.getText(); + URI newServerURI = serversClient.addServer(serverNameText); + + modelManager.addGlusterServer(serversClient.getGlusterServer(newServerURI)); + + MessageDialog + .openInformation(getShell(), "Add Server", "Server " + serverNameText + " added successfully!"); + } catch (Exception e) { + MessageDialog.openError(getShell(), "Server addition Failed", e.getMessage()); + setReturnCode(RETURN_CODE_ERROR); + } + this.close(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/jobs/DataSyncJob.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/jobs/DataSyncJob.java new file mode 100644 index 00000000..ee4daafe --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/jobs/DataSyncJob.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.jobs; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.swt.widgets.Display; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.core.model.GlusterDataModel; + + +/** + * + */ +public class DataSyncJob extends Job { + private static final GlusterLogger logger = GlusterLogger.getInstance(); + + public DataSyncJob(String name) { + super(name); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(final IProgressMonitor monitor) { + final GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + // fetch the latest model + final GlusterDataModel model = modelManager.fetchModel(monitor); + if(model == null) { + return Status.CANCEL_STATUS; + } + + monitor.beginTask("Notify views", 1); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + modelManager.updateModel(model); + } + }); + monitor.worked(1); + monitor.done(); + + return Status.OK_STATUS; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/AlertsPreferencePage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/AlertsPreferencePage.java new file mode 100644 index 00000000..7855f289 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/AlertsPreferencePage.java @@ -0,0 +1,38 @@ +package org.gluster.storage.management.console.preferences; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.gluster.storage.management.console.Activator; + + +public class AlertsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public AlertsPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("Gluster Management Console - Alerts"); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ + @Override + protected void createFieldEditors() { + addField(new IntegerFieldEditor(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD, + "&Server CPU usage threshold:", getFieldEditorParent())); + + addField(new IntegerFieldEditor(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD, + "&Server memory usage threshold (%):", getFieldEditorParent())); + + addField(new IntegerFieldEditor(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD, + "&Disk space usage threshold (%):", getFieldEditorParent())); + } + + @Override + public void init(IWorkbench workbench) { + // TODO Auto-generated method stub + + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/ChartsPreferencePage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/ChartsPreferencePage.java new file mode 100644 index 00000000..6c4f9506 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/ChartsPreferencePage.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.preferences; + +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.gluster.storage.management.console.Activator; + + +/** + * + */ +public class ChartsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public ChartsPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("Gluster Management Console"); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + @Override + public void init(IWorkbench workbench) { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ + @Override + protected void createFieldEditors() { + String[][] entryNamesAndValues = new String[][] { + { "1 day", "1d" }, { "1 week", "1w" }, { "1 month", "1m" }, { "1 year", "1y" } }; + addField(new ComboFieldEditor(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD, "Aggregated CPU Usage chart period", entryNamesAndValues, + getFieldEditorParent())); + addField(new ComboFieldEditor(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD, "Aggregated Network Usage chart period", entryNamesAndValues, + getFieldEditorParent())); + addField(new ComboFieldEditor(PreferenceConstants.P_CPU_CHART_PERIOD, "CPU Usage chart period", entryNamesAndValues, + getFieldEditorParent())); + addField(new ComboFieldEditor(PreferenceConstants.P_MEM_CHART_PERIOD, "Memory Usage chart period", entryNamesAndValues, + getFieldEditorParent())); + addField(new ComboFieldEditor(PreferenceConstants.P_NETWORK_CHART_PERIOD, "Network Usage chart period", entryNamesAndValues, + getFieldEditorParent())); + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/GlusterPreferencePage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/GlusterPreferencePage.java new file mode 100644 index 00000000..44ff55ed --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/GlusterPreferencePage.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.preferences; + +import java.util.List; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.gluster.storage.management.client.ClustersClient; +import org.gluster.storage.management.console.Activator; + + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

    + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ +public class GlusterPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + private List clusterNames; + + public GlusterPreferencePage() { + super(GRID); + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + setDescription("Gluster Management Console"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField( + new BooleanFieldEditor( + PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, + "&Show Cluster Selection Dialog on Login:", + getFieldEditorParent())); + + String[][] clusterNamesArr = new String[clusterNames.size()][2]; + for(int i = 0; i < clusterNames.size(); i++) { + String clusterName = clusterNames.get(i); + clusterNamesArr[i][0] = clusterName; + clusterNamesArr[i][1] = clusterName; + } + + addField(new ComboFieldEditor(PreferenceConstants.P_DEFAULT_CLUSTER_NAME, "Default &Cluster to manage:", + clusterNamesArr, getFieldEditorParent())); + addField(new IntegerFieldEditor(PreferenceConstants.P_DATA_SYNC_INTERVAL, "&Refresh Interval (sec):", + getFieldEditorParent())); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + clusterNames = new ClustersClient().getClusterNames(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceConstants.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceConstants.java new file mode 100644 index 00000000..1422a77d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceConstants.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + + public static final String P_SHOW_CLUSTER_SELECTION_DIALOG = "show.cluster.selection.dialog"; + public static final String P_DEFAULT_CLUSTER_NAME = "default.cluster.name"; + public static final String P_DATA_SYNC_INTERVAL = "data.sync.interval"; + + public static final String P_SERVER_CPU_CRITICAL_THRESHOLD = "server.cpu.threshold"; + public static final String P_SERVER_MEMORY_USAGE_THRESHOLD = "server.memory.threshold"; + public static final String P_DISK_SPACE_USAGE_THRESHOLD = "disk.space.threshold"; // in percentage + + public static final String P_CPU_CHART_PERIOD = "cpu.chart.period"; + public static final String P_MEM_CHART_PERIOD = "memory.chart.period"; + public static final String P_NETWORK_CHART_PERIOD = "network.chart.period"; + public static final String P_DEFAULT_NETWORK_INTERFACE_PFX = "default.network.interface."; + public static final String P_CPU_AGGREGATED_CHART_PERIOD = "cpu.aggregated.chart.period"; + public static final String P_NETWORK_AGGREGATED_CHART_PERIOD = "network.aggregated.chart.period"; +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceInitializer.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceInitializer.java new file mode 100644 index 00000000..36d8b652 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/preferences/PreferenceInitializer.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.gluster.storage.management.console.Activator; + + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + + store.setDefault(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, true); + + // default data sync interval = 5 minutes + store.setDefault(PreferenceConstants.P_DATA_SYNC_INTERVAL, 300); + + // Default CPU utilisation threshold + store.setDefault(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD, 80); + + // Default Memory threshold + store.setDefault(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD, 80); + + // Default disk free space threshold + store.setDefault(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD, 80); + + // Default period for server statistics charts + store.setDefault(PreferenceConstants.P_CPU_CHART_PERIOD, "1d"); + store.setDefault(PreferenceConstants.P_MEM_CHART_PERIOD, "1d"); + store.setDefault(PreferenceConstants.P_NETWORK_CHART_PERIOD, "1d"); + store.setDefault(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD, "1d"); + store.setDefault(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD, "1d"); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/GlusterToolbarManager.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/GlusterToolbarManager.java new file mode 100644 index 00000000..fc8ef865 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/GlusterToolbarManager.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.toolbar; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.gluster.storage.management.console.actions.ActionConstants; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.Volume; + + +public class GlusterToolbarManager implements ToolbarManager { + private enum ENTITY_TYPE { + CLUSTER, VOLUMES, VOLUME, GLUSTER_SERVERS, GLUSTER_SERVER, DISCOVERED_SERVERS, DISCOVERED_SERVER, TASK + }; + + private IWorkbenchWindow window; + private final Map, ENTITY_TYPE> entityTypeMap = createEntityTypeMap(); + private final Map actionSetMap = createActionSetMap(); + + private Map, ENTITY_TYPE> createEntityTypeMap() { + Map, ENTITY_TYPE> entityTypeMap = new HashMap, GlusterToolbarManager.ENTITY_TYPE>(); + entityTypeMap.put(Cluster.class, ENTITY_TYPE.CLUSTER); + entityTypeMap.put(Volume.class, ENTITY_TYPE.VOLUME); + entityTypeMap.put(Server.class, ENTITY_TYPE.DISCOVERED_SERVER); + entityTypeMap.put(GlusterServer.class, ENTITY_TYPE.GLUSTER_SERVER); + entityTypeMap.put(TaskInfo.class, ENTITY_TYPE.TASK); + + return entityTypeMap; + } + + private Map createActionSetMap() { + Map actionSetMap = new HashMap(); + actionSetMap.put(ENTITY_TYPE.CLUSTER, ActionConstants.ACTION_SET_CLUSTER); + actionSetMap.put(ENTITY_TYPE.VOLUMES, ActionConstants.ACTION_SET_VOLUMES); + actionSetMap.put(ENTITY_TYPE.VOLUME, ActionConstants.ACTION_SET_VOLUME); + actionSetMap.put(ENTITY_TYPE.GLUSTER_SERVERS, ActionConstants.ACTION_SET_GLUSTER_SERVERS); + actionSetMap.put(ENTITY_TYPE.GLUSTER_SERVER, ActionConstants.ACTION_SET_GLUSTER_SERVER); + actionSetMap.put(ENTITY_TYPE.DISCOVERED_SERVERS, ActionConstants.ACTION_SET_DISCOVERED_SERVERS); + actionSetMap.put(ENTITY_TYPE.DISCOVERED_SERVER, ActionConstants.ACTION_SET_DISCOVERED_SERVER); + actionSetMap.put(ENTITY_TYPE.TASK, ActionConstants.ACTION_SET_TASK); + + return actionSetMap; + } + + public GlusterToolbarManager(IWorkbenchWindow window) { + this.window = window; + } + + @SuppressWarnings("rawtypes") + private ENTITY_TYPE getEntityType(Entity entity) { + if (entity instanceof EntityGroup) { + EntityGroup entityGroup = (EntityGroup) entity; + if (entityGroup.getEntityType() == Volume.class) { + return ENTITY_TYPE.VOLUMES; + } else if (entityGroup.getEntityType() == GlusterServer.class) { + return ENTITY_TYPE.GLUSTER_SERVERS; + } else { + return ENTITY_TYPE.DISCOVERED_SERVERS; + } + } + + return entityTypeMap.get(entity.getClass()); + } + + @Override + public void updateToolbar(Entity entity) { + ENTITY_TYPE entityType = getEntityType(entity); + IWorkbenchPage page = window.getActivePage(); + + for (ENTITY_TYPE targetEntityType : actionSetMap.keySet()) { + String actionSetId = actionSetMap.get(targetEntityType); + if (entityType == targetEntityType) { + // show only the action set mapped to given entity + page.showActionSet(actionSetId); + } else { + page.hideActionSet(actionSetId); + } + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/ToolbarManager.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/ToolbarManager.java new file mode 100644 index 00000000..e4b8d320 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/toolbar/ToolbarManager.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.toolbar; + +import org.gluster.storage.management.core.model.Entity; + +/** + * Whenever the current selection/action demands changes to the toolbar, the toolbar manager is used to update the + * toolbar. + */ +public interface ToolbarManager { + /** + * Updates the toolbar for given entity. This typically means that user is working with the given entity, and hence + * the toolbar actions related to that entity should be made visible, and other un-related actions should be hidden. + * + * @param entity + */ + public void updateToolbar(Entity entity); +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartUtil.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartUtil.java new file mode 100644 index 00000000..b5d2a602 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartUtil.java @@ -0,0 +1,339 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.utils; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.birt.chart.util.CDateTime; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.gluster.storage.management.console.Activator; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.NetworkInterface; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.ServerStatsRow; + +import com.ibm.icu.util.Calendar; + +/** + * + */ +public class ChartUtil { + private static final ChartUtil instance = new ChartUtil(); + private static final int CHART_WIDTH = 350; + private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + + private ChartUtil() { + } + + public static ChartUtil getInstance() { + return instance; + } + + /** + * @param toolkit + * @param section + * @param stats + * @param dataColumnIndex + * @param unit + * @param timestampFormat + * @param listener + * @param maxValue + * @return The composite containing the various links related to the created chart + */ + public Composite createAreaChart(FormToolkit toolkit, Composite section, ServerStats stats, int dataColumnIndex, + String unit, String timestampFormat, ChartPeriodLinkListener listener, double maxValue, int linkColumnCount) { + if (stats == null) { + toolkit.createLabel(section, "Server statistics not available. Try after some time!"); + return null; + } + + List timestamps = new ArrayList(); + List data = new ArrayList(); + + extractChartData(stats, timestamps, data, dataColumnIndex); + + if (timestamps.size() == 0) { + toolkit.createLabel(section, "Server statistics not available!" + CoreConstants.NEWLINE + + "Check if all services are running properly " + CoreConstants.NEWLINE + + "on the cluster servers, or try after some time!"); + return null; + } + + createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit, + timestampFormat, maxValue); + + // Calendar[] timestamps = new Calendar[] { new CDateTime(1000l*1310468100), new CDateTime(1000l*1310468400), + // new CDateTime(1000l*1310468700), + // new CDateTime(1000l*1310469000), new CDateTime(1000l*1310469300), new CDateTime(1000l*1310469600), new + // CDateTime(1000l*1310469900), + // new CDateTime(1000l*1310470200), new CDateTime(1000l*1310470500), new CDateTime(1000l*1310470800), new + // CDateTime(1000l*1310471100), + // new CDateTime(1000l*1310471400), new CDateTime(1000l*1310471700), new CDateTime(1000l*1310472000), new + // CDateTime(1000l*1310472300), + // new CDateTime(1000l*1310472600), new CDateTime(1000l*1310472900), new CDateTime(1000l*1310473200), new + // CDateTime(1000l*1310473500), + // new CDateTime(1000l*1310473800) }; + // + // Double[] values = new Double[] { 10d, 11.23d, 17.92d, 18.69d, 78.62d, 89.11d, 92.43d, 89.31d, 57.39d, 18.46d, + // 10.44d, 16.28d, 13.51d, 17.53d, 12.21, 20d, 21.43d, 16.45d, 14.86d, 15.27d }; + // createLineChart(section, timestamps, values, "%"); + Composite chartLinksComposite = createChartLinks(toolkit, section, linkColumnCount, listener); + + if (linkColumnCount == 5) { + createNetworkInterfaceCombo(section, chartLinksComposite, toolkit, + (NetworkChartPeriodLinkListener) listener); + } + return chartLinksComposite; + } + + private ChartViewerComposite createAreaChart(Composite section, Calendar timestamps[], Double values[], + String unit, String timestampFormat, double maxValue) { + ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, + unit, timestampFormat, maxValue); + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = CHART_WIDTH; + data.heightHint = 250; + data.verticalAlignment = SWT.CENTER; + chartViewerComposite.setLayoutData(data); + return chartViewerComposite; + } + + private void extractChartData(ServerStats stats, List timestamps, List data, int dataColumnIndex) { + for (ServerStatsRow row : stats.getRows()) { + Double cpuUsage = row.getUsageData().get(dataColumnIndex); + if (!cpuUsage.isNaN()) { + timestamps.add(new CDateTime(row.getTimestamp() * 1000)); + data.add(cpuUsage); + } + } + } + + private Composite createChartLinks(FormToolkit toolkit, Composite section, int columnCount, + ChartPeriodLinkListener listener) { + GridLayout layout = new org.eclipse.swt.layout.GridLayout(columnCount, false); + layout.marginBottom = 0; + layout.marginTop = 0; + layout.marginLeft = (CHART_WIDTH - (50 * columnCount)) / 2; + Composite graphComposite = toolkit.createComposite(section, SWT.NONE); + graphComposite.setLayout(layout); + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = CHART_WIDTH; + graphComposite.setLayoutData(data); + + createStatsLink(toolkit, listener, graphComposite, "1 day", GlusterConstants.STATS_PERIOD_1DAY); + createStatsLink(toolkit, listener, graphComposite, "1 week", GlusterConstants.STATS_PERIOD_1WEEK); + createStatsLink(toolkit, listener, graphComposite, "1 month", GlusterConstants.STATS_PERIOD_1MONTH); + createStatsLink(toolkit, listener, graphComposite, "1 year", GlusterConstants.STATS_PERIOD_1YEAR); + + return graphComposite; + } + + private void createStatsLink(FormToolkit toolkit, ChartPeriodLinkListener listener, Composite parent, String label, + String statsPeriod) { + Hyperlink link1 = toolkit.createHyperlink(parent, label, SWT.NONE); + link1.addHyperlinkListener(listener.getInstance(statsPeriod)); + if (listener.getStatsPeriod().equals(statsPeriod)) { + link1.setEnabled(false); + } + } + + public abstract class ChartPeriodLinkListener extends HyperlinkAdapter { + protected String statsPeriod; + protected String unit; + protected int columnCount; + protected double maxValue; + protected FormToolkit toolkit; + protected String serverName; + protected int dataColumnIndex; + + public String getStatsPeriod() { + return this.statsPeriod; + } + + public ChartPeriodLinkListener(String serverName, String statsPeriod, String unit, double maxValue, + int columnCount, int dataColumnIndex, FormToolkit toolkit) { + this.serverName = serverName; + this.statsPeriod = statsPeriod; + this.unit = unit; + this.columnCount = columnCount; + this.maxValue = maxValue; + this.dataColumnIndex = dataColumnIndex; + this.toolkit = toolkit; + } + + public ChartPeriodLinkListener(String serverName, String statsPeriod, FormToolkit toolkit) { + this.statsPeriod = statsPeriod; + this.serverName = serverName; + this.toolkit = toolkit; + } + + @Override + public void linkActivated(HyperlinkEvent e) { + super.linkActivated(e); + Composite section = ((Hyperlink) e.getSource()).getParent().getParent(); + updatePreference(serverName); + } + + public abstract ChartPeriodLinkListener getInstance(String statsPeriod); + + protected abstract void updatePreference(String serverName); + } + + public class CpuChartPeriodLinkListener extends ChartPeriodLinkListener { + public CpuChartPeriodLinkListener(String serverName, String statsPeriod, FormToolkit toolkit) { + super(serverName, statsPeriod, toolkit); + } + + private CpuChartPeriodLinkListener(String serverName, String statsPeriod, String unit, double maxValue, + int columnCount, int dataColumnIndex, FormToolkit toolkit) { + super(serverName, statsPeriod, unit, maxValue, columnCount, dataColumnIndex, toolkit); + } + + @Override + protected void updatePreference(String serverName) { + ServerStats stats; + if (serverName == null) { + preferenceStore.setValue(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD, statsPeriod); + } else { + preferenceStore.setValue(PreferenceConstants.P_CPU_CHART_PERIOD, statsPeriod); + } + } + + @Override + public ChartPeriodLinkListener getInstance(String statsPeriod) { + return new CpuChartPeriodLinkListener(serverName, statsPeriod, "%", 100, 4, dataColumnIndex, toolkit); + } + } + + public class MemoryChartPeriodLinkListener extends ChartPeriodLinkListener { + public MemoryChartPeriodLinkListener(String serverName, String statsPeriod, FormToolkit toolkit) { + super(serverName, statsPeriod, toolkit); + } + + private MemoryChartPeriodLinkListener(String serverName, String statsPeriod, String unit, double maxValue, + int columnCount, int dataColumnIndex, FormToolkit toolkit) { + super(serverName, statsPeriod, unit, maxValue, columnCount, dataColumnIndex, toolkit); + } + + @Override + protected void updatePreference(String serverName) { + preferenceStore.setValue(PreferenceConstants.P_MEM_CHART_PERIOD, statsPeriod); + } + + @Override + public ChartPeriodLinkListener getInstance(String statsPeriod) { + return new MemoryChartPeriodLinkListener(serverName, statsPeriod, "%", 100, 4, dataColumnIndex, toolkit); + } + } + + public class NetworkChartPeriodLinkListener extends ChartPeriodLinkListener { + private GlusterServer server; + + public NetworkChartPeriodLinkListener(GlusterServer server, String statsPeriod, FormToolkit toolkit) { + super(server == null ? null : server.getName(), statsPeriod, toolkit); + this.setServer(server); + } + + private NetworkChartPeriodLinkListener(GlusterServer server, String statsPeriod, String unit, double maxValue, + int columnCount, int dataColumnIndex, FormToolkit toolkit) { + super(server == null ? null : server.getName(), statsPeriod, unit, maxValue, columnCount, dataColumnIndex, + toolkit); + this.setServer(server); + } + + @Override + protected void updatePreference(String serverName) { + if (serverName == null) { + preferenceStore.setValue(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD, statsPeriod); + } else { + preferenceStore.setValue(PreferenceConstants.P_NETWORK_CHART_PERIOD, statsPeriod); + } + } + + @Override + public ChartPeriodLinkListener getInstance(String statsPeriod) { + // if serverName is null, it means we are showing aggregated stats - so the "network interface" combo will + // not be shown in the "links" composite. + int columnCount = (serverName == null ? 4 : 5); + return new NetworkChartPeriodLinkListener(server, statsPeriod, "KiB/s", -1d, columnCount, dataColumnIndex, + toolkit); + } + + public void setServer(GlusterServer server) { + this.server = server; + } + + public GlusterServer getServer() { + return server; + } + } + + public void createNetworkInterfaceCombo(final Composite section, final Composite graphComposite, + final FormToolkit toolkit, final NetworkChartPeriodLinkListener networkChartPeriodLinkListener) { + final GlusterServer server = networkChartPeriodLinkListener.getServer(); + final CCombo interfaceCombo = new CCombo(graphComposite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER | SWT.FLAT); + final List niList = server.getNetworkInterfaces(); + final String[] interfaces = new String[niList.size()]; + + for (int i = 0; i < interfaces.length; i++) { + interfaces[i] = niList.get(i).getName(); + } + interfaceCombo.setItems(interfaces); + interfaceCombo.select(0); + interfaceCombo.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + preferenceStore.setValue(PreferenceConstants.P_DEFAULT_NETWORK_INTERFACE_PFX + server.getName(), interfaces[interfaceCombo.getSelectionIndex()]); + } + }); + } + + public void refreshChartSection(FormToolkit toolkit, Composite section, ServerStats stats, String statsPeriod, + String unit, double maxValue, int columnCount, ChartPeriodLinkListener linkListener, int dataColumnIndex) { + GUIHelper.getInstance().clearSection(section); + createAreaChart(toolkit, section, stats, dataColumnIndex, unit, getTimestampFormatForPeriod(statsPeriod), + linkListener, maxValue, columnCount); + section.layout(); + } + + public String getTimestampFormatForPeriod(String statsPeriod) { + if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1DAY)) { + return "HH:mm"; + } else if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1WEEK)) { + return "dd-MMM HH:mm"; + } else { + return "dd-MMM"; + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartViewerComposite.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartViewerComposite.java new file mode 100644 index 00000000..4f2e7ecf --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ChartViewerComposite.java @@ -0,0 +1,475 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.utils; + +import java.util.Arrays; +import java.util.Collections; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.birt.chart.api.ChartEngine; +import org.eclipse.birt.chart.device.IDeviceRenderer; +import org.eclipse.birt.chart.device.IUpdateNotifier; +import org.eclipse.birt.chart.exception.ChartException; +import org.eclipse.birt.chart.factory.GeneratedChartState; +import org.eclipse.birt.chart.factory.Generator; +import org.eclipse.birt.chart.model.Chart; +import org.eclipse.birt.chart.model.ChartWithoutAxes; +import org.eclipse.birt.chart.model.attribute.Anchor; +import org.eclipse.birt.chart.model.attribute.AxisType; +import org.eclipse.birt.chart.model.attribute.Bounds; +import org.eclipse.birt.chart.model.attribute.ChartDimension; +import org.eclipse.birt.chart.model.attribute.LineAttributes; +import org.eclipse.birt.chart.model.attribute.LineStyle; +import org.eclipse.birt.chart.model.attribute.Position; +import org.eclipse.birt.chart.model.attribute.Text; +import org.eclipse.birt.chart.model.attribute.TickStyle; +import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; +import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; +import org.eclipse.birt.chart.model.attribute.impl.JavaDateFormatSpecifierImpl; +import org.eclipse.birt.chart.model.attribute.impl.LineAttributesImpl; +import org.eclipse.birt.chart.model.attribute.impl.NumberFormatSpecifierImpl; +import org.eclipse.birt.chart.model.component.Axis; +import org.eclipse.birt.chart.model.component.Series; +import org.eclipse.birt.chart.model.component.impl.SeriesImpl; +import org.eclipse.birt.chart.model.data.DateTimeDataElement; +import org.eclipse.birt.chart.model.data.DateTimeDataSet; +import org.eclipse.birt.chart.model.data.NumberDataSet; +import org.eclipse.birt.chart.model.data.SeriesDefinition; +import org.eclipse.birt.chart.model.data.TextDataSet; +import org.eclipse.birt.chart.model.data.impl.DateTimeDataElementImpl; +import org.eclipse.birt.chart.model.data.impl.DateTimeDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; +import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; +import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; +import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; +import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; +import org.eclipse.birt.chart.model.layout.Legend; +import org.eclipse.birt.chart.model.layout.Plot; +import org.eclipse.birt.chart.model.type.AreaSeries; +import org.eclipse.birt.chart.model.type.PieSeries; +import org.eclipse.birt.chart.model.type.impl.AreaSeriesImpl; +import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl; +import org.eclipse.birt.core.framework.PlatformConfig; +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; + +import com.ibm.icu.util.Calendar; + +/** + * + */ +public final class ChartViewerComposite extends Composite implements PaintListener, IUpdateNotifier { + + public enum CHART_TYPE { + PIE, LINE + }; + + private IDeviceRenderer deviceReader = null; + private Chart chart = null; + private GeneratedChartState generatedChartState = null; + private boolean needsGeneration = true; + + private static Logger logger = Logger.getLogger(ChartViewerComposite.class.getName()); + + /** + * @param parent + * Parent composite of this pie chart viewer composite + * @param style + * SWT style to be used + * @param categories + * Categories of the pie chart + * @param values + * Values of each category in the pie chart Constructs a pie + * chart viewer composite for given categories and values + */ + public ChartViewerComposite(Composite parent, int style, String[] categories, Double[] values) { + super(parent, style); + init(); + + chart = createPieChart(categories, values); + addPaintListener(this); + } + + /** + * @param parent + * Parent composite of this pie chart viewer composite + * @param style + * SWT style to be used + * @param categories + * Categories of the pie chart + * @param values + * Values of each category in the pie chart Constructs a pie + * chart viewer composite for given categories and values + * @param maxValue + */ + public ChartViewerComposite(Composite parent, int style, Calendar[] categories, Double[] values, String unit, String timestampFormat, double maxValue) { + super(parent, style); + init(); + + createSingleAreaChart(categories, values, unit, timestampFormat, maxValue); + addPaintListener(this); + } + + public void init() { + try { + PlatformConfig config = new PlatformConfig(); + config.setBIRTHome(Platform.getInstallLocation().getURL().getPath()); + // Get the connection with SWT device to render the graphics. + deviceReader = ChartEngine.instance(config).getRenderer("dv.SWT");//$NON-NLS-1$ + } catch (ChartException ex) { + logger.log(Level.SEVERE, "Could not create Chart Renderer for SWT", ex); + } + + addControlListener(new ControlListener() { + + public void controlMoved(ControlEvent e) { + needsGeneration = true; + } + + public void controlResized(ControlEvent e) { + needsGeneration = true; + } + }); + } + + private void createSingleAreaChart(Calendar[] timestamps, Double[] values, String unit, String timestampFormat, double maxValue) { + createAreaChart(timestamps, new Double[][] {values}, unit, timestampFormat, maxValue); + } + + /** + * Creates a line chart model as a reference implementation + * @param maxValue + * + * @return An instance of the simulated runtime chart model (containing + * filled datasets) + */ + private final void createAreaChart(Calendar[] timestamps, Double[][] values, final String unit, final String timestampFormat, double maxValue) { + chart = ChartWithAxesImpl.create(); + // Plot + chart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); + Plot p = chart.getPlot(); + p.getClientArea().setBackground(ColorDefinitionImpl.WHITE()); + p.setBackground(ColorDefinitionImpl.WHITE()); + + // Title + chart.getTitle().getLabel().getCaption().setValue("Line Chart");//$NON-NLS-1$ + chart.getTitle().setVisible(false); + chart.getTitle().getLabel().setVisible(true); + chart.getTitle().getInsets().set(0, 10, 0, 0); + chart.getTitle().setAnchor(Anchor.SOUTH_LITERAL); + + // Legend + Legend lg = chart.getLegend(); + lg.setVisible(false); + LineAttributes lia = lg.getOutline( ); + lia.setStyle( LineStyle.SOLID_LITERAL ); + lg.getText( ).getFont( ).setSize( 10 ); + //lg.getInsets( ).set( 10, 5, 0, 0 ); + lg.getInsets( ).set( 0, 0, 0, 0 ); + lg.getOutline( ).setVisible( false ); + lg.setAnchor( Anchor.NORTH_LITERAL ); + + updateDataSet(timestamps, values, unit, timestampFormat, maxValue); + } + + private void updateDataSet(Calendar[] timestamps, Double[][] values, final String unit, final String timestampFormat, double maxValue) { + Axis xAxisPrimary = setupXAxis(timestamps, timestampFormat); + + if(maxValue <= 0) { + maxValue = getMaxValue(values); + } + Axis yAxisPrimary = setupYAxis(unit, xAxisPrimary, maxValue); + configureXSeries(timestamps, xAxisPrimary); + configureYSeries(values, yAxisPrimary); + } + + private double getMaxValue(Double[][] values) { + double maxValue = -1; + for(Double[] seriesValues : values) { + double seriesMaxVal = Collections.max(Arrays.asList(seriesValues)); + if(seriesMaxVal > maxValue) { + maxValue = Math.round(seriesMaxVal) + 5 - (Math.round(seriesMaxVal) % 5); + } + } + return maxValue; + } + + private void configureYSeries(Double[][] values, Axis yAxisPrimary) { + SeriesDefinition sdY = SeriesDefinitionImpl.create(); + sdY.getSeriesPalette().shift(-3); + yAxisPrimary.getSeriesDefinitions().add(sdY); + + for (int i = 0; i < values.length; i++) { + // Y-Sereis + AreaSeries ls = (AreaSeries) AreaSeriesImpl.create(); + // LineSeries ls = (LineSeries) LineSeriesImpl.create(); + + NumberDataSet orthoValues = NumberDataSetImpl.create(values[i]); + ls.setDataSet(orthoValues); + ls.getLineAttributes().setColor(ColorDefinitionImpl.create(50, 50, 255)); +// for (int j = 0; j < ls.getMarkers().size(); j++) { +// ( (Marker) ls.getMarkers( ).get( j ) ).setType( MarkerType.CIRCLE_LITERAL); +// ((Marker) ls.getMarkers().get(j)).setVisible(true); +// } + ls.setTranslucent(true); + // don't show values on each point on the line chart + ls.getLabel().setVisible(false); + sdY.getSeries().add(ls); + } + } + + private void configureXSeries(Calendar[] timestamps, Axis xAxisPrimary) { + // Data Set + DateTimeDataSet categoryValues = DateTimeDataSetImpl.create(timestamps); + + // X-Series + Series seCategory = SeriesImpl.create(); + seCategory.setDataSet(categoryValues); + SeriesDefinition sdX = SeriesDefinitionImpl.create(); + + xAxisPrimary.getSeriesDefinitions().add(sdX); + sdX.getSeries().add(seCategory); + } + + private Axis setupYAxis(final String unit, Axis xAxisPrimary, double maxValue) { + Axis yAxisPrimary = ((ChartWithAxesImpl)chart).getPrimaryOrthogonalAxis(xAxisPrimary); + if(maxValue > 0) { + yAxisPrimary.getScale().setMax(NumberDataElementImpl.create(maxValue)); + yAxisPrimary.getScale().setStep(maxValue / 5); + } + yAxisPrimary.getScale().setMin(NumberDataElementImpl.create(0)); + yAxisPrimary.setGapWidth(0); + yAxisPrimary.getScale().setMajorGridsStepNumber(1); + yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); + yAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1)); + yAxisPrimary.getLabel().setVisible(true); + yAxisPrimary.getLabel().getCaption().getFont().setSize(8); + yAxisPrimary.setFormatSpecifier(new NumberFormatSpecifierImpl() { + @Override + public String getSuffix() { + return " " + unit; + } + }); + return yAxisPrimary; + } + + private Axis setupXAxis(Calendar[] timestamps, final String timestampFormat) { + Axis xAxisPrimary = ((ChartWithAxesImpl)chart).getPrimaryBaseAxes()[0]; + xAxisPrimary.setType(AxisType.TEXT_LITERAL); + DateTimeDataElement dtde = DateTimeDataElementImpl.create(timestamps[timestamps.length-1]); + DateTimeDataElement dtde1 = DateTimeDataElementImpl.create(timestamps[0]); + xAxisPrimary.getScale().setMax(dtde); + xAxisPrimary.getScale().setStep((dtde.getValue() - dtde1.getValue())/ 10); + xAxisPrimary.getScale().setMajorGridsStepNumber(timestamps.length > 10 ? timestamps.length / 10 : 1); + //xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.ABOVE_LITERAL); + xAxisPrimary.getMajorGrid().getTickAttributes().setVisible(false); + xAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1)); + xAxisPrimary.getTitle().setVisible(false); + xAxisPrimary.getTitle().getInsets().set(1, 1, 1, 1); + xAxisPrimary.getLabel().getInsets().set(1, 1, 1, 1); + //xAxisPrimary.getLabel().getCaption().setFont(createChartFont()); + xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setSize(8); + //commenting to check whether this is causing the problem on windows + //xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 75 ); + xAxisPrimary.setFormatSpecifier( JavaDateFormatSpecifierImpl.create( timestampFormat ) ); + return xAxisPrimary; + } + + /** + * @param categories + * Categories of the pie chart + * @param values + * Values of each category in the pie chart + * @return The chart object created for given categories and values + */ + public static final Chart createPieChart(String[] categories, Double[] values) { + ChartWithoutAxes pieChart = ChartWithoutAxesImpl.create(); + + // script hook to NOT show the label if value is zero + pieChart.setScript("function beforeDrawDataPointLabel( dph, label, icsc ){ if (dph.getOrthogonalValue() == 0){ label.setVisible(false); } } "); + + // Plot + pieChart.setSeriesThickness(10); + pieChart.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL); + pieChart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); + Plot p = pieChart.getPlot(); + + p.getClientArea().setBackground(null); + p.getClientArea().getOutline().setVisible(false); + p.getOutline().setVisible(false); + + // Legend + Legend lg = pieChart.getLegend(); + lg.setMaxPercent(0.7); + lg.getText().getFont().setSize(9); + lg.setBackground(null); + lg.getOutline().setVisible(false); + lg.setVisible(true); + + // Title + pieChart.getTitle().getLabel().getCaption().setValue("Pie Chart");//$NON-NLS-1$ + pieChart.getTitle().getOutline().setVisible(false); + pieChart.getTitle().setVisible(false); + + TextDataSet categoryValues = TextDataSetImpl.create(categories); + NumberDataSet seriesOneValues = NumberDataSetImpl.create(values); + + // Base Series + Series seCategory = SeriesImpl.create(); + seCategory.setDataSet(categoryValues); + + SeriesDefinition sd = SeriesDefinitionImpl.create(); + pieChart.getSeriesDefinitions().add(sd); + sd.setSeriesPalette(new GlusterChartPalette()); + sd.getSeriesPalette().shift(0); + sd.getSeries().add(seCategory); + + // Orthogonal Series + PieSeries sePie = (PieSeries) PieSeriesImpl.create(); + sePie.setRatio(0.60); + sePie.setDataSet(seriesOneValues); + sePie.setSeriesIdentifier("Chart");//$NON-NLS-1$ + sePie.getTitle().setVisible(false); // no title + sePie.getLabel().setVisible(true); // show label (values) + sePie.setExplosion(0); // no gap between the pie slices + sePie.setLabelPosition(Position.INSIDE_LITERAL); + Text labelCaption = sePie.getLabel().getCaption(); + labelCaption.setColor(ColorDefinitionImpl.CYAN()); + labelCaption.getFont().setSize(8); + labelCaption.getFont().setBold(true); + + SeriesDefinition seriesDefinition = SeriesDefinitionImpl.create(); + seriesDefinition.getQuery().setDefinition("query.definition");//$NON-NLS-1$ + sd.getSeriesDefinitions().add(seriesDefinition); + seriesDefinition.getSeries().add(sePie); + + return pieChart; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events + * .PaintEvent) + */ + public final void paintControl(PaintEvent e) { + Rectangle d = ((Composite) e.getSource()).getBounds(); + Image imgChart = new Image(this.getDisplay(), d); + GC gcImage = new GC(imgChart); + deviceReader.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gcImage); + deviceReader.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this); + + Bounds bo = BoundsImpl.create(0, 0, d.width, d.height); + bo.scale(71d / deviceReader.getDisplayServer().getDpiResolution()); + + Generator gr = Generator.instance(); + if (needsGeneration) { + needsGeneration = false; + try { + generatedChartState = gr.build(deviceReader.getDisplayServer(), chart, bo, null, null, null); + } catch (ChartException ce) { + ce.printStackTrace(); + } + } + + try { + gr.render(deviceReader, generatedChartState); + GC gc = e.gc; + gc.drawImage(imgChart, d.x, d.y); + } catch (ChartException gex) { + logger.log(Level.SEVERE, "Exception while rendering pie chart [" + gex.getMessage() + "]", gex); + } + } + +// public void chartRefresh(Calendar[] timestamps, Double[][] values, String unit, String timestampFormat) +// { +// if ( !isDisposed( ) ) +// { +// final Generator gr = Generator.instance( ); +// updateDataSet( timestamps, values, unit, timestampFormat); +// +// // Refresh +// try +// { +// gr.refresh( generatedChartState ); +// } +// catch ( ChartException ex ) +// { +// // TODO: log the exception +// ex.printStackTrace( ); +// } +// redraw( ); +// } +// } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#getDesignTimeModel() + */ + public Chart getDesignTimeModel() { + return chart; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#getRunTimeModel() + */ + public Chart getRunTimeModel() { + return generatedChartState.getChartModel(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#peerInstance() + */ + public Object peerInstance() { + return this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#regenerateChart() + */ + public void regenerateChart() { + redraw(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.device.IUpdateNotifier#repaintChart() + */ + public void repaintChart() { + redraw(); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/EntityViewerFilter.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/EntityViewerFilter.java new file mode 100644 index 00000000..2ee6d535 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/EntityViewerFilter.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.utils; + +import java.util.Map.Entry; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.gluster.storage.management.core.model.Filterable; +import org.gluster.storage.management.core.utils.StringUtil; + + +public class EntityViewerFilter extends ViewerFilter { + + private String filterString; + private boolean caseSensitive = false; + + public EntityViewerFilter(String filterString, boolean caseSensitive) { + this.filterString = filterString; + this.caseSensitive = caseSensitive; + } + + public boolean isCaseSensitive() { + return caseSensitive; + } + + public void setCaseSensitive(boolean caseSensitive) { + this.caseSensitive = caseSensitive; + } + + public String getFilterString() { + return filterString; + } + + public void setFilterString(String filterString) { + this.filterString = filterString; + } + + @SuppressWarnings("unchecked") + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { + if (filterString == null || filterString.isEmpty()) { + // No filter string. select everything + return true; + } + + if (element instanceof Filterable) { + return ((Filterable) element).filter(filterString, caseSensitive); + } + + if(element instanceof Entry) { + Entry entry = (Entry)element; + return StringUtil.filterString(entry.getKey() + entry.getValue(), filterString, caseSensitive); + } + + if(element instanceof String) { + return StringUtil.filterString((String)element, filterString, caseSensitive); + } + + return false; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GUIHelper.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GUIHelper.java new file mode 100644 index 00000000..600a941c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GUIHelper.java @@ -0,0 +1,481 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.utils; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.fieldassist.FieldDecorationRegistry; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ColumnLayoutData; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.events.ExpansionAdapter; +import org.eclipse.ui.forms.events.ExpansionEvent; +import org.eclipse.ui.forms.widgets.ColumnLayout; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.progress.IProgressConstants; +import org.gluster.storage.management.console.Application; +import org.gluster.storage.management.console.ConsoleConstants; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.views.NavigationView; +import org.gluster.storage.management.console.views.TasksView; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.utils.JavaUtil; + + +public class GUIHelper { + private static final GUIHelper instance = new GUIHelper(); + private static final ImageUtil imageUtil = new ImageUtil(); + private static final GlusterLogger logger = GlusterLogger.getInstance(); + + private GUIHelper() { + + } + + public static GUIHelper getInstance() { + return instance; + } + + public ScrolledForm setupForm(Composite parent, FormToolkit toolkit, final String formName) { + return setupForm(toolkit, formName, toolkit.createScrolledForm(parent)); + } + + public ScrolledForm setupForm(FormToolkit toolkit, final String formName, ScrolledForm form) { + form.setText(formName); + toolkit.decorateFormHeading(form.getForm()); + + ColumnLayout layout = new ColumnLayout(); + + // layout.topMargin = 0; + // layout.bottomMargin = 5; + // layout.leftMargin = 10; + // layout.rightMargin = 10; + // layout.horizontalSpacing = 10; + // layout.verticalSpacing = 10; + // layout.maxNumColumns = 4; + // layout.minNumColumns = 1; + + form.getBody().setLayout(layout); + return form; + } + + public Composite createSection(final ScrolledForm form, FormToolkit toolkit, String title, String desc, + int numColumns, boolean collapsible) { + int style = Section.TITLE_BAR | Section.EXPANDED; + if (desc != null && !desc.isEmpty()) { + style |= Section.DESCRIPTION; + } + if (collapsible) { + style |= Section.TWISTIE; + } + + Section section = toolkit.createSection(form.getBody(), style); + section.setText(title); + section.setDescription(desc); + + // toolkit.createCompositeSeparator(section); + Composite client = toolkit.createComposite(section); + GridLayout layout = new GridLayout(); + layout.marginWidth = layout.marginHeight = 0; + layout.numColumns = numColumns; + layout.verticalSpacing = 10; + layout.marginBottom = 15; + layout.marginTop = 10; + + client.setLayout(layout); + section.setClient(client); + + section.addExpansionListener(new ExpansionAdapter() { + public void expansionStateChanged(ExpansionEvent e) { + form.reflow(false); + } + }); + return client; + } + + public Composite createTab(TabFolder tabFolder, String title, String imageKey) { + TabItem item = new TabItem(tabFolder, SWT.NONE); + item.setText(title); + item.setImage(getImage(imageKey)); + + Composite composite = new Composite(tabFolder, SWT.NONE); + composite.setLayout(new FillLayout()); + + item.setControl(composite); + + return composite; + } + + public ImageDescriptor getImageDescriptor(String imagePath) { + return imageUtil.getImageDescriptor(imagePath); + } + + public Image getImage(String imagePath) { + return imageUtil.getImage(imagePath); + } + + public Action createPullDownMenu(String menuName, String iconPath, final MenuManager menuManager) { + Action action = new Action(menuName, IAction.AS_DROP_DOWN_MENU) { + public void run() { + } + }; + action.setMenuCreator(new IMenuCreator() { + + @Override + public Menu getMenu(Menu menu) { + return null; + } + + @Override + public Menu getMenu(Control control) { + return menuManager.createContextMenu(control); + } + + @Override + public void dispose() { + } + }); + action.setImageDescriptor(getImageDescriptor(iconPath)); + return action; + } + + public TableColumnLayout createTableColumnLayout(Table table, String[] columns) { + TableColumnLayout tableColumnLayout = new TableColumnLayout(); + ColumnLayoutData defaultColumnLayoutData = new ColumnWeightData(100); + + for (String columnName : columns) { + TableColumn column = new TableColumn(table, SWT.LEFT); + column.setText(columnName); + + tableColumnLayout.setColumnData(column, defaultColumnLayoutData); + } + + return tableColumnLayout; + } + + /** + * Creates a filter for given structured viewer that will filter the contents of the viewer based on the current + * text of the text field + * + * @param viewer + * Structured viewer for which the filter is to be created + * @param filterText + * The text field whose contents are to be used for filtering + * @param caseSensitive + * Flag indicating whether the filtering should be case sensitive + * @return The newly created filter + */ + public EntityViewerFilter createFilter(final StructuredViewer viewer, final Text filterText, boolean caseSensitive) { + final String initialFilterString = filterText.getText(); + + final EntityViewerFilter filter = new EntityViewerFilter(initialFilterString, caseSensitive); + // On every keystroke inside the text field, update the filter string + filterText.addKeyListener(new KeyAdapter() { + private String filterString = initialFilterString; + + @Override + public void keyReleased(KeyEvent e) { + String enteredString = filterText.getText(); + if (enteredString.equals(filterString)) { + // Filter string has not changed. don't do anything + return; + } + + // Update filter string + filterString = enteredString; + filter.setFilterString(filterString); + + // Refresh viewer with newly filtered content + viewer.refresh(true); + if(viewer instanceof TreeViewer) { + ((TreeViewer)viewer).expandAll(); + } + } + }); + + viewer.addFilter(filter); + return filter; + } + + public IViewPart getView(String viewId) { + IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + .getViewReferences(); + for (IViewReference view : views) { + if (view.getId().equals(viewId)) { + return view.getView(false); + } + } + return null; + } + + public IWorkbenchPart getActiveView() { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); + } + + public ControlDecoration createErrorDecoration(Control control) { + ControlDecoration passwordErrorDecoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP); + passwordErrorDecoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); + return passwordErrorDecoration; + } + + public void centerShellInScreen(Shell shell) { + Rectangle monitorBounds = shell.getMonitor().getBounds(); + Rectangle myBounds = shell.getBounds(); + + int x = monitorBounds.x + (monitorBounds.width - myBounds.width) / 2; + int y = monitorBounds.y + (monitorBounds.height - myBounds.height) / 2; + shell.setLocation(x, y); + } + + public Text createFilterText(FormToolkit toolkit, Composite parent) { + final String tooltipMessage = "Start typing to filter table contents."; + final Text filterText = toolkit.createText(parent, "", SWT.FLAT); + + GridData data = new GridData(SWT.RIGHT, SWT.CENTER, false, false); + data.widthHint = 300; + filterText.setLayoutData(data); + + ControlDecoration searchDecoration = new ControlDecoration(filterText, SWT.LEFT); + searchDecoration.setImage(getImage(IImageKeys.SEARCH_22x22)); + searchDecoration.show(); + searchDecoration.setShowHover(true); + searchDecoration.setDescriptionText(tooltipMessage); + searchDecoration.setMarginWidth(5); + + filterText.setToolTipText(tooltipMessage); + return filterText; + } + + public Text createFilterText(Composite parent) { + final String tooltipMessage = "Start typing to filter table contents."; + final Text filterText = new Text(parent, SWT.FLAT); + + GridData data = new GridData(SWT.LEFT, SWT.CENTER, false, false); + data.widthHint = 300; + filterText.setLayoutData(data); + + ControlDecoration searchDecoration = new ControlDecoration(filterText, SWT.RIGHT); + searchDecoration.setImage(getImage(IImageKeys.SEARCH_22x22)); + searchDecoration.show(); + searchDecoration.setShowHover(true); + searchDecoration.setDescriptionText(tooltipMessage); + + filterText.setToolTipText(tooltipMessage); + return filterText; + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, int columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + /** + * Fetches the currently selected objects from the workbench site and returns the one of given type. If none of the + * selected objects are of given type, returns null + * + * @param site + * The workbench site + * @param expectedType + * Type of the selected object to look for + * @return The selected object of given type if found, else null + */ + public T getSelectedEntity(IWorkbenchSite site, Class expectedType) { + return getSelectedEntity(site.getWorkbenchWindow(), expectedType); + } + + @SuppressWarnings({ "unchecked" }) + public T getSelectedEntity(IWorkbenchWindow window, Class expectedType) { + ISelection selection = window.getSelectionService().getSelection(NavigationView.ID); + if (selection instanceof IStructuredSelection) { + Iterator iter = ((IStructuredSelection) selection).iterator(); + while (iter.hasNext()) { + Object selectedObj = iter.next(); + if (selectedObj.getClass() == expectedType) { + return (T)selectedObj; + } + } + } + return null; + } + + /** + * Fetches the currently selected objects from the workbench site and returns those of given type. If none of the + * selected objects are of given type, returns null + * + * @param site + * The workbench site + * @param expectedType + * Type of the selected objects to look for + * @return The selected objects of given type if found, else null + */ + public Set getSelectedEntities(IWorkbenchSite site, Class expectedType) { + return getSelectedEntities(site.getWorkbenchWindow(), expectedType); + } + + @SuppressWarnings("unchecked") + public Set getSelectedEntities(IWorkbenchWindow window, Class expectedType) { + Set selectedEntities = new HashSet(); + ISelection selection = window.getSelectionService().getSelection(); + if (selection instanceof IStructuredSelection) { + Iterator iter = ((IStructuredSelection) selection).iterator(); + while (iter.hasNext()) { + Object selectedObj = iter.next(); + if (selectedObj.getClass() == expectedType) { + selectedEntities.add((T) selectedObj); + } + } + } + return selectedEntities; + } + + + public void configureCheckboxTableViewer(final CheckboxTableViewer tableViewer) { + tableViewer.addCheckStateListener(new ICheckStateListener() { + + @Override + public void checkStateChanged(CheckStateChangedEvent event) { + tableViewer.setSelection(new StructuredSelection(tableViewer.getCheckedElements())); + } + }); + + tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + @SuppressWarnings("unchecked") + @Override + public void selectionChanged(SelectionChangedEvent event) { + List checkedElements = Arrays.asList(tableViewer.getCheckedElements()); + List selectedElements = ((IStructuredSelection)event.getSelection()).toList(); + + if (JavaUtil.listsDiffer(checkedElements, selectedElements)) { + tableViewer.setSelection(new StructuredSelection(tableViewer.getCheckedElements())); + } + } + }); + } + + public void showView(String viewId) { + try { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(viewId); + } catch (PartInitException e) { + String errMsg = "Could not open view [" + viewId + "]"; + logger.error(errMsg, e); + throw new GlusterRuntimeException(errMsg, e); + } + } + + public void showTerminalView() { + showView(ConsoleConstants.TERMINAL_VIEW_ID); + } + + public void showProgressView() { + showView(IProgressConstants.PROGRESS_VIEW_ID); + } + + public void showTaskView() { + NavigationView navigationView = (NavigationView) getView(NavigationView.ID); + navigationView.selectEntity(GlusterDataModelManager.getInstance().getModel().getCluster()); + + showView(TasksView.ID); + } + + public void setStatusMessage(String message) { + clearStatusMessage(); + Application.getApplication().getStatusLineManager().setMessage(message); + Application.getApplication().getStatusLineManager().setMessage(message); + } + + public void clearStatusMessage() { + Application.getApplication().getStatusLineManager().setMessage(null); + } + + public String getDiskToolTip(Disk disk) { + return disk.getQualifiedName() + " - " + disk.getDescription(); + } + + public void clearSection(Composite section) { + if (section.isDisposed()) { + return; + } + for(Control control : section.getChildren()) { + if(! control.isDisposed()) { + control.dispose(); + } + } + section.layout(true); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterChartPalette.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterChartPalette.java new file mode 100644 index 00000000..4c579103 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterChartPalette.java @@ -0,0 +1,479 @@ +/*********************************************************************** + * Copyright (c) 2004 Actuate Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - initial API and implementation + ***********************************************************************/ + +package org.gluster.storage.management.console.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.birt.chart.engine.i18n.Messages; +import org.eclipse.birt.chart.log.ILogger; +import org.eclipse.birt.chart.log.Logger; +import org.eclipse.birt.chart.model.attribute.AttributeFactory; +import org.eclipse.birt.chart.model.attribute.AttributePackage; +import org.eclipse.birt.chart.model.attribute.ColorDefinition; +import org.eclipse.birt.chart.model.attribute.Fill; +import org.eclipse.birt.chart.model.attribute.Palette; +import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import com.ibm.icu.util.ULocale; + +/** + * An implementation of the model object ' + * Palette'. + *

    + * The following features are implemented: + *

      + *
    • {@link org.eclipse.birt.chart.model.attribute.impl.GlusterChartPalette#getName Name}
    • + *
    • {@link org.eclipse.birt.chart.model.attribute.impl.GlusterChartPalette#getEntries Entries}
    • + *
    + *

    + * + * @generated + */ +public class GlusterChartPalette extends EObjectImpl implements Palette +{ + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The cached value of the '{@link #getEntries() Entries}' containment reference list. + * + * @see #getEntries() + * @generated + * @ordered + */ + protected EList entries; + + private static ILogger logger = Logger.getLogger( "org.eclipse.birt.chart.engine/model.attribute.impl" ); //$NON-NLS-1$ + + private static List colorLib = new ArrayList( 32 ); + static + { + colorLib.add( ColorDefinitionImpl.create ( 0, 1, 252) ); + colorLib.add( ColorDefinitionImpl.create ( 255, 0, 255) ); + //colorLib.add( ColorDefinitionImpl.BLUE() ); + //colorLib.add( ColorDefinitionImpl.create( 232, 172, 57 ) ); + } + + /** + * + * @generated + */ + public GlusterChartPalette( ) + { + super( ); + } + + /** + * + * @generated + */ + @Override + protected EClass eStaticClass( ) + { + return AttributePackage.Literals.PALETTE; + } + + /** + * + * @generated + */ + public String getName( ) + { + return name; + } + + /** + * + * @generated + */ + public void setName( String newName ) + { + String oldName = name; + name = newName; + if ( eNotificationRequired( ) ) + eNotify( new ENotificationImpl( this, + Notification.SET, + AttributePackage.PALETTE__NAME, + oldName, + name ) ); + } + + /** + * + * @generated + */ + public EList getEntries( ) + { + if ( entries == null ) + { + entries = new EObjectContainmentEList( Fill.class, + this, + AttributePackage.PALETTE__ENTRIES ); + } + return entries; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove( InternalEObject otherEnd, + int featureID, NotificationChain msgs ) + { + switch ( featureID ) + { + case AttributePackage.PALETTE__ENTRIES : + return ( (InternalEList) getEntries( ) ).basicRemove( otherEnd, + msgs ); + } + return super.eInverseRemove( otherEnd, featureID, msgs ); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet( int featureID, boolean resolve, boolean coreType ) + { + switch ( featureID ) + { + case AttributePackage.PALETTE__NAME : + return getName( ); + case AttributePackage.PALETTE__ENTRIES : + return getEntries( ); + } + return super.eGet( featureID, resolve, coreType ); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet( int featureID, Object newValue ) + { + switch ( featureID ) + { + case AttributePackage.PALETTE__NAME : + setName( (String) newValue ); + return; + case AttributePackage.PALETTE__ENTRIES : + getEntries( ).clear( ); + getEntries( ).addAll( (Collection) newValue ); + return; + } + super.eSet( featureID, newValue ); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset( int featureID ) + { + switch ( featureID ) + { + case AttributePackage.PALETTE__NAME : + setName( NAME_EDEFAULT ); + return; + case AttributePackage.PALETTE__ENTRIES : + getEntries( ).clear( ); + return; + } + super.eUnset( featureID ); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet( int featureID ) + { + switch ( featureID ) + { + case AttributePackage.PALETTE__NAME : + return NAME_EDEFAULT == null ? name != null + : !NAME_EDEFAULT.equals( name ); + case AttributePackage.PALETTE__ENTRIES : + return entries != null && !entries.isEmpty( ); + } + return super.eIsSet( featureID ); + } + + /** + * + * @generated + */ + @Override + public String toString( ) + { + if ( eIsProxy( ) ) + return super.toString( ); + + StringBuffer result = new StringBuffer( super.toString( ) ); + result.append( " (name: " ); //$NON-NLS-1$ + result.append( name ); + result.append( ')' ); + return result.toString( ); + } + + /** + * A convenience method provided to create an empty or pre-initialized + * palette + * + * NOTE: Manually written + * + * @param bEmpty + */ + public static final Palette create( int iIndex, boolean bEmpty ) + { + final Palette p = AttributeFactory.eINSTANCE.createPalette( ); + + if ( !bEmpty ) + { + p.shift( iIndex ); + } + return p; + } + + /** + * A convenience method provided to create a palette with a single color + * entry + * + * NOTE: Manually written + * + * @param f + */ + public static final Palette create( Fill f ) + { + final Palette p = AttributeFactory.eINSTANCE.createPalette( ); + p.getEntries( ).add( f ); + return p; + } + + /** + * Shift the list content from tail to head. + * + * @param lst + * @param pos + */ + private static final void shiftList( final List lst, int pos ) + { + int size = lst.size( ); + + if ( pos < 1 ) + { + pos = 0; + } + + if ( pos >= size ) + { + pos = pos % size; + } + + if ( pos == 0 ) + { + return; + } + + Object[] array = lst.toArray( ); + + lst.clear( ); + + for ( int i = pos; i < array.length; i++ ) + { + lst.add( array[i] ); + } + + for ( int i = 0; i < pos; i++ ) + { + lst.add( array[i] ); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.model.attribute.Palette#update(int) + */ + public final void update( int iIndex ) + { + final EList el = getEntries( ); + el.clear( ); + if ( iIndex < 0 ) + { + // a rotation version of palette-0, rataion pos is the negatvie + // index. + ArrayList al = new ArrayList( ); + + al.add( ColorDefinitionImpl.create( 80, 166, 218 ) ); + al.add( ColorDefinitionImpl.create( 242, 88, 106 ) ); + al.add( ColorDefinitionImpl.create( 232, 172, 57 ) ); + al.add( ColorDefinitionImpl.create( 128, 255, 128 ) ); + al.add( ColorDefinitionImpl.create( 64, 128, 128 ) ); + al.add( ColorDefinitionImpl.create( 128, 128, 192 ) ); + al.add( ColorDefinitionImpl.create( 170, 85, 85 ) ); + al.add( ColorDefinitionImpl.create( 128, 128, 0 ) ); + + shiftList( al, -iIndex ); + + el.addAll( al ); + } + else if ( iIndex == 0 ) + { + el.add( ColorDefinitionImpl.create( 80, 166, 218 ) ); + el.add( ColorDefinitionImpl.create( 242, 88, 106 ) ); + el.add( ColorDefinitionImpl.create( 232, 172, 57 ) ); + el.add( ColorDefinitionImpl.create( 128, 255, 128 ) ); + el.add( ColorDefinitionImpl.create( 64, 128, 128 ) ); + el.add( ColorDefinitionImpl.create( 128, 128, 192 ) ); + el.add( ColorDefinitionImpl.create( 170, 85, 85 ) ); + el.add( ColorDefinitionImpl.create( 128, 128, 0 ) ); + } + else if ( iIndex == 1 ) + { + el.add( ColorDefinitionImpl.create( 225, 225, 255 ) ); + el.add( ColorDefinitionImpl.create( 223, 197, 41 ) ); + el.add( ColorDefinitionImpl.create( 249, 225, 191 ) ); + el.add( ColorDefinitionImpl.create( 255, 205, 225 ) ); + el.add( ColorDefinitionImpl.create( 225, 255, 225 ) ); + el.add( ColorDefinitionImpl.create( 255, 191, 255 ) ); + el.add( ColorDefinitionImpl.create( 185, 185, 221 ) ); + el.add( ColorDefinitionImpl.create( 40, 255, 148 ) ); + } + else + { + logger.log( ILogger.WARNING, + Messages.getString( "error.unknown.palette", //$NON-NLS-1$ + new Object[]{ + Integer.valueOf( iIndex ) + }, + ULocale.getDefault( ) ) ); + update( 0 ); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.birt.chart.model.attribute.Palette#update(org.eclipse.birt.chart.model.attribute.Fill) + */ + public final void update( Fill f ) + { + final EList el = getEntries( ); + el.clear( ); + el.add( f ); + } + + public void shift( int step ) + { + shift( step, colorLib.size( ) ); + } + + public void shift( int step, int size ) + { + if ( size <= 0 || size > colorLib.size( ) ) + { + size = colorLib.size( ); + } + + final EList el = getEntries( ); + el.clear( ); + + if ( step == 0 || Math.abs( step ) >= size ) + { + // Do nothing + step = 0; + } + else if ( step < 0 ) + { + // Move to the left side + step = -step; + } + else if ( step > 0 ) + { + // Move to the right side + step = size - step; + } + + for ( int i = step; i < size; i++ ) + { + el.add( ( (ColorDefinition) colorLib.get( i ) ).copyInstance( ) ); + } + for ( int i = 0; i < step; i++ ) + { + el.add( ( (ColorDefinition) colorLib.get( i ) ).copyInstance( ) ); + } + } + + /** + * A convenient method to get an instance copy. This is much faster than the + * ECoreUtil.copy(). + */ + public Palette copyInstance( ) + { + GlusterChartPalette dest = new GlusterChartPalette( ); + dest.set( this ); + return dest; + } + + protected void set( Palette src ) + { + if ( src.getEntries( ) != null ) + { + EList list = getEntries( ); + for ( Fill element : src.getEntries( ) ) + { + list.add( element.copyInstance( ) ); + } + } + name = src.getName( ); + } + +} // GlusterChartPalette diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterLogger.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterLogger.java new file mode 100644 index 00000000..4a2ba53b --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/GlusterLogger.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.utils; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.Status; +import org.gluster.storage.management.console.Activator; + + +/** + * + */ +public class GlusterLogger { + private static final ILog log = Activator.getDefault().getLog(); + private static GlusterLogger instance = new GlusterLogger(); + + private GlusterLogger() { + } + + public static GlusterLogger getInstance() { + return instance; + } + + private void log(String message, int severity, Throwable t) { + log.log(new Status(severity, Activator.PLUGIN_ID, message, t)); + } + + public void error(String message) { + log(message, Status.ERROR, null); + } + + public void error(String message, Throwable t) { + log(message, Status.ERROR, t); + } + + public void warn(String message) { + log(message, Status.WARNING, null); + } + + public void warn(String message, Throwable t) { + log(message, Status.WARNING, t); + } + + public void info(String message) { + log(message, Status.INFO, null); + } + + public void info(String message, Throwable t) { + log(message, Status.INFO, t); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ImageUtil.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ImageUtil.java new file mode 100644 index 00000000..eb4a31b9 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/ImageUtil.java @@ -0,0 +1,52 @@ +/** + * ImageUtil.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.utils; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.gluster.storage.management.console.Application; +import org.gluster.storage.management.core.utils.LRUCache; + + +/** + * + */ +public class ImageUtil { + private static final LRUCache imageCache = new LRUCache(20); + + public ImageDescriptor getImageDescriptor(String imagePath) { + return AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, imagePath); + } + + public synchronized Image getImage(String imagePath) { + if(imageCache.containsKey(imagePath)) { + return imageCache.get(imagePath); + } + return createImage(imagePath); + } + + private Image createImage(String imagePath) { + Image image = getImageDescriptor(imagePath).createImage(); + imageCache.put(imagePath, image); + return image; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/TableViewerComparator.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/TableViewerComparator.java new file mode 100644 index 00000000..9df3942a --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/TableViewerComparator.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.utils; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; + +/** + * Comparator for sorting contents of a table viewer + */ +public class TableViewerComparator extends ViewerComparator { + private int column = -1; + private static final int ASCENDING = 0; + private static final int DESCENDING = 1; + private static final int NONE = -1; + private int direction = DESCENDING; + + public TableViewerComparator() { + this(NONE); + } + + public TableViewerComparator(int direction) { + this.direction = direction; + } + + public int getDirection() { + return direction == DESCENDING ? SWT.DOWN : (direction == ASCENDING ? SWT.UP : SWT.NONE); + } + + public void setColumn(int column) { + if (column == this.column) { + // Same column as last sort; toggle the direction + direction = 1 - direction; + } else { + // first column selection or new column; do an ascending sort + direction = ASCENDING; + this.column = column; + } + } + + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + if(direction == NONE) { + // no sorting + return 0; + } + + int result = super.compare(viewer, e1, e2); + // If descending order, flip the direction + if (direction == DESCENDING) { + result = -result; + } + + return result; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/validators/StringRequiredValidator.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/validators/StringRequiredValidator.java new file mode 100644 index 00000000..5d364606 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/validators/StringRequiredValidator.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.validators; + +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.swt.widgets.Control; + +public class StringRequiredValidator implements IValidator { + protected final String errorText; + protected final ControlDecoration controlDecoration; + protected final Control linkedControl; + + public StringRequiredValidator(String errorText, ControlDecoration controlDecoration, Control linkedControl) { + super(); + this.errorText = errorText; + this.controlDecoration = controlDecoration; + this.linkedControl = linkedControl; + } + + public StringRequiredValidator(String errorText, ControlDecoration controlDecoration) { + this(errorText, controlDecoration, null); + } + + public IStatus validate(Object value) { + if (value instanceof String) { + if (((String) value).isEmpty()) { + controlDecoration.setDescriptionText(errorText); + controlDecoration.show(); + if (linkedControl != null) { + linkedControl.setEnabled(false); + } + return ValidationStatus.error(errorText); + } + } + if(linkedControl != null) { + linkedControl.setEnabled(true); + } + controlDecoration.hide(); + return Status.OK_STATUS; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterAdapterFactory.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterAdapterFactory.java new file mode 100644 index 00000000..a830d4ea --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterAdapterFactory.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.gluster.storage.management.console.Application; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterDataModel; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Volume; + + +public class ClusterAdapterFactory implements IAdapterFactory { + private IWorkbenchAdapter entityAdapter = new IWorkbenchAdapter() { + + @Override + public Object getParent(Object o) { + return ((Entity) o).getParent(); + } + + @Override + public String getLabel(Object o) { + return ((Entity)o).getName(); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public ImageDescriptor getImageDescriptor(Object object) { + String iconPath = null; + + if(object instanceof GlusterDataModel || object instanceof Cluster) { + iconPath = IImageKeys.CLUSTER_16x16; + } + + if(object instanceof EntityGroup) { + Class entityType = ((EntityGroup) object).getEntityType(); + if(entityType == Volume.class) { + iconPath = IImageKeys.VOLUMES_16x16; + } else { + iconPath = IImageKeys.SERVERS_16x16; + } + } + + if(object instanceof Volume) { + iconPath = IImageKeys.VOLUME_16x16; + } + + if(object instanceof Server || object instanceof GlusterServer) { + iconPath = IImageKeys.SERVER_16x16; + } + + return AbstractUIPlugin.imageDescriptorFromPlugin( + Application.PLUGIN_ID, iconPath); + } + + @Override + public Object[] getChildren(Object o) { + return ((Entity)o).getChildren().toArray(); + } + }; + + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adapterType == IWorkbenchAdapter.class) { + if (adaptableObject instanceof Entity) { + return entityAdapter; + } + } + return null; + } + + @SuppressWarnings("rawtypes") + @Override + public Class[] getAdapterList() { + return new Class[] { IWorkbenchAdapter.class }; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterSummaryView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterSummaryView.java new file mode 100644 index 00000000..41d2daa7 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ClusterSummaryView.java @@ -0,0 +1,469 @@ +/** + * DiscoveredServerView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import java.util.List; + +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.Activator; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.actions.ActionConstants; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.console.utils.ChartUtil; +import org.gluster.storage.management.console.utils.ChartViewerComposite; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterDataModel; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; + + +/** + * + */ +public class ClusterSummaryView extends ViewPart { + public static final String ID = ClusterSummaryView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private Cluster cluster; + private Composite cpuChartSection; + private Composite networkChartSection; + private GlusterDataModel model = GlusterDataModelManager.getInstance().getModel(); + private ClusterListener clusterListener; + private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + private Composite alertsSection; + private Composite tasksSection; + private static final ChartUtil chartUtil = ChartUtil.getInstance(); + private IPropertyChangeListener propertyChangeListener; + private Label onlineServerCountLabel; + private Label offlineServerCountLabel; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + if (cluster == null) { + cluster = model.getCluster(); + } + setPartName("Summary"); + createSections(parent); + + createListeners(); + } + + private void createListeners() { + createClusterListener(); + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + + createPropertyChangeListener(); + preferenceStore.addPropertyChangeListener(propertyChangeListener ); + } + + private void createPropertyChangeListener() { + propertyChangeListener = new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + String preferenceName = event.getProperty(); + GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + if(preferenceName.equals(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD)) { + modelManager.initializeAggregatedCpuStats(cluster); + String cpuStatsPeriod = (String)event.getNewValue(); + refreshChartSection(cpuChartSection, cluster.getAggregatedCpuStats(), cpuStatsPeriod, "%", 100, 4, + chartUtil.new CpuChartPeriodLinkListener(null, cpuStatsPeriod, toolkit), 2); + } else if(preferenceName.equals(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD)) { + modelManager.initializeAggregatedNetworkStats(cluster); + String networkStatsPeriod = (String)event.getNewValue(); + refreshChartSection(networkChartSection, cluster.getAggregatedNetworkStats(), networkStatsPeriod, "KiB/s", -1, + 4, chartUtil.new NetworkChartPeriodLinkListener(null, networkStatsPeriod, toolkit), 2); + } + } + }; + } + + private void createClusterListener() { + clusterListener = new DefaultClusterListener() { + @Override + public void aggregatedStatsChanged() { + super.aggregatedStatsChanged(); + refreshCharts(); + populateOnlineOfflineServerCount(); + } + + @Override + public void alertsGenerated() { + super.alertsGenerated(); + guiHelper.clearSection(alertsSection); + populateAlerts(); + } + + @Override + public void taskAdded(TaskInfo taskInfo) { + super.taskAdded(taskInfo); + updateTaskSection(); + } + + @Override + public void taskRemoved(TaskInfo taskInfo) { + super.taskRemoved(taskInfo); + updateTaskSection(); + } + + @Override + public void taskUpdated(TaskInfo taskInfo) { + super.taskUpdated(taskInfo); + updateTaskSection(); + } + + private void updateTaskSection() { + guiHelper.clearSection(tasksSection); + populateTasksSection(); + } + }; + } + + @Override + public void dispose() { + super.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + preferenceStore.removePropertyChangeListener(propertyChangeListener); + } + + private void refreshCharts() { + String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD); + String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD); + refreshChartSection(cpuChartSection, cluster.getAggregatedCpuStats(), cpuStatsPeriod, "%", 100, 4, + chartUtil.new CpuChartPeriodLinkListener(null, cpuStatsPeriod, toolkit), 2); + refreshChartSection(networkChartSection, cluster.getAggregatedNetworkStats(), networkStatsPeriod, "KiB/s", -1, + 4, chartUtil.new NetworkChartPeriodLinkListener(null, networkStatsPeriod, toolkit), 2); + } + + private int getServerCountByStatus(Cluster cluster, SERVER_STATUS status) { + int count = 0; + for (GlusterServer server : cluster.getServers()) { + if (server.getStatus() == status) { + count++; + } + } + return count; + } + + private void createServersSection() { + Composite section = guiHelper.createSection(form, toolkit, "Servers", null, 2, false); + toolkit.createLabel(section, "Online : "); + onlineServerCountLabel = toolkit.createLabel(section, ""); + + toolkit.createLabel(section, "Offline : "); + offlineServerCountLabel = toolkit.createLabel(section, ""); + populateOnlineOfflineServerCount(); + } + + private void populateOnlineOfflineServerCount() { + int onlineServerCount = getServerCountByStatus(cluster, SERVER_STATUS.ONLINE); + int offlineServerCount = getServerCountByStatus(cluster, SERVER_STATUS.OFFLINE); + onlineServerCountLabel.setText("" + onlineServerCount); + onlineServerCountLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN)); + offlineServerCountLabel.setText("" + offlineServerCount); + offlineServerCountLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } + + + private void createDiskSpaceSection() { + Composite section = guiHelper.createSection(form, toolkit, "Disk Space", null, 3, false); + if (cluster.getServers().size() == 0) { + toolkit.createLabel(section, "This section will be populated after at least" + CoreConstants.NEWLINE + + "one server is added to the storage cloud."); + return; + } + + double totalDiskSpace = cluster.getTotalDiskSpace(); + double diskSpaceInUse = cluster.getDiskSpaceInUse(); + Double[] values = new Double[] { diskSpaceInUse / 1024, (totalDiskSpace - diskSpaceInUse) / 1024 }; + createDiskSpaceChart(section, values); + } + + private void createDiskSpaceChart(Composite section, Double[] values) { + String[] categories = new String[] { "Used Space (GB)", "Free Space (GB)" }; + ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, categories, values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = 400; + data.heightHint = 180; + data.verticalAlignment = SWT.CENTER; + chartViewerComposite.setLayoutData(data); + } + + private void createAlertsSection() { + alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false); + populateAlerts(); + } + + private void populateAlerts() { + List alerts = cluster.getAlerts(); + for (Alert alert : alerts) { + addAlertLabel(alertsSection, alert); + } + alertsSection.layout(); + form.reflow(true); + } + + private void addAlertLabel(Composite section, Alert alert) { + CLabel lblAlert = new CLabel(section, SWT.FLAT); + GridData layoutData = new GridData(); + layoutData.widthHint = 400; + layoutData.horizontalIndent = 20; + lblAlert.setLayoutData(layoutData); + + Image alertImage = null; + switch (alert.getType()) { + case OFFLINE_VOLUME_BRICKS_ALERT: + alertImage = guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22); + break; + case DISK_USAGE_ALERT: + alertImage = guiHelper.getImage(IImageKeys.LOW_DISK_SPACE_22x22); + break; + case OFFLINE_SERVERS_ALERT: + alertImage = guiHelper.getImage(IImageKeys.SERVER_OFFLINE_22x22); + break; + case MEMORY_USAGE_ALERT: + alertImage = guiHelper.getImage(IImageKeys.MEMORY_USAGE_ALERT_22x22); + break; + case CPU_USAGE_ALERT: + alertImage = guiHelper.getImage(IImageKeys.SERVER_WARNING_22x22); + break; + case OFFLINE_VOLUME_ALERT: + alertImage = guiHelper.getImage(IImageKeys.VOLUME_OFFLINE_22x22); + break; + } + lblAlert.setText(alert.getMessage()); + ControlDecoration dec = new ControlDecoration(lblAlert, SWT.LEFT); + dec.setImage(alertImage); + lblAlert.redraw(); + } + + private void createActionsSection() { + Composite section = guiHelper.createSection(form, toolkit, "Actions", null, 1, false); + + ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(section, SWT.NONE); + imageHyperlink.setText("Create Volume"); + imageHyperlink.setImage(guiHelper.getImage(IImageKeys.CREATE_VOLUME_48x48)); + imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { + IHandlerService hs = (IHandlerService) getSite().getService(IHandlerService.class); + try { + hs.executeCommand(ActionConstants.COMMAND_CREATE_VOLUME, null); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + + imageHyperlink = toolkit.createImageHyperlink(section, SWT.NONE); + imageHyperlink.setText("Add Server(s)"); + imageHyperlink.setImage(guiHelper.getImage(IImageKeys.ADD_SERVER_48x48)); + imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { + // Open the "discovered servers" view by selecting the corresponding entity in the navigation view + EntityGroup autoDiscoveredServersEntityGroup = GlusterDataModelManager.getInstance().getModel() + .getCluster().getEntityGroup(Server.class); + + NavigationView navigationView = (NavigationView) guiHelper.getView(NavigationView.ID); + navigationView.selectEntity(autoDiscoveredServersEntityGroup); + } + }); + } + + private void createSections(Composite parent) { + form = guiHelper.setupForm(parent, toolkit, "Cluster Summary"); + + if (cluster.getServers().size() > 0 + && (cluster.getAggregatedCpuStats().getRows() == null || cluster.getAggregatedNetworkStats().getRows() == null)) { + // cluster has servers, but stats are null. Happens when user logs in to a new cluster, ' + // and then adds the first server. + GlusterDataModelManager.getInstance().initializeAggregatedCpuStats(cluster); + GlusterDataModelManager.getInstance().initializeAggregatedNetworkStats(cluster); + } + + createServersSection(); + createDiskSpaceSection(); + createCPUUsageSection(); + createNetworkUsageSection(); + createActionsSection(); + createAlertsSection(); + createTasksSection(); + + parent.layout(); // IMP: lays out the form properly + } + + private Composite createAreaChartSection(ServerStats stats, String sectionTitle, int dataColumnIndex, String unit, String timestampFormat, ChartPeriodLinkListener listener, double maxValue, int chartLinkColumnCount) { + Composite section = guiHelper.createSection(form, toolkit, sectionTitle, null, 1, false); + if (cluster.getServers().size() == 0) { + toolkit.createLabel(section, "This section will be populated after at least" + CoreConstants.NEWLINE + + "one server is added to the storage cloud."); + return section; + } + + ChartUtil.getInstance().createAreaChart(toolkit, section, stats, dataColumnIndex, unit, timestampFormat, listener, maxValue, chartLinkColumnCount); + return section; + } + + private void createCPUUsageSection() { + IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_AGGREGATED_CHART_PERIOD); + + // in case of CPU usage, there are three elements in usage data: user, system and total. we use total. + cpuChartSection = createAreaChartSection(cluster.getAggregatedCpuStats(), "CPU Usage (Aggregated)", 2, "%", + getTimestampFormatForPeriod(cpuStatsPeriod), chartUtil.new CpuChartPeriodLinkListener(null, + cpuStatsPeriod, toolkit), 100, 4); + } + + private String getTimestampFormatForPeriod(String statsPeriod) { + if(statsPeriod.equals(GlusterConstants.STATS_PERIOD_1DAY)) { + return "HH:mm"; + } else if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1WEEK)) { + return "dd-MMM HH:mm"; + } else { + return "dd-MMM"; + } + } + + private void createNetworkUsageSection() { + IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_AGGREGATED_CHART_PERIOD); + + // in case of network usage, there are three elements in usage data: received, transmitted and total. we use total. + networkChartSection = createAreaChartSection(cluster.getAggregatedNetworkStats(), "Network Usage (Aggregated)", + 2, "KiB/s", getTimestampFormatForPeriod(networkStatsPeriod), + chartUtil.new NetworkChartPeriodLinkListener(null, networkStatsPeriod, toolkit), -1, 4); + } + + private void createTasksSection() { + tasksSection = guiHelper.createSection(form, toolkit, CoreConstants.RUNNING_TASKS, null, 1, false); + populateTasksSection(); + } + + private void populateTasksSection() { + for (TaskInfo taskInfo : cluster.getTaskInfoList()) { + if (taskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS) { + addTaskLabel(tasksSection, taskInfo); + } + } + tasksSection.layout(); + form.reflow(true); + } + + private void addTaskLabel(Composite section, TaskInfo taskInfo) { + //TODO: create link and open the task progress view + CLabel lblAlert = new CLabel(section, SWT.NONE); + + Image taskImage = null; + switch(taskInfo.getType()) { + case DISK_FORMAT: + taskImage = guiHelper.getImage(IImageKeys.DISK_INITIALIZING_22x22); + break; + case BRICK_MIGRATE: + taskImage = guiHelper.getImage(IImageKeys.BRICK_MIGRATE_22x22); + break; + case VOLUME_REBALANCE: + taskImage = guiHelper.getImage(IImageKeys.VOLUME_REBALANCE_22x22); + break; + } + + String description = taskInfo.getDescription(); + switch (taskInfo.getStatus().getCode()) { + case Status.STATUS_CODE_PAUSE: + description += " (paused)"; + break; + case Status.STATUS_CODE_COMMIT_PENDING: + description += " (commit pending)"; + break; + case Status.STATUS_CODE_FAILURE: + description += " (failed)"; + break; + } + lblAlert.setText(description); + lblAlert.setImage(taskImage); + lblAlert.redraw(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + if (form != null) { + form.setFocus(); + } + } + + private void refreshChartSection(Composite section, ServerStats stats, String statsPeriod, String unit, + double maxValue, int columnCount, ChartPeriodLinkListener linkListener, int dataColumnIndex) { + if(stats == null) { + return; + } + + for (Control control : section.getChildren()) { + if (!control.isDisposed()) { + control.dispose(); + } + } + chartUtil.createAreaChart(toolkit, section, stats, dataColumnIndex, unit, + getTimestampFormatForPeriod(statsPeriod), linkListener, maxValue, columnCount); + section.layout(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServerView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServerView.java new file mode 100644 index 00000000..7ae6fe61 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServerView.java @@ -0,0 +1,90 @@ +/** + * DiscoveredServerView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.utils.NumberUtil; + + +/** + * @author root + * + */ +public class DiscoveredServerView extends ViewPart { + public static final String ID = DiscoveredServerView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private Server server; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + if (server == null) { + server = guiHelper.getSelectedEntity(getSite(), Server.class); + } + createSections(parent); + } + + private void createServerSummarySection() { + Composite section = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); + + toolkit.createLabel(section, "Number of CPUs: ", SWT.NONE); + toolkit.createLabel(section, "" + server.getNumOfCPUs(), SWT.NONE); + + toolkit.createLabel(section, "Total Memory (GB): ", SWT.NONE); + toolkit.createLabel(section, "" + NumberUtil.formatNumber((server.getTotalMemory() / 1024)), SWT.NONE); + + toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + toolkit.createLabel(section, "" + NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)), SWT.NONE); + } + + private void createSections(Composite parent) { + String serverName = server.getName(); + form = guiHelper.setupForm(parent, toolkit, "Discovered Server Summary [" + serverName + "]"); + createServerSummarySection(); + + parent.layout(); // IMP: lays out the form properly + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + if (form != null) { + form.setFocus(); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServersView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServersView.java new file mode 100644 index 00000000..e3e7ec8a --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DiscoveredServersView.java @@ -0,0 +1,83 @@ +/** + * DiscoveredServersView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.ServersPage; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Server; + + +/** + * + */ +public class DiscoveredServersView extends ViewPart implements IDoubleClickListener { + public static final String ID = DiscoveredServersView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private EntityGroup servers; + private ServersPage page; + + public DiscoveredServersView() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void createPartControl(Composite parent) { + if (servers == null) { + Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); + if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Server.class) { + servers = (EntityGroup)selectedObj; + } + } + + page = new ServersPage(parent, getSite(), servers); + page.addDoubleClickListener(this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + page.setFocus(); + } + + @Override + public void doubleClick(DoubleClickEvent event) { + NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); + if (clusterView != null) { + clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DisksView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DisksView.java new file mode 100644 index 00000000..1263a07f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/DisksView.java @@ -0,0 +1,45 @@ +package org.gluster.storage.management.console.views; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.DisksPage; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterServer; + + +public class DisksView extends ViewPart { + public static final String ID = DisksView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private EntityGroup servers; + private DisksPage page; + + @SuppressWarnings("unchecked") + @Override + public void createPartControl(Composite parent) { + if (servers == null) { + servers = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); + } + + page = new DisksPage(parent, SWT.NONE, getSite(), getAllDisks(servers)); + //page.layout(); // IMP: lays out the form properly + } + + private List getAllDisks(EntityGroup servers) { + List disks = new ArrayList(); + for(GlusterServer server : servers.getEntities()) { + disks.addAll(server.getDisks()); + } + return disks; + } + + @Override + public void setFocus() { + page.setFocus(); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerDisksView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerDisksView.java new file mode 100644 index 00000000..8aa0fde1 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerDisksView.java @@ -0,0 +1,84 @@ +/** + * GlusterServerDisksView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.ServerDisksPage; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Event.EVENT_TYPE; + + +public class GlusterServerDisksView extends ViewPart { + public static final String ID = GlusterServerDisksView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private ClusterListener clusterListener; + private GlusterServer server; + private ServerDisksPage page; + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + if (server == null) { + server = guiHelper.getSelectedEntity(getSite(), GlusterServer.class); + } + page = new ServerDisksPage(parent, SWT.NONE, getSite(), server.getDisks()); + + final ViewPart thisView = this; + clusterListener = new DefaultClusterListener() { + @Override + public void serverChanged(GlusterServer server, Event event) { + super.serverChanged(server, event); + if(event.getEventType() == EVENT_TYPE.GLUSTER_SERVER_CHANGED) { + if(!server.isOnline()) { + getViewSite().getPage().hideView(thisView); + } + } + } + }; + + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + + parent.layout(); // IMP: lays out the form properly + } + + @Override + public void dispose() { + super.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + page.setFocus(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerLogsView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerLogsView.java new file mode 100644 index 00000000..2e8ebe60 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerLogsView.java @@ -0,0 +1,59 @@ +/** + * GlusterServerLogsView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.ServerLogsPage; +import org.gluster.storage.management.core.model.GlusterServer; + + +public class GlusterServerLogsView extends ViewPart { + public static final String ID = GlusterServerLogsView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private GlusterServer server; + private ServerLogsPage page; + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + if (server == null) { + server = guiHelper.getSelectedEntity(getSite(), GlusterServer.class); + } + + page = new ServerLogsPage(parent, SWT.NONE, server); + + parent.layout(); // IMP: lays out the form properly + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + page.setFocus(); + } +} + diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerSummaryView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerSummaryView.java new file mode 100644 index 00000000..e5570ad9 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServerSummaryView.java @@ -0,0 +1,544 @@ +/** + * GlusterServerSummaryView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.birt.chart.util.CDateTime; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.ProgressBar; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.client.GlusterServersClient; +import org.gluster.storage.management.console.Activator; +import org.gluster.storage.management.console.ConsoleConstants; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.NetworkInterfaceTableLabelProvider; +import org.gluster.storage.management.console.preferences.PreferenceConstants; +import org.gluster.storage.management.console.toolbar.GlusterToolbarManager; +import org.gluster.storage.management.console.utils.ChartUtil; +import org.gluster.storage.management.console.utils.ChartViewerComposite; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.ServerStatsRow; +import org.gluster.storage.management.core.model.Event.EVENT_TYPE; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.utils.NumberUtil; + +import com.ibm.icu.util.Calendar; +import com.richclientgui.toolbox.gauges.CoolGauge; + +public class GlusterServerSummaryView extends ViewPart { + public static final String ID = GlusterServerSummaryView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private GlusterServer server; + private ClusterListener clusterListener; + private static final int CHART_WIDTH = 350; + private static final int CHART_HEIGHT = 250; + private static final GlusterLogger logger = GlusterLogger.getInstance(); + private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); + + public enum NETWORK_INTERFACE_TABLE_COLUMN_INDICES { + INTERFACE, MODEL, SPEED, IP_ADDRESS, NETMASK, GATEWAY + }; + + private static final String[] NETWORK_INTERFACE_TABLE_COLUMN_NAMES = { "Interface", "Model", "Speed", "IP Address", + "Netmask", "Gateway" }; + private CoolGauge cpuGauge; + private IPropertyChangeListener propertyChangeListener; + private Composite cpuUsageSection; + private Composite networkUsageSection; + private Composite memoryUsageSection; + private static final ChartUtil chartUtil = ChartUtil.getInstance(); + private Composite serverSummarySection; + private Label numCpus; + private ProgressBar memoryUsageBar; + private ProgressBar diskUsageBar; + private CLabel lblServerStatus; + + @Override + public void createPartControl(Composite parent) { + if (server == null) { + server = guiHelper.getSelectedEntity(getSite(), GlusterServer.class); + } + setPartName("Summary"); + createSections(parent); + + createListeners(); + } + + private void createListeners() { + // Refresh the server details whenever the server has changed + createClusterListener(); + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + + createPropertyChangeListener(); + preferenceStore.addPropertyChangeListener(propertyChangeListener); + } + + private void createPropertyChangeListener() { + propertyChangeListener = new IPropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent event) { + String propertyName = event.getProperty(); + if(propertyName.equals(PreferenceConstants.P_CPU_CHART_PERIOD)) { + refreshCpuChart(); + } else if(propertyName.equals(PreferenceConstants.P_MEM_CHART_PERIOD)) { + refreshMemoryChart(); + } else if (propertyName.equals(PreferenceConstants.P_NETWORK_CHART_PERIOD) + || propertyName.equals(PreferenceConstants.P_DEFAULT_NETWORK_INTERFACE_PFX + server.getName())) { + refreshNetworkChart(); + } + } + }; + } + + private void createClusterListener() { + final GlusterToolbarManager toolbarManager = new GlusterToolbarManager(getSite().getWorkbenchWindow()); + final GlusterServer thisServer = server; + clusterListener = new DefaultClusterListener() { + + @Override + public void serverChanged(GlusterServer server, Event event) { + if (event.getEventType() == EVENT_TYPE.GLUSTER_SERVER_CHANGED && server == thisServer) { + updateServerDetails(); + toolbarManager.updateToolbar(server); + refreshCharts(); + } + } + }; + } + + private void refreshCharts() { + refreshCpuChart(); + refreshMemoryChart(); + refreshNetworkChart(); + } + + private void refreshNetworkChart() { + guiHelper.clearSection(networkUsageSection); + String statsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_CHART_PERIOD); + String networkInterface = preferenceStore.getString(PreferenceConstants.P_DEFAULT_NETWORK_INTERFACE_PFX + server.getName()); + if(networkInterface == null || networkInterface.isEmpty()) { + networkInterface = server.getNetworkInterfaces().get(0).getName(); + } + ServerStats stats = new GlusterServersClient().getNetworkStats(server.getName(), networkInterface, statsPeriod); + chartUtil.refreshChartSection(toolkit, networkUsageSection, stats, statsPeriod, "KiB/s", -1, 5, chartUtil.new NetworkChartPeriodLinkListener(server, statsPeriod, toolkit), 2); + } + + private void refreshMemoryChart() { + guiHelper.clearSection(memoryUsageSection); + String statsPeriod = preferenceStore.getString(PreferenceConstants.P_MEM_CHART_PERIOD); + ServerStats stats = new GlusterServersClient().getMemoryStats(server.getName(), statsPeriod); + chartUtil.refreshChartSection(toolkit, memoryUsageSection, stats, statsPeriod, "%", 100, 4, chartUtil.new MemoryChartPeriodLinkListener(server.getName(), statsPeriod, toolkit), 0); + } + + private void refreshCpuChart() { + guiHelper.clearSection(cpuUsageSection); + String statsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_CHART_PERIOD); + ServerStats stats = new GlusterServersClient().getCpuStats(server.getName(), statsPeriod); + chartUtil.refreshChartSection(toolkit, cpuUsageSection, stats, statsPeriod, "%", 100, 4, + chartUtil.new CpuChartPeriodLinkListener(server.getName(), statsPeriod, toolkit), 2); + } + + private void updateServerDetails() { + // TODO: Update the server details (cpu usage, memory usage) + populateServerSummarySection(server); + + } + + @Override + public void dispose() { + super.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + preferenceStore.removePropertyChangeListener(propertyChangeListener); + } + + private void createAreaChart(Composite section, Calendar timestamps[], Double values[], String unit) { + ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, unit, "HH:mm", 100); + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = CHART_WIDTH; + data.heightHint = CHART_HEIGHT; + chartViewerComposite.setLayoutData(data); + } + + private void extractChartData(ServerStats stats, List timestamps, List data, int dataColumnIndex) { + for(ServerStatsRow row : stats.getRows()) { + Double cpuUsage = row.getUsageData().get(dataColumnIndex); + if(!cpuUsage.isNaN()) { + timestamps.add(new CDateTime(row.getTimestamp() * 1000)); + data.add(cpuUsage); + } + } + } + + private void createAreaChartSection(ServerStats stats, String sectionTitle, int dataColumnIndex, String unit) { + List timestamps = new ArrayList(); + List data = new ArrayList(); + extractChartData(stats, timestamps, data, dataColumnIndex); + + if(timestamps.size() == 0) { + // Log a message saying no CPU stats available + return; + } + + Composite section = guiHelper.createSection(form, toolkit, sectionTitle, null, 1, false); + createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit); + +// Calendar[] timestamps = new Calendar[] { new CDateTime(1000l*1310468100), new CDateTime(1000l*1310468400), new CDateTime(1000l*1310468700), +// new CDateTime(1000l*1310469000), new CDateTime(1000l*1310469300), new CDateTime(1000l*1310469600), new CDateTime(1000l*1310469900), +// new CDateTime(1000l*1310470200), new CDateTime(1000l*1310470500), new CDateTime(1000l*1310470800), new CDateTime(1000l*1310471100), +// new CDateTime(1000l*1310471400), new CDateTime(1000l*1310471700), new CDateTime(1000l*1310472000), new CDateTime(1000l*1310472300), +// new CDateTime(1000l*1310472600), new CDateTime(1000l*1310472900), new CDateTime(1000l*1310473200), new CDateTime(1000l*1310473500), +// new CDateTime(1000l*1310473800) }; +// +// Double[] values = new Double[] { 10d, 11.23d, 17.92d, 18.69d, 78.62d, 89.11d, 92.43d, 89.31d, 57.39d, 18.46d, 10.44d, 16.28d, 13.51d, 17.53d, 12.21, 20d, 21.43d, 16.45d, 14.86d, 15.27d }; +// createLineChart(section, timestamps, values, "%"); + createChartLinks(section, 4); + } + + private void createMemoryUsageSection() { + String memStatsPeriod = preferenceStore.getString(PreferenceConstants.P_MEM_CHART_PERIOD); + memoryUsageSection = guiHelper.createSection(form, toolkit, "Memory Usage", null, 1, false); + + ServerStats stats; + try { + stats = new GlusterServersClient().getMemoryStats(server.getName(), memStatsPeriod); + } catch(Exception e) { + logger.error("Couldn't fetch memory usage statistics for server [" + server.getName() + "]", e); + toolkit.createLabel(memoryUsageSection, "Couldn't fetch memory usage statistics for server [" + server.getName() + "]! Error: [" + e.getMessage() + "]"); + return; + } + + // in case of memory usage, there are four elements in usage data: user, free, cache, buffer and total. we use "user". + ChartUtil chartUtil = ChartUtil.getInstance(); + chartUtil.createAreaChart(toolkit, memoryUsageSection, stats, 0, "%", chartUtil + .getTimestampFormatForPeriod(memStatsPeriod), + chartUtil.new MemoryChartPeriodLinkListener(server.getName(), memStatsPeriod, toolkit), 100, 4); + } + + private void createCPUUsageSection() { + String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_CHART_PERIOD); + cpuUsageSection = guiHelper.createSection(form, toolkit, "CPU Usage", null, 1, false); + + ServerStats stats; + try { + stats = new GlusterServersClient().getCpuStats(server.getName(), cpuStatsPeriod); + } catch(Exception e) { + logger.error("Couldn't fetch CPU usage statistics for server [" + server.getName() + "]", e); + toolkit.createLabel(cpuUsageSection, "Couldn't fetch CPU usage statistics for server [" + server.getName() + "]! Error: [" + e.getMessage() + "]"); + return; + } + + // in case of CPU usage, there are three elements in usage data: user, system and total. we use total. + chartUtil.createAreaChart(toolkit, cpuUsageSection, stats, 2, "%", chartUtil + .getTimestampFormatForPeriod(cpuStatsPeriod), + chartUtil.new CpuChartPeriodLinkListener(server.getName(), cpuStatsPeriod, toolkit), 100, 4); + } + + private void createNetworkUsageSection() { + final String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_CHART_PERIOD); + networkUsageSection = guiHelper.createSection(form, toolkit, "Network Usage", null, 1, false); + + String networkInterface = server.getNetworkInterfaces().get(0).getName(); + ServerStats stats; + try { + stats = new GlusterServersClient().getNetworkStats(server.getName(), networkInterface, networkStatsPeriod); + } catch(Exception e) { + logger.error("Couldn't fetch Network usage statistics for server [" + server.getName() + "] network interface [" + networkInterface + "]", e); + toolkit.createLabel(networkUsageSection, "Couldn't fetch CPU usage statistics for server [" + server.getName() + "]! Error: [" + e.getMessage() + "]"); + return; + } + + // in case of network usage, there are three elements in usage data: received, transmitted and total. we use total. + final ChartUtil chartUtil = ChartUtil.getInstance(); + final ChartPeriodLinkListener networkChartPeriodLinkListener = chartUtil.new NetworkChartPeriodLinkListener(server, networkStatsPeriod, toolkit); + chartUtil.createAreaChart(toolkit, networkUsageSection, stats, 2, "KiB/s", chartUtil + .getTimestampFormatForPeriod(networkStatsPeriod), + networkChartPeriodLinkListener , -1, 5); + } + + private Composite createChartLinks(Composite section, int columnCount) { + GridLayout layout = new org.eclipse.swt.layout.GridLayout(columnCount, false); + layout.marginBottom = 0; + layout.marginTop = 0; + layout.marginLeft = (CHART_WIDTH - (50*columnCount)) / 2; + Composite graphComposite = toolkit.createComposite(section, SWT.NONE); + graphComposite.setLayout(layout); + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = CHART_WIDTH; + graphComposite.setLayoutData(data); + + Label label1 = toolkit.createLabel(graphComposite, "1 day"); + Hyperlink link1 = toolkit.createHyperlink(graphComposite, "1 week", SWT.NONE); + Hyperlink link2 = toolkit.createHyperlink(graphComposite, "1 month", SWT.NONE); + Hyperlink link3 = toolkit.createHyperlink(graphComposite, "1 year", SWT.NONE); + + return graphComposite; + } + + private void createSections(Composite parent) { + String serverName = server.getName(); + form = guiHelper.setupForm(parent, toolkit, "Server Summary [" + serverName + "]"); + createServerSummarySection(server, toolkit, form); + + if (server.getStatus() == SERVER_STATUS.ONLINE) { + try { + new ProgressMonitorDialog(getSite().getShell()).run(false, false, new IRunnableWithProgress() { + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("Creating Server Summary View", 4); + monitor.setTaskName("Creating Memory Usage Section"); + createMemoryUsageSection(); + monitor.worked(1); + + monitor.setTaskName("Creating Network Usage Section"); + createNetworkUsageSection(); + monitor.worked(1); + + monitor.setTaskName("Creating CPU Usage Section"); + createCPUUsageSection(); + monitor.worked(1); + + monitor.setTaskName("Creating Network Interfaces Section"); + createNetworkInterfacesSection(server, toolkit, form); + monitor.worked(1); + monitor.done(); + } + }); + } catch (Exception e) { + String errMsg = "Exception while creating the Gluster Server Summary View : [" + e.getMessage() + "]"; + logger.error(errMsg, e); + MessageDialog.openError(getSite().getShell(), ConsoleConstants.CONSOLE_TITLE, errMsg); + } + } + + parent.layout(); // IMP: lays out the form properly + } + + private void createServerSummarySection(GlusterServer server, FormToolkit toolkit, final ScrolledForm form) { + serverSummarySection = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); + // toolkit.createLabel(section, "Preferred Network: ", SWT.NONE); + // toolkit.createLabel(section, server.getPreferredNetworkInterface().getName(), SWT.NONE); + + if (server.isOnline()) { + toolkit.createLabel(serverSummarySection, "Number of CPUs: ", SWT.NONE); + numCpus = toolkit.createLabel(serverSummarySection, "" + server.getNumOfCPUs(), SWT.NONE); + + toolkit.createLabel(serverSummarySection, "% CPU Usage (avg): ", SWT.NONE); + cpuGauge = new CoolGauge(serverSummarySection, guiHelper.getImage(IImageKeys.GAUGE_SMALL)); + + toolkit.createLabel(serverSummarySection, "Memory Usage: ", SWT.NONE); + memoryUsageBar = new ProgressBar(serverSummarySection, SWT.SMOOTH); + + // toolkit.createLabel(section, "Memory Usage: ", SWT.NONE); + // final CoolProgressBar bar = new CoolProgressBar(section,SWT.HORIZONTAL, + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_LEFT), + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_FILLED), + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_EMPTY), + // guiHelper.getImage(IImageKeys.PROGRESS_BAR_RIGHT)); + // bar.updateProgress(server.getMemoryInUse() / server.getTotalMemory()); + + // toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + // toolkit.createLabel(section, online ? "" + server.getTotalDiskSpace() : "NA", SWT.NONE); + // + // toolkit.createLabel(section, "Disk Space in Use (GB): ", SWT.NONE); + // toolkit.createLabel(section, online ? "" + server.getDiskSpaceInUse() : "NA", SWT.NONE); + + toolkit.createLabel(serverSummarySection, "Disk Usage: ", SWT.NONE); + diskUsageBar = new ProgressBar(serverSummarySection, SWT.SMOOTH); + } + + toolkit.createLabel(serverSummarySection, "Status: ", SWT.NONE); + lblServerStatus = new CLabel(serverSummarySection, SWT.NONE); + populateServerSummarySection(server); + } + + private void populateServerSummarySection(GlusterServer server) { + if (server.isOnline()) { + numCpus.setText("" + server.getNumOfCPUs()); + numCpus.redraw(); + + cpuGauge.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); + cpuGauge.setGaugeNeedleColour(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + cpuGauge.setGaugeNeedleWidth(2); + cpuGauge.setGaugeNeedlePivot(new Point(66, 65)); + + cpuGauge.setPoints(getPnts()); + cpuGauge.setLevel(server.getCpuUsage() / 100); + cpuGauge.setToolTipText(server.getCpuUsage() + "%"); + cpuGauge.redraw(); + + memoryUsageBar.setMinimum(0); + memoryUsageBar.setMaximum((int) Math.round(server.getTotalMemory())); + memoryUsageBar.setSelection((int) Math.round(server.getMemoryInUse())); + memoryUsageBar.setToolTipText("Total: " + NumberUtil.formatNumber((server.getTotalMemory() / 1024)) + + "GB, In Use: " + NumberUtil.formatNumber((server.getMemoryInUse() / 1024)) + "GB"); + + diskUsageBar.setMinimum(0); + diskUsageBar.setMaximum((int) Math.round(server.getTotalDiskSpace())); + diskUsageBar.setSelection((int) Math.round(server.getDiskSpaceInUse())); + diskUsageBar.setToolTipText("Total: " + NumberUtil.formatNumber((server.getTotalDiskSpace() / 1024)) + + "GB, In Use: " + NumberUtil.formatNumber((server.getDiskSpaceInUse() / 1024)) + "GB"); + + } + lblServerStatus.setText(server.getStatusStr()); + lblServerStatus.setImage(server.getStatus() == GlusterServer.SERVER_STATUS.ONLINE ? guiHelper + .getImage(IImageKeys.STATUS_ONLINE_16x16) : guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16)); + toolkit.adapt(lblServerStatus, true, true); + + serverSummarySection.layout(); + form.reflow(true); + } + + private List getPnts() { + final List pnts = new ArrayList(); + pnts.add(new Point(47, 98)); + pnts.add(new Point(34, 84)); + pnts.add(new Point(29, 65)); + pnts.add(new Point(33, 48)); + pnts.add(new Point(48, 33)); + pnts.add(new Point(66, 28)); + pnts.add(new Point(83, 32)); + pnts.add(new Point(98, 47)); + pnts.add(new Point(103, 65)); + pnts.add(new Point(98, 83)); + pnts.add(new Point(84, 98)); + return pnts; + } + + private Composite createNetworkInterfacesSection(GlusterServer server, FormToolkit toolkit, ScrolledForm form) { + final Composite section = guiHelper.createSection(form, toolkit, "Network Interfaces", null, 1, false); + createNetworkInterfacesTableViewer(createTableViewerComposite(section), server); + // Hyperlink changePreferredNetworkLink = toolkit.createHyperlink(section, "Change Preferred Network", + // SWT.NONE); + // changePreferredNetworkLink.addHyperlinkListener(new HyperlinkAdapter() { + // + // @Override + // public void linkActivated(HyperlinkEvent e) { + // new MessageDialog( + // section.getShell(), + // "Gluster Storage Platform", + // guiHelper.getImage(IImageKeys.SERVER), + // "This will show additional controls to help user choose a new network interface. TO BE IMPLEMENTED.", + // MessageDialog.INFORMATION, new String[] { "OK" }, 0).open(); + // } + // }); + return section; + } + + private TableViewer createNetworkInterfacesTableViewer(final Composite parent, GlusterServer server) { + TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + // TableViewer tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new NetworkInterfaceTableLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + + setupNetworkInterfaceTable(parent, tableViewer.getTable()); + tableViewer.setInput(server.getNetworkInterfaces().toArray()); + + return tableViewer; + } + + private void setupNetworkInterfaceTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, + NETWORK_INTERFACE_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.INTERFACE, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.MODEL, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.SPEED, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.IP_ADDRESS, SWT.CENTER, 100); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.NETMASK, SWT.CENTER, 70); + setColumnProperties(table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES.GATEWAY, SWT.CENTER, 70); + } + + private Composite createTableViewerComposite(Composite parent) { + Composite tableViewerComposite = new Composite(parent, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false); + tableLayoutData.widthHint = 400; + tableLayoutData.minimumWidth = 400; + // tableLayoutData.grabExcessHorizontalSpace = true; + tableViewerComposite.setLayoutData(tableLayoutData); + return tableViewerComposite; + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, NETWORK_INTERFACE_TABLE_COLUMN_INDICES columnIndex, int alignment, + int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + @Override + public void setFocus() { + form.setFocus(); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersSummaryView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersSummaryView.java new file mode 100644 index 00000000..c7435166 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersSummaryView.java @@ -0,0 +1,290 @@ +/** + * GlusterServersSummaryView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.ChartViewerComposite; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.Alert.ALERT_TYPES; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; + + +/** + * + */ +public class GlusterServersSummaryView extends ViewPart { + public static final String ID = GlusterServersSummaryView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private ClusterListener clusterListener; + private EntityGroup servers; + private Composite alertsSection; + private Composite serversAvailabilitySection; + private Composite tasksSection; + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @SuppressWarnings("unchecked") + @Override + public void createPartControl(Composite parent) { + if (servers == null) { + servers = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); + } + setPartName("Summary"); + createSections(parent); + + clusterListener = new DefaultClusterListener() { + @Override + public void serverAdded(GlusterServer server) { + super.serverAdded(server); + updateServerAvailabilitySection(); + } + + @Override + public void serverRemoved(GlusterServer server) { + super.serverRemoved(server); + updateServerAvailabilitySection(); + } + + @Override + public void serverChanged(GlusterServer server, Event event) { + super.serverChanged(server, event); + updateServerAvailabilitySection(); + } + + private void updateServerAvailabilitySection() { + guiHelper.clearSection(serversAvailabilitySection); + populateAvailabilitySection(); + } + + @Override + public void alertsGenerated() { + super.alertsGenerated(); + guiHelper.clearSection(alertsSection); + populateAlertSection(); + } + + @Override + public void taskAdded(TaskInfo taskInfo) { + super.taskAdded(taskInfo); + updateTasksSection(); + } + + @Override + public void taskRemoved(TaskInfo taskInfo) { + super.taskRemoved(taskInfo); + updateTasksSection(); + } + + @Override + public void taskUpdated(TaskInfo taskInfo) { + super.taskUpdated(taskInfo); + updateTasksSection(); + } + + private void updateTasksSection() { + guiHelper.clearSection(tasksSection); + populateTasksSection(); + } + }; + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + } + + @Override + public void dispose() { + super.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } + + /** + * @param parent + */ + private void createSections(Composite parent) { + form = guiHelper.setupForm(parent, toolkit, "Servers - Summary"); + + createSummarySection(); + createRunningTasksSection(); + createAlertsSection(); + + parent.layout(); // IMP: lays out the form properly + } + + private void createSummarySection() { + serversAvailabilitySection = guiHelper.createSection(form, toolkit, "Availability", null, 2, false); + populateAvailabilitySection(); + } + + private void populateAvailabilitySection() { + if (servers.getEntities().size() == 0) { + toolkit.createLabel(serversAvailabilitySection, "This section will be populated after at least" + + CoreConstants.NEWLINE + "one server is added to the storage cloud."); + return; + } + + Double[] values = new Double[] { Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.ONLINE)), + Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.OFFLINE)) }; + createStatusChart(serversAvailabilitySection, values); + } + + private int getServerCountByStatus(EntityGroup servers, SERVER_STATUS status) { + int count = 0; + for (GlusterServer server : servers.getEntities()) { + if (server.getStatus() == status) { + count++; + } + } + return count; + } + + private void createStatusChart(Composite section, Double[] values) { + String[] categories = new String[] { "Online", "Offline" }; + ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, categories, values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = 300; + data.heightHint = 150; + chartViewerComposite.setLayoutData(data); + } + + private void createAlertsSection() { + alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false); + populateAlertSection(); + } + + private void populateAlertSection() { + List alerts = GlusterDataModelManager.getInstance().getModel().getCluster().getAlerts(); + + for (Alert alert : alerts) { + if (alert.getType() == ALERT_TYPES.DISK_USAGE_ALERT || alert.getType() != ALERT_TYPES.OFFLINE_SERVERS_ALERT + || alert.getType() == ALERT_TYPES.MEMORY_USAGE_ALERT + || alert.getType() == ALERT_TYPES.CPU_USAGE_ALERT) { + addAlertLabel(alertsSection, alert); + } + } + alertsSection.pack(true); + form.reflow(true); + } + + private void addAlertLabel(Composite section, Alert alert) { + CLabel lblAlert = new CLabel(section, SWT.FLAT); + Image alertImage = null; + switch (alert.getType()) { + case DISK_USAGE_ALERT: + alertImage = guiHelper.getImage(IImageKeys.LOW_DISK_SPACE_22x22); + break; + case OFFLINE_SERVERS_ALERT: + alertImage = guiHelper.getImage(IImageKeys.SERVER_OFFLINE_22x22); + break; + case MEMORY_USAGE_ALERT: + alertImage = guiHelper.getImage(IImageKeys.MEMORY_USAGE_ALERT_22x22); + break; + case CPU_USAGE_ALERT: + alertImage = guiHelper.getImage(IImageKeys.SERVER_WARNING_22x22); + break; + } + lblAlert.setImage(alertImage); + lblAlert.setText(alert.getMessage()); + lblAlert.redraw(); + } + + private void createRunningTasksSection() { + tasksSection = guiHelper.createSection(form, toolkit, CoreConstants.RUNNING_TASKS, null, 1, false); + populateTasksSection(); + } + + private void populateTasksSection() { + for (TaskInfo taskInfo : GlusterDataModelManager.getInstance().getModel().getCluster().getTaskInfoList()) { + // Exclude volume related tasks + if (taskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS + && taskInfo.getType() != TASK_TYPE.VOLUME_REBALANCE + && taskInfo.getType() != TASK_TYPE.BRICK_MIGRATE) { + addTaskLabel(tasksSection, taskInfo); + } + } + tasksSection.layout(); + form.reflow(true); + } + + private void addTaskLabel(Composite section, TaskInfo taskInfo) { + CLabel lblTask = new CLabel(section, SWT.NONE); + Image taskImage = null; + switch(taskInfo.getType()) { + case DISK_FORMAT: + taskImage = guiHelper.getImage(IImageKeys.DISK_INITIALIZING_22x22); + break; + case BRICK_MIGRATE: + taskImage = guiHelper.getImage(IImageKeys.BRICK_MIGRATE_22x22); + break; + case VOLUME_REBALANCE: + taskImage = guiHelper.getImage(IImageKeys.VOLUME_REBALANCE_22x22); + break; + } + + String description = taskInfo.getDescription(); + switch (taskInfo.getStatus().getCode()) { + case Status.STATUS_CODE_PAUSE: + description += " (paused)"; + break; + case Status.STATUS_CODE_COMMIT_PENDING: + description += " (commit pending)"; + break; + case Status.STATUS_CODE_FAILURE: + description += " (failed)"; + break; + } + + lblTask.setText(description); + lblTask.setImage(taskImage); + lblTask.redraw(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + form.setFocus(); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersView.java new file mode 100644 index 00000000..fe4e3bb3 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterServersView.java @@ -0,0 +1,78 @@ +/** + * GlusterServersView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.GlusterServersPage; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterServer; + + +/** + * @author root + * + */ +public class GlusterServersView extends ViewPart implements IDoubleClickListener { + public static final String ID = GlusterServersView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private EntityGroup servers; + private GlusterServersPage page; + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @SuppressWarnings("unchecked") + @Override + public void createPartControl(Composite parent) { + if (servers == null) { + servers = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); + } + + page = new GlusterServersPage(getSite(), parent, SWT.NONE, servers); + page.addDoubleClickListener(this); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + page.setFocus(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) + */ + @Override + public void doubleClick(DoubleClickEvent event) { + NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); + if (clusterView != null) { + clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterViewsManager.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterViewsManager.java new file mode 100644 index 00000000..a4d0a98f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/GlusterViewsManager.java @@ -0,0 +1,130 @@ +/** + * GlusterViewsManager.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.gluster.storage.management.console.ConsoleConstants; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Volume; + + +/** + * @see ViewsManager + */ +public class GlusterViewsManager implements ViewsManager { + private IWorkbenchPage page; + + public GlusterViewsManager(IWorkbenchPage page) { + this.page = page; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.ViewsManager#updateViews(org.gluster.storage.management.core.model.Entity) + */ + @SuppressWarnings("rawtypes") + @Override + public void updateViews(Entity entity) { + closeAllViews(); + + try { + if (entity instanceof EntityGroup) { + showViewsForEntityGroup((EntityGroup)entity); + } else if (entity.getClass() == Server.class) { + showViewsForDiscoveredServer((Server)entity); + } else if (entity.getClass() == GlusterServer.class) { + showViewsForGlusterServer((GlusterServer)entity); + } else if (entity instanceof Volume) { + showViewsForVolume((Volume)entity); + } else if (entity instanceof Cluster) { + showViewsForCluster((Cluster)entity); + } + } catch (PartInitException e) { + e.printStackTrace(); + } + } + + private void closeAllViews() { + IViewReference[] viewReferences = page.getViewReferences(); + for (final IViewReference viewReference : viewReferences) { + if (!(viewReference.getId().equals(NavigationView.ID) || viewReference.getId().equals( + ConsoleConstants.TERMINAL_VIEW_ID))) { + page.hideView(viewReference); + } + } + } + + private void showViewsForCluster(Cluster cluster) throws PartInitException { + page.showView(ClusterSummaryView.ID); + page.showView(TasksView.ID, null, IWorkbenchPage.VIEW_CREATE); + } + + private void showViewsForVolume(Volume volume) throws PartInitException { + page.showView(VolumeSummaryView.ID); + page.showView(VolumeBricksView.ID, null, IWorkbenchPage.VIEW_CREATE); + page.showView(VolumeOptionsView.ID, null, IWorkbenchPage.VIEW_CREATE); + page.showView(VolumeLogsView.ID, null, IWorkbenchPage.VIEW_CREATE); + } + + private void showViewsForGlusterServer(GlusterServer server) throws PartInitException { + page.showView(GlusterServerSummaryView.ID); + if (server.getStatus() == GlusterServer.SERVER_STATUS.ONLINE) { + page.showView(GlusterServerDisksView.ID, null, IWorkbenchPage.VIEW_CREATE); + //page.showView(GlusterServerLogsView.ID, null, IWorkbenchPage.VIEW_CREATE); + } + } + + private void showViewsForDiscoveredServer(Server server) throws PartInitException { + page.showView(DiscoveredServerView.ID); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private void showViewsForEntityGroup(EntityGroup entityGroup) throws PartInitException { + Class entityType = entityGroup.getEntityType(); + if (entityType == Server.class) { + showViewForServers(entityGroup); + } else if (entityType == Volume.class) { + showViewsForVolumes(entityGroup); + } else if (entityType == GlusterServer.class) { + showViewsForGlusterServers(entityGroup); + } + } + + private void showViewsForGlusterServers(EntityGroup server) throws PartInitException { + page.showView(GlusterServersSummaryView.ID); + page.showView(GlusterServersView.ID, null, IWorkbenchPage.VIEW_CREATE); + page.showView(DisksView.ID, null, IWorkbenchPage.VIEW_CREATE); + } + + private void showViewsForVolumes(EntityGroup volumes) throws PartInitException { + page.showView(VolumesSummaryView.ID); + page.showView(VolumesView.ID, null, IWorkbenchPage.VIEW_CREATE); + } + + private void showViewForServers(EntityGroup servers) throws PartInitException { + page.showView(DiscoveredServersView.ID); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java new file mode 100644 index 00000000..45f7119f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationTreeLabelDecorator.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views; + +import org.eclipse.jface.viewers.IDecoration; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ILightweightLabelDecorator; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.gluster.storage.management.console.Application; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Volume; + + +public class NavigationTreeLabelDecorator implements ILightweightLabelDecorator { + + @Override + public void addListener(ILabelProviderListener listener) { + } + + @Override + public void dispose() { + } + + @Override + public boolean isLabelProperty(Object element, String property) { + return false; + } + + @Override + public void removeListener(ILabelProviderListener listener) { + } + + @SuppressWarnings("rawtypes") + @Override + public void decorate(Object element, IDecoration decoration) { + if (element instanceof Volume) { + Volume volume = (Volume) element; + if (volume.getStatus() == Volume.VOLUME_STATUS.OFFLINE) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_OFFLINE_8x8)); + } else { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_ONLINE_8x8)); + } + } + + if (element instanceof GlusterServer) { + GlusterServer server = (GlusterServer) element; + if (server.getStatus() == GlusterServer.SERVER_STATUS.OFFLINE) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_OFFLINE_8x8)); + } else { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_ONLINE_8x8)); + } + } + + if (element instanceof Server) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_STAR_8x8)); + } + + if(element instanceof EntityGroup && ((EntityGroup)element).getEntityType() == Server.class) { + decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, + IImageKeys.OVERLAY_STAR_8x8)); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationView.java new file mode 100644 index 00000000..0c565a24 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/NavigationView.java @@ -0,0 +1,161 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.model.BaseWorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.toolbar.GlusterToolbarManager; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterDataModel; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Volume; + + +public class NavigationView extends ViewPart implements ISelectionListener { + public static final String ID = NavigationView.class.getName(); + private TreeViewer treeViewer; + private IAdapterFactory adapterFactory = new ClusterAdapterFactory(); + private GlusterToolbarManager toolbarManager; + private Entity entity; + private GlusterViewsManager viewsManager; + private DefaultClusterListener clusterListener; + + @Override + public void createPartControl(Composite parent) { + createNavigationTree(parent); + + // Create the views and toolbar managers + toolbarManager = new GlusterToolbarManager(getSite().getWorkbenchWindow()); + viewsManager = new GlusterViewsManager(getSite().getPage()); + + // listen to selection events to update views/toolbar accordingly + getSite().getPage().addSelectionListener(this); + } + + private void createNavigationTree(Composite parent) { + GlusterDataModel model = GlusterDataModelManager.getInstance().getModel(); + + Platform.getAdapterManager().registerAdapters(adapterFactory, Entity.class); + treeViewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()); + treeViewer.setContentProvider(new BaseWorkbenchContentProvider()); + treeViewer.setInput(model); + treeViewer.expandAll(); + // select the first element by default + treeViewer.setSelection(new StructuredSelection(model.getChildren().get(0))); + + setupContextMenu(); + + // register as selection provider so that other views can listen to any selection events on the tree + getSite().setSelectionProvider(treeViewer); + + clusterListener = new DefaultClusterListener() { + public void modelChanged() { + treeViewer.refresh(true); + } + + @Override + public void volumeChanged(Volume volume, Event event) { + super.volumeChanged(volume, event); + treeViewer.update(volume, null); + if (volume == entity) { + // this makes sure that the toolbar buttons get updated according to new status + selectEntity(volume); + } + } + + @Override + public void volumeDeleted(Volume volume) { + super.volumeDeleted(volume); + if(volume == entity) { + // volume selected was deleted. select the root element in the tree. + selectEntity(GlusterDataModelManager.getInstance().getModel().getCluster()); + } + } + + @Override + public void serverRemoved(GlusterServer server) { + super.serverRemoved(server); + if(server == entity) { + // server selected was removed. select the root element in the tree. + selectEntity(GlusterDataModelManager.getInstance().getModel().getCluster()); + } + }; + }; + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + } + + private void setupContextMenu() { + MenuManager menuManager = new MenuManager("&Gluster", "gluster.context.menu"); + Menu contextMenu = menuManager.createContextMenu(treeViewer.getControl()); + treeViewer.getTree().setMenu(contextMenu); + getSite().registerContextMenu(menuManager, treeViewer); + } + + public void selectEntity(Entity entity) { + treeViewer.setSelection(new StructuredSelection(entity)); + treeViewer.reveal(entity); + setFocus(); // this ensures that the "selection changed" event gets fired + } + + @Override + public void setFocus() { + treeViewer.getControl().setFocus(); + } + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (part instanceof NavigationView && selection instanceof TreeSelection) { + Entity selectedEntity = (Entity) ((TreeSelection) selection).getFirstElement(); + + if (selectedEntity != null && selectedEntity != entity) { + entity = selectedEntity; + + // update views and toolbar buttons visibility based on selected entity + viewsManager.updateViews(entity); + toolbarManager.updateToolbar(entity); + + // Opening of other views may cause navigation tree to lose focus; get it back. + setFocus(); + } + } + } + + @Override + public void dispose() { + super.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/TasksView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/TasksView.java new file mode 100644 index 00000000..9732a460 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/TasksView.java @@ -0,0 +1,39 @@ +package org.gluster.storage.management.console.views; + +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.views.pages.TasksPage; +import org.gluster.storage.management.core.model.TaskInfo; + + +public class TasksView extends ViewPart { + + public static final String ID = TasksView.class.getName(); + private TasksPage page; + + + public TasksView() { + // TODO Auto-generated constructor stub + } + + @Override + public void createPartControl(Composite parent) { + page = new TasksPage(getSite(), parent, SWT.NONE, getAllTasks()); + page.layout(); // IMP: lays out the form properly + } + + + private List getAllTasks() { + return GlusterDataModelManager.getInstance().getModel().getCluster().getTaskInfoList(); + } + + @Override + public void setFocus() { + page.setFocus(); + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ViewsManager.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ViewsManager.java new file mode 100644 index 00000000..76581416 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/ViewsManager.java @@ -0,0 +1,38 @@ +/** + * ViewsManager.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.gluster.storage.management.core.model.Entity; + +/** + * Whenever the current selection/action demands opening different set of views, the views manager is used to open + * appropriate views. + */ +public interface ViewsManager { + /** + * Updates the views for given entity. This typically means that user is working with the given entity, and hence + * the views related to that entity should be made visible, and other un-related views should be hidden. + * + * @param entity + * The entity for which views are to be updated + */ + public void updateViews(Entity entity); +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeBricksView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeBricksView.java new file mode 100644 index 00000000..33f7c970 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeBricksView.java @@ -0,0 +1,39 @@ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.BricksPage; +import org.gluster.storage.management.core.model.Volume; + + +public class VolumeBricksView extends ViewPart { + public static final String ID = VolumeBricksView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private BricksPage page; + private Volume volume; + + @Override + public void createPartControl(Composite parent) { + if (volume == null) { + volume = guiHelper.getSelectedEntity(getSite(), Volume.class); + } + + createPage(parent); + } + + /** + * @param parent + */ + private void createPage(Composite parent) { + page = new BricksPage(parent, SWT.NONE, getSite(), volume.getBricks()); + parent.layout(); // IMP: lays out the form properly + } + + @Override + public void setFocus() { + page.setFocus(); + } +} + diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeLogsView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeLogsView.java new file mode 100644 index 00000000..eeffe6d5 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeLogsView.java @@ -0,0 +1,58 @@ +package org.gluster.storage.management.console.views; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.VolumeLogsPage; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeLogMessage; +import org.gluster.storage.management.core.utils.DateUtil; + + +public class VolumeLogsView extends ViewPart implements IDoubleClickListener { + VolumeLogsPage logsPage; + public static final String ID = VolumeLogsView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private Volume volume; + + @Override + public void createPartControl(Composite parent) { + if (volume == null) { + volume = guiHelper.getSelectedEntity(getSite(), Volume.class); + } + + createPage(parent); + } + + private void createPage(Composite parent) { + logsPage = new VolumeLogsPage(parent, SWT.NONE, volume); + logsPage.addDoubleClickListener(this); + + parent.layout(); // IMP: lays out the form properly + } + + @Override + public void setFocus() { + logsPage.setFocus(); + } + + @Override + public void doubleClick(DoubleClickEvent event) { + VolumeLogMessage volumeLogMessage = (VolumeLogMessage) ((StructuredSelection) event.getSelection()) + .getFirstElement(); + String message = DateUtil.formatDate(volumeLogMessage.getTimestamp()) + " " + + DateUtil.formatTime(volumeLogMessage.getTimestamp()) + " [" + volumeLogMessage.getSeverity() + "]" + + CoreConstants.NEWLINE + CoreConstants.NEWLINE + volumeLogMessage.getMessage(); + + new MessageDialog(getSite().getShell(), "Log message from " + volumeLogMessage.getBrick(), null, message, + MessageDialog.NONE, new String[] { "Close" }, 0).open(); + + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeOptionsView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeOptionsView.java new file mode 100644 index 00000000..144f1441 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeOptionsView.java @@ -0,0 +1,36 @@ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.VolumeOptionsPage; +import org.gluster.storage.management.core.model.Volume; + + +public class VolumeOptionsView extends ViewPart { + public static final String ID = VolumeOptionsView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private VolumeOptionsPage page; + private Volume volume; + + @Override + public void createPartControl(Composite parent) { + if (volume == null) { + volume = guiHelper.getSelectedEntity(getSite(), Volume.class); + } + + createPage(parent); + } + + private void createPage(Composite parent) { + page = new VolumeOptionsPage(parent, SWT.NONE, volume); + parent.layout(); // IMP: lays out the form properly + } + + @Override + public void setFocus() { + page.setFocus(); + } +} + diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeSummaryView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeSummaryView.java new file mode 100644 index 00000000..2257c56f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeSummaryView.java @@ -0,0 +1,859 @@ +package org.gluster.storage.management.console.views; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.FormText; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.toolbar.GlusterToolbarManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.utils.NumberUtil; +import org.gluster.storage.management.core.utils.StringUtil; +import org.gluster.storage.management.core.utils.ValidationUtil; + + +public class VolumeSummaryView extends ViewPart { + public static final String ID = VolumeSummaryView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private Volume volume; + private Label volumeType; + private CLabel lblStatusValue; + private DefaultClusterListener volumeChangedListener; + private Hyperlink changeLink; + private Hyperlink cifsChangeLink; + private Text accessControlText; + private Text cifsUsersText; + private ControlDecoration errDecoration; + private ControlDecoration errCifsDecoration; + private Composite parent; + private static final String COURIER_FONT = "Courier"; + private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + private Cluster cluster = modelManager.getModel().getCluster(); + private Button nfsCheckBox; + private FormText glusterNfsMountText; + private String nfsMountInfo; + private Label nfsLabel; + private String nfs; + + private Label numberOfBricks; + private Label totalDiskSpace; + private Composite alertsSection; + private Button cifsCheckbox; + private Label cifsLabel; + private Composite cifsUpdateLinkComposite; + + @Override + public void createPartControl(Composite parent) { + if (volume == null) { + volume = guiHelper.getSelectedEntity(getSite(), Volume.class); + } + + this.parent = parent; + setPartName("Summary"); + createSections(); + + final GlusterToolbarManager toolbarManager = new GlusterToolbarManager(getSite().getWorkbenchWindow()); + // Refresh the navigation tree whenever there is a change to the data model + volumeChangedListener = new DefaultClusterListener() { + @Override + public void volumeChanged(Volume volume, Event event) { + updateVolumeStatusLabel(); + populateAccessControlText(); + changeNFSStatus(volume.isNfsEnabled()); + updateBrickChanges(volume); + toolbarManager.updateToolbar(volume); + cifsCheckbox.setSelection(volume.isCifsEnable()); + populateCifsUsersText(); + renderVolumeTypeField(); + } + + @Override + public void alertsGenerated() { + super.alertsGenerated(); + guiHelper.clearSection(alertsSection); + populateAlertSection(); + alertsSection.layout(); + } + }; + modelManager.addClusterListener(volumeChangedListener); + } + + @Override + public void dispose() { + super.dispose(); + modelManager.removeClusterListener(volumeChangedListener); + } + + private void createSections() { + form = guiHelper.setupForm(parent, toolkit, "Volume Properties [" + volume.getName() + "]"); + + createVolumePropertiesSection(); + createVolumeMountingInfoSection(); + createVolumeAlertsSection(); + + parent.layout(); // IMP: lays out the form properly + } + + private void createVolumeAlertsSection() { + alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false); + populateAlertSection(); + } + + private void populateAlertSection() { + List alerts = cluster.getAlerts(); + + for (int i = 0; i < alerts.size(); i++) { + if (alerts.get(i).getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT + && alerts.get(i).getReference().split(":")[0].trim().equals(volume.getName())) { + addAlertLabel(alertsSection, alerts.get(i)); + } + } + } + + private void addAlertLabel(Composite section, Alert alert) { + CLabel lblAlert = new CLabel(section, SWT.NONE); + lblAlert.setImage(guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22)); + lblAlert.setText(alert.getMessage()); + lblAlert.redraw(); + } + + private FormText setFormTextStyle(FormText formText, String fontName, int size, int style) { + Font font = new Font(Display.getCurrent(), new FontData(fontName, size, style)); + formText.setFont(font); + return formText; + } + + private void createVolumeMountingInfoSection() { + String glusterFs = "Gluster:"; + nfs = "NFS:"; + String onlineServers = getOnlineServers(10); // Limited to 10 servers + String firstOnlineServer = onlineServers.split(",")[0].trim(); + String glusterFsMountInfo = "mount -t glusterfs " + firstOnlineServer + ":/" + volume.getName() + + " "; + nfsMountInfo = "mount -t nfs " + firstOnlineServer + ":/" + volume.getName() + " "; + // TODO: if more than 10 servers... + String info = "Server can be any server name in the storage cloud eg. <" + onlineServers + ">"; + + Composite section = guiHelper.createSection(form, toolkit, "Mounting Information", null, 3, false); + + toolkit.createLabel(section, glusterFs, SWT.NORMAL); + FormText glusterfsMountText = setFormTextStyle(toolkit.createFormText(section, true), COURIER_FONT, 10, + SWT.NONE); + glusterfsMountText.setText(glusterFsMountInfo, false, false); + glusterfsMountText.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, + 2, 0)); // Label spanned two column + + nfsLabel = toolkit.createLabel(section, nfs, SWT.NONE); + GridData data = new GridData(); + data.horizontalAlignment = SWT.FILL; + nfsLabel.setLayoutData(data); + + glusterNfsMountText = setFormTextStyle(toolkit.createFormText(section, true), COURIER_FONT, 10, SWT.NONE); + glusterNfsMountText.setText(nfsMountInfo, false, false); + glusterNfsMountText.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, + false, 2, 0)); + + changeNFSStatus(nfsCheckBox.getSelection()); + + toolkit.createLabel(section, ""); + Label infoLabel = toolkit.createLabel(section, info, SWT.NONE); + infoLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false, 2, 0)); + + // TODO: implement a logic to identify the corresponding glusterfs client download link + String message = "You can download GlusterFS client from"; + String glusterFSDownloadlinkText = "here."; + final String glusterFSDownloadlink = "http://download.gluster.com/pub/gluster/glusterfs/"; + + toolkit.createLabel(section, ""); + toolkit.createLabel(section, message); + Hyperlink link = toolkit.createHyperlink(section, glusterFSDownloadlinkText, SWT.NORMAL); + link.addHyperlinkListener(new HyperlinkAdapter() { + public void linkActivated(HyperlinkEvent e) { + try { + System.out.println(e.getLabel() + " [" + e.getHref() + "]"); + PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser() + .openURL(new URL(glusterFSDownloadlink)); + } catch (PartInitException e1) { + e1.printStackTrace(); + } catch (MalformedURLException e1) { + e1.printStackTrace(); + } + } + }); + } + + private String getOnlineServers(int maxServers) { + List OnlineServers = new ArrayList(); + for (GlusterServer server : cluster.getServers()) { + if (server.getStatus() == SERVER_STATUS.ONLINE) { + OnlineServers.add(server.getName()); + if (OnlineServers.size() >= maxServers) { + break; + } + } + } + return StringUtil.collectionToString(OnlineServers, ", ") + ((OnlineServers.size() > maxServers) ? "..." : ""); + } + + /** + * + */ + private void createVolumePropertiesSection() { + Composite section = guiHelper.createSection(form, toolkit, "Properties", null, 3, false); + + createVolumeTypeField(section); + + VOLUME_TYPE volumeType = volume.getVolumeType(); + if (volumeType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { + createReplicaCountField(section); + } + + if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + createStripeCountField(section); + } + + createNumOfBricksField(section); + createDiskSpaceField(section); + // createTransportTypeField(section); + createNASProtocolField(section); + createCifsField(section); + createAccessControlField(section); + createStatusField(section); + } + + private GridData createDefaultLayoutData() { + GridData layoutData = new GridData(); + layoutData.minimumWidth = 300; + layoutData.widthHint = 300; + return layoutData; + } + + private void createCifsField(Composite section) { + cifsLabel = toolkit.createLabel(section, "CIFS: ", SWT.NONE); + cifsUsersText = toolkit.createText(section, volume.getAccessControlList(), SWT.BORDER); + populateCifsUsersText(); + addKeyListenerForCifsUser(); + + cifsUpdateLinkComposite = toolkit.createComposite(section, SWT.NONE); + cifsUpdateLinkComposite.setLayout(new FillLayout()); + cifsUpdateLinkComposite.setVisible(volume.isCifsEnable()); + + createChangeLinkForCifs(cifsUpdateLinkComposite); + renderCifsUsers(cifsCheckbox.getSelection()); + errCifsDecoration = guiHelper.createErrorDecoration(cifsUsersText); + errCifsDecoration.hide(); + } + + private void createAccessControlField(Composite section) { + toolkit.createLabel(section, "Allow Access From: ", SWT.NONE); + accessControlText = toolkit.createText(section, volume.getAccessControlList(), SWT.BORDER); + + populateAccessControlText(); + addKeyListenerForAccessControl(); + accessControlText.setLayoutData(createDefaultLayoutData()); + accessControlText.setEnabled(false); + createChangeLinkForAccessControl(section); + + // error decoration used while validating the access control text + errDecoration = guiHelper.createErrorDecoration(accessControlText); + errDecoration.hide(); + createAccessControlInfoLabel(section); // info text + } + + private void createAccessControlInfoLabel(Composite section) { + toolkit.createLabel(section, "", SWT.NONE); + Label accessControlInfoLabel = toolkit.createLabel(section, "(Comma separated list of IP addresses/hostnames)"); + GridData data = new GridData(SWT.LEFT, SWT.CENTER, true, false); + data.horizontalSpan = 2; + accessControlInfoLabel.setLayoutData(data); + } + + private void createChangeLinkForAccessControl(Composite section) { + changeLink = toolkit.createHyperlink(section, "change", SWT.NONE); + changeLink.addHyperlinkListener(new HyperlinkAdapter() { + + private void finishEdit() { + saveAccessControlList(); + } + + private void startEdit() { + accessControlText.setEnabled(true); + accessControlText.setFocus(); + accessControlText.selectAll(); + changeLink.setText("update"); + } + + @Override + public void linkActivated(HyperlinkEvent e) { + if (accessControlText.isEnabled()) { + // we were already in edit mode. + finishEdit(); + } else { + // Get in to edit mode + startEdit(); + } + } + }); + } + + private void saveAccessControlList() { + final String newACL = accessControlText.getText(); + + guiHelper.setStatusMessage("Setting access control list to [" + newACL + "]..."); + parent.update(); + + if (newACL.equals(volume.getAccessControlList())) { + accessControlText.setEnabled(false); + changeLink.setText("change"); + } else if (ValidationUtil.isValidAccessControl(newACL)) { + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override + public void run() { + try { + new VolumesClient().setVolumeOption(volume.getName(), Volume.OPTION_AUTH_ALLOW, newACL); + accessControlText.setEnabled(false); + changeLink.setText("change"); + + modelManager.setAccessControlList(volume, newACL); + } catch (Exception e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control", e.getMessage()); + } + } + }); + } else { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control", "Invalid IP / Host name "); + } + guiHelper.clearStatusMessage(); + parent.update(); + } + + private void createChangeLinkForCifs(Composite section) { + cifsChangeLink = toolkit.createHyperlink(section, "change", SWT.NONE); + cifsChangeLink.addHyperlinkListener(new HyperlinkAdapter() { + + private void finishEdit() { + saveCifsConfiguration(); + } + + private void startEdit() { + if (cifsCheckbox.getSelection()) { + enableCifsUsersControls(true); + cifsUsersText.selectAll(); + } + } + + @Override + public void linkActivated(HyperlinkEvent e) { + if (cifsUsersText.isEnabled()) { + // we were already in edit mode. + finishEdit(); + } else { + // Get in to edit mode + startEdit(); + } + } + }); + } + + private void saveCifsConfiguration() { + guiHelper.setStatusMessage("Setting Cifs Configuration..."); + parent.update(); + + // To check if no changes in the users list + if (!isvalidCifsUser()) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", + "Please enter cifs users name"); + enableCifsUsersControls(true); + validateCifsUsers(); + // } else if (cifsUsers.equals(configuredUsers)) { // Nothing to do. + // enableCifsUsersControls(false); + } else { + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override + public void run() { + VolumesClient vc = new VolumesClient(); + Volume newVolume = new Volume(); + Integer userAction = 1; + String cifsUsers = cifsUsersText.getText().trim(); + List servers = GlusterDataModelManager.getInstance().getOfflineServers(); + // One or more servers are offline, Show warning if cifs is enabled + if (servers != null && servers.size() > 0) { + userAction = new MessageDialog(parent.getShell(), "CIFS configuration", GUIHelper + .getInstance().getImage(IImageKeys.VOLUME_16x16), + "Performing CIFS updates when one or more servers are offline can trigger " + + "inconsistent behavior for CIFS accesses in the cluster." + + CoreConstants.NEWLINE + CoreConstants.NEWLINE + + "Are you sure you want to continue?", MessageDialog.QUESTION, new String[] { + "No", "Yes" }, -1).open(); + } + + // If no cifs users and removing cifs config, nothing to do + if (!(!cifsCheckbox.getSelection() && volume.getCifsUsers().toString().equals("[]") && (cifsUsers + .isEmpty() || cifsUsers.equals(""))) && userAction == 1) { + try { + vc.setCifsConfig(volume.getName(), cifsCheckbox.getSelection(), cifsUsers); + enableCifsUsersControls(false); + newVolume = vc.getVolume(volume.getName()); + modelManager.volumeChanged(volume, newVolume); + showCifsUsersControls(volume.isCifsEnable()); + } catch (Exception e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Cifs Configuration", + e.getMessage()); + cifsCheckbox.setSelection(volume.isCifsEnable()); + enableCifsUsersControls(cifsCheckbox.getSelection()); + populateCifsUsersText(); + } + } else { + newVolume = vc.getVolume(volume.getName()); + modelManager.volumeChanged(volume, newVolume); + showCifsUsersControls(volume.isCifsEnable()); + } + } + }); + } + guiHelper.clearStatusMessage(); + parent.update(); + } + + private void saveNFSOption() { + guiHelper.setStatusMessage("Setting NFS option..."); + parent.update(); + + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + @Override + public void run() { + try { + boolean enableNfs = nfsCheckBox.getSelection(); + new VolumesClient().setVolumeOption(volume.getName(), Volume.OPTION_NFS_DISABLE, + (enableNfs) ? GlusterConstants.OFF : GlusterConstants.ON); + modelManager.setNfsEnabled(volume, enableNfs); + } catch (Exception e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "NFS Option", e.getMessage()); + } + } + }); + guiHelper.clearStatusMessage(); + parent.update(); + } + + private void addKeyListenerForAccessControl() { + accessControlText.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent key) { + switch (key.keyCode) { + case SWT.ESC: + // Reset to default + populateAccessControlText(); + changeLink.setText("change"); + accessControlText.setEnabled(false); + break; + case 13: + // User has pressed enter. Save the new value + saveAccessControlList(); + break; + } + + validateAccessControlList(); + } + }); + } + + private void populateAccessControlText() { + String accessControlList = volume.getAccessControlList(); + if (accessControlList == null) { + // if not set, show default value + accessControlList = modelManager.getVolumeOptionDefaultValue(Volume.OPTION_AUTH_ALLOW); + } + accessControlText.setText(accessControlList); + } + + private void addKeyListenerForCifsUser() { + cifsUsersText.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent key) { + switch (key.keyCode) { + case SWT.ESC: + // Reset to default + populateCifsUsersText(); + enableCifsUsersControls(false); + if (cifsUsersText.getText().trim().length() == 0) { // Disable CIFS as well + cifsCheckbox.setSelection(false); + } + form.reflow(true); + break; + case 13: + // User has pressed enter. Save the new value + saveCifsConfiguration(); + break; + } + validateCifsUsers(); + } + }); + } + + private void populateCifsUsersText() { + List userList = volume.getCifsUsers(); + if (volume.isCifsEnable() && userList != null) { + cifsUsersText.setText(StringUtil.collectionToString(userList, ",")); + } else { + cifsUsersText.setText(""); + } + } + + private void createNASProtocolField(final Composite section) { + toolkit.createLabel(section, "Access Protocols: ", SWT.NONE); + + Composite nasProtocolsComposite = toolkit.createComposite(section); + nasProtocolsComposite.setLayout(new FillLayout()); + + createCheckbox(nasProtocolsComposite, "Gluster", true, false); + + nfsCheckBox = createCheckbox(nasProtocolsComposite, "NFS", volume.isNfsEnabled(), true); + + nfsCheckBox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (!nfsCheckBox.getSelection()) { + Integer userAction = new MessageDialog(parent.getShell(), "NFS Re-export", GUIHelper.getInstance() + .getImage(IImageKeys.VOLUME_16x16), + "Are you sure you want to stop the NFS Re-export for volume [" + volume.getName() + "]?", + MessageDialog.QUESTION, new String[] { "No", "Yes" }, -1).open(); + if (userAction <= 0) { // user select cancel or pressed escape key + nfsCheckBox.setSelection(true); + return; + } + } + saveNFSOption(); + } + }); + + // CIFS checkbox + cifsCheckbox = createCheckbox(nasProtocolsComposite, "CIFS", volume.isCifsEnable(), true); + createCifsCheckboxListner(cifsCheckbox); + + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createCifsCheckboxListner(final Button cifsCheckbox) { + cifsCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (cifsCheckbox.getSelection()) { + // need to enable cifs + // TODO: Open the text box (empty and enabled), + // the hyperlink next to the textbox should have label "update" + // when user clicks on that hyperlink, + // saveCifsConfiguration should be called + // Also, if user presses the "ESC" key, + // return to the previous state of checkbox and hide the textbox + hyperlink + showCifsUsersControls(true); + enableCifsUsersControls(true); + // saveCifsConfiguration(); + } else { + // need to disable cifs + // TODO: hide the textbox and the link AFTER disabling cifs + if ((volume.getCifsUsers() == null || volume.getCifsUsers().toString().equals("[]")) + && cifsUsersText.getText().trim().equals("")) { + showCifsUsersControls(false); + enableCifsUsersControls(false); + } else { + + Integer userAction = new MessageDialog(parent.getShell(), "CIFS Re-export", GUIHelper + .getInstance().getImage(IImageKeys.VOLUME_16x16), + "Are you sure you want to stop the CIFS re-export for volume [" + volume.getName() + + "]?", MessageDialog.QUESTION, new String[] { "No", "Yes" }, -1).open(); + if (userAction <= 0) { // user select cancel or pressed escape key + cifsCheckbox.setSelection(true); // back to previous state. + } else { + showCifsUsersControls(false); + enableCifsUsersControls(false); + saveCifsConfiguration(); + } + } + } + populateCifsUsersText(); + form.reflow(true); + } + }); + } + + private void renderCifsUsers(Boolean cifsSelection) { + if (cifsSelection) { + enableCifsUsersControls(false); + showCifsUsersControls(true); + } else { + showCifsUsersControls(false); + } + } + + private void showCifsUsersControls(Boolean visible) { + if (visible) { + GridData data = new GridData(); + data.heightHint = 20; + data.widthHint = 100; + cifsLabel.setLayoutData(data); + + GridData data1 = new GridData(); + data1.heightHint = 20; + data1.widthHint = 300; + + cifsUsersText.setLayoutData(data1); + + GridData data2 = new GridData(); + data2.heightHint = 25; + data2.widthHint = 75; + cifsUpdateLinkComposite.setLayoutData(data2); + } else { + GridData data = new GridData(); + data.heightHint = 0; + + cifsLabel.setLayoutData(data); + cifsUsersText.setLayoutData(data); + cifsUpdateLinkComposite.setLayoutData(data); + } + + cifsLabel.setVisible(visible); + cifsUsersText.setVisible(visible); + cifsUpdateLinkComposite.setVisible(visible); + form.reflow(true); + } + + private void enableCifsUsersControls(Boolean enable) { + cifsUsersText.setEnabled(enable); + cifsChangeLink.setText((enable) ? "update" : "change"); + if (enable) { + cifsUsersText.setFocus(); + validateCifsUsers(); + } else { + if (errCifsDecoration != null) { + errCifsDecoration.hide(); + } + } + } + + private Button createCheckbox(Composite parent, String label, boolean checked, boolean enabled) { + final Button checkBox = toolkit.createButton(parent, label, SWT.CHECK); + checkBox.setSelection(checked); + checkBox.setEnabled(enabled); + return checkBox; + } + + private void changeNFSStatus(Boolean isNFSExported) { + glusterNfsMountText.setVisible(isNFSExported); + nfsLabel.setVisible(isNFSExported); + nfsCheckBox.setSelection(isNFSExported); + } + + private void updateBrickChanges(Volume volume) { + numberOfBricks.setText("" + volume.getNumOfBricks()); + totalDiskSpace.setText("" + NumberUtil.formatNumber(getTotalDiskSpace() / 1024)); + } + + private double getDiskSize(String serverName, String deviceName) { + double diskSize = 0; + GlusterServer server = cluster.getServer(serverName); + if (server.getStatus() == SERVER_STATUS.ONLINE) { + for (Disk disk : server.getDisks()) { + if (disk.getName().equals(deviceName)) { + diskSize = disk.getSpace(); + break; + } + + if (disk.hasPartitions()) { + for (Partition partition : disk.getPartitions()) { + if (partition.getName().equals(deviceName)) { + diskSize = partition.getSpace(); + break; + } + } + } + } + } + return diskSize; + } + + private double getTotalDiskSpace() { + List diskSizes = getVolumeDiskSizes(); + VOLUME_TYPE volumeType = volume.getVolumeType(); + double diskSize = 0d; + if (volumeType == VOLUME_TYPE.DISTRIBUTE || volumeType == VOLUME_TYPE.STRIPE + || volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + for (Double size : diskSizes) { + diskSize += size; + } + } else { // Replicate or distributed replicate + int replicaCount = volume.getReplicaCount(); + if (replicaCount == 0) { + replicaCount = Volume.DEFAULT_REPLICA_COUNT; + } + int startIndex = 0; + for (int i = 0; i < (diskSizes.size() / replicaCount); i++) { + startIndex = i * replicaCount; + diskSize += Collections.min(diskSizes.subList(startIndex, startIndex + replicaCount)); + } + } + return diskSize; + } + + private List getVolumeDiskSizes() { + List diskSizes = new ArrayList(); + Device device; + for (Brick brick : volume.getBricks()) { + device = modelManager.getDeviceForBrickDir(brick); + diskSizes.add( (device == null) ? 0d : getDiskSize(brick.getServerName(), device.getName()) ); + } + return diskSizes; + } + + + + private void createDiskSpaceField(Composite section) { + Label diskSpaceLabel = toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + diskSpaceLabel.setToolTipText("boldnormal"); + totalDiskSpace = toolkit.createLabel(section, + "" + NumberUtil.formatNumber(getTotalDiskSpace() / 1024), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createStatusField(Composite section) { + toolkit.createLabel(section, "Status: ", SWT.NONE); + + lblStatusValue = new CLabel(section, SWT.NONE); + updateVolumeStatusLabel(); + + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void updateVolumeStatusLabel() { + lblStatusValue.setText(volume.getStatusStr()); + lblStatusValue.setImage((volume.getStatus() == Volume.VOLUME_STATUS.ONLINE) ? guiHelper + .getImage(IImageKeys.STATUS_ONLINE_16x16) : guiHelper.getImage(IImageKeys.STATUS_OFFLINE_16x16)); + GridData data = new GridData(); + data.horizontalAlignment = SWT.FILL; + lblStatusValue.setLayoutData(data); + lblStatusValue.redraw(); + } + + private void createTransportTypeField(Composite section) { + toolkit.createLabel(section, "Transport Type: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getTransportTypeStr(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createNumOfBricksField(Composite section) { + toolkit.createLabel(section, "Number of Bricks: ", SWT.NONE); + numberOfBricks = toolkit.createLabel(section, "" + volume.getNumOfBricks(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createStripeCountField(Composite section) { + toolkit.createLabel(section, "Stripe Count: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getStripeCount(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createReplicaCountField(Composite section) { + toolkit.createLabel(section, "Replica Count: ", SWT.NONE); + toolkit.createLabel(section, "" + volume.getReplicaCount(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); // dummy + } + + private void createVolumeTypeField(Composite section) { + toolkit.createLabel(section, "Volume Type: ", SWT.NONE); + volumeType = toolkit.createLabel(section, volume.getVolumeTypeStr(), SWT.NONE); + toolkit.createLabel(section, "", SWT.NONE); + } + + private void renderVolumeTypeField() { + volumeType.setText(volume.getVolumeTypeStr()); + } + + @Override + public void setFocus() { + form.setFocus(); + } + + private void validateAccessControlList() { + errDecoration.hide(); + + if (accessControlText.getText().length() == 0) { + errDecoration.setDescriptionText("Access control list cannot be empty!"); + errDecoration.show(); + return; + } + + if (!ValidationUtil.isValidAccessControl(accessControlText.getText())) { + errDecoration.setDescriptionText("Invalid IP address/Host name [" + + ValidationUtil.getInvalidIpOrHostname(accessControlText.getText()) + + "]. Please enter a valid value!"); + errDecoration.show(); + } + } + + private void validateCifsUsers() { + errCifsDecoration.hide(); + if (cifsCheckbox.getSelection()) { + String cifsUserList = cifsUsersText.getText().trim(); + if (cifsUserList.length() == 0) { + errCifsDecoration.setDescriptionText("Please enter cifs user name"); + errCifsDecoration.show(); + } + } + } + + private boolean isvalidCifsUser() { + if (cifsCheckbox.getSelection()) { + String cifsUserList = cifsUsersText.getText().trim(); + return (cifsUserList.length() != 0); + } + validateCifsUsers(); + return true; + } + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeView.java new file mode 100644 index 00000000..27df48c1 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumeView.java @@ -0,0 +1,90 @@ +/** + * DiscoveredServerView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.utils.NumberUtil; + + +/** + * @author root + * + */ +public class VolumeView extends ViewPart { + public static final String ID = VolumeView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private Server server; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createPartControl(Composite parent) { + if (server == null) { + server = guiHelper.getSelectedEntity(getSite(), Server.class); + } + createSections(parent, server, toolkit); + } + + private void createServerSummarySection(Server server, FormToolkit toolkit, final ScrolledForm form) { + Composite section = guiHelper.createSection(form, toolkit, "Summary", null, 2, false); + + toolkit.createLabel(section, "Number of CPUs: ", SWT.NONE); + toolkit.createLabel(section, "" + server.getNumOfCPUs(), SWT.NONE); + + toolkit.createLabel(section, "Total Memory (GB): ", SWT.NONE); + toolkit.createLabel(section, "" + server.getTotalMemory(), SWT.NONE); + + toolkit.createLabel(section, "Total Disk Space (GB): ", SWT.NONE); + toolkit.createLabel(section, "" + NumberUtil.formatNumber(server.getTotalDiskSpace()), SWT.NONE); + } + + private void createSections(Composite parent, Server server, FormToolkit toolkit) { + String serverName = server.getName(); + form = guiHelper.setupForm(parent, toolkit, "Discovered Server Summary [" + serverName + "]"); + createServerSummarySection(server, toolkit, form); + + parent.layout(); // IMP: lays out the form properly + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + if (form != null) { + form.setFocus(); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesSummaryView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesSummaryView.java new file mode 100644 index 00000000..549353e8 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesSummaryView.java @@ -0,0 +1,301 @@ +/** + * VolumesSummaryView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ScrolledForm; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IImageKeys; +import org.gluster.storage.management.console.utils.ChartViewerComposite; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; + + +/** + * + */ +public class VolumesSummaryView extends ViewPart { + public static final String ID = VolumesSummaryView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private ScrolledForm form; + private EntityGroup volumes; + private Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster(); + private ClusterListener clusterListener; + + private static final String ALERTS = "Alerts"; + private static final String VOLUMES_SUMMARY = "Volumes - Summary"; + private static final String AVAILABILITY = "Availability"; + private Composite alertsSection; + private Composite tasksSection; + private Composite summarySection; + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets + * .Composite) + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void createPartControl(Composite parent) { + if (volumes == null) { + Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); + if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Volume.class) { + volumes = (EntityGroup) selectedObj; + } + } + + setPartName("Summary"); + createSections(parent); + + clusterListener = new DefaultClusterListener() { + @Override + public void volumeCreated(Volume volume) { + super.volumeCreated(volume); + updateSummarySection(); + } + + @Override + public void volumeDeleted(Volume volume) { + super.volumeDeleted(volume); + updateSummarySection(); + } + + @Override + public void volumeChanged(Volume volume, Event event) { + super.volumeChanged(volume, event); + updateSummarySection(); + } + + private void updateAlertSection() { + guiHelper.clearSection(alertsSection); + populateAlertSection(); + } + + private void updateSummarySection() { + guiHelper.clearSection(summarySection); + populateSummarySection(); + summarySection.layout(); + form.reflow(true); + } + + @Override + public void alertsGenerated() { + super.alertsGenerated(); + guiHelper.clearSection(alertsSection); + populateAlertSection(); + } + + @Override + public void alertRemoved(Alert alert) { + super.alertRemoved(alert); + updateAlertSection(); + } + + @Override + public void alertCreated(Alert alert) { + super.alertCreated(alert); + updateAlertSection(); + } + + @Override + public void taskAdded(TaskInfo taskInfo) { + super.taskAdded(taskInfo); + updateTasksSection(); + } + + @Override + public void taskRemoved(TaskInfo taskInfo) { + super.taskRemoved(taskInfo); + updateTasksSection(); + } + + @Override + public void taskUpdated(TaskInfo taskInfo) { + super.taskUpdated(taskInfo); + updateTasksSection(); + } + + private void updateTasksSection() { + guiHelper.clearSection(tasksSection); + populateTasks(); + } + }; + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + } + + @Override + public void dispose() { + super.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } + + private void createSections(Composite parent) { + form = guiHelper.setupForm(parent, toolkit, VOLUMES_SUMMARY); + createSummarySection(); + createTasksSection(); + createAlertsSection(); + + parent.layout(); // IMP: lays out the form properly + } + + private void createAlertsSection() { + alertsSection = guiHelper.createSection(form, toolkit, ALERTS, null, 1, false); + populateAlertSection(); + } + + private void populateAlertSection() { + for (Alert alert : cluster.getAlerts()) { + if (alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT + || alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_ALERT) { + addAlertLabel(alertsSection, alert); + } + } + alertsSection.pack(true); + form.reflow(true); + } + + private void addAlertLabel(Composite section, Alert alert) { + CLabel lblAlert = new CLabel(section, SWT.NONE); + + Image alertImage = null; + switch (alert.getType()) { + case OFFLINE_VOLUME_BRICKS_ALERT: + alertImage = guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22); + break; + case OFFLINE_VOLUME_ALERT: + alertImage = guiHelper.getImage(IImageKeys.VOLUME_OFFLINE_22x22); + break; + } + lblAlert.setImage(alertImage); + lblAlert.setText(alert.getMessage()); + lblAlert.redraw(); + } + + private void createTasksSection() { + tasksSection = guiHelper.createSection(form, toolkit, CoreConstants.RUNNING_TASKS, null, 1, false); + populateTasks(); + } + + private void populateTasks() { + for (TaskInfo taskInfo : cluster.getTaskInfoList()) { + if ((taskInfo.getType() == TASK_TYPE.BRICK_MIGRATE || taskInfo.getType() == TASK_TYPE.VOLUME_REBALANCE) + && taskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS) + addTaskLabel(tasksSection, taskInfo); + } + tasksSection.pack(true); + form.reflow(true); + } + + private void addTaskLabel(Composite section, TaskInfo taskInfo) { + // Task related to Volumes context + if (taskInfo.getStatus().isPercentageSupported()) { + // TODO Progress bar or link to progress view + } + + CLabel lblTask = new CLabel(section, SWT.NONE); + String description = taskInfo.getDescription(); + switch (taskInfo.getStatus().getCode()) { + case Status.STATUS_CODE_PAUSE: + description += " (paused)"; + break; + case Status.STATUS_CODE_COMMIT_PENDING: + description += " (commit pending)"; + break; + case Status.STATUS_CODE_FAILURE: + description += " (failed)"; + break; + } + lblTask.setText(description); + lblTask.setImage((taskInfo.getType() == TASK_TYPE.BRICK_MIGRATE) ? guiHelper + .getImage(IImageKeys.BRICK_MIGRATE_32x32) : guiHelper.getImage(IImageKeys.VOLUME_REBALANCE_32x32)); + lblTask.redraw(); + } + + private void createSummarySection() { + summarySection = guiHelper.createSection(form, toolkit, AVAILABILITY, null, 2, false); + populateSummarySection(); + } + + private void populateSummarySection() { + if(volumes.getEntities().size() == 0) { + toolkit.createLabel(summarySection, + "This section will be populated after at least" + CoreConstants.NEWLINE +"one volume is created the storage cloud."); + return; + } + + Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.ONLINE)), + Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.OFFLINE)) }; + createStatusChart(toolkit, summarySection, values); + } + + private int getVolumeCountByStatus(EntityGroup volumes, VOLUME_STATUS status) { + int count = 0; + for (Volume volume : volumes.getEntities()) { + if (volume.getStatus() == status) { + count++; + } + } + return count; + } + + private void createStatusChart(FormToolkit toolkit, Composite section, Double[] values) { + String[] categories = new String[] { "Online", "Offline" }; + ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, categories, values); + + GridData data = new GridData(SWT.FILL, SWT.FILL, false, false); + data.widthHint = 300; + data.heightHint = 150; + chartViewerComposite.setLayoutData(data); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + if (form != null) { + form.setFocus(); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesView.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesView.java new file mode 100644 index 00000000..41ccba1d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/VolumesView.java @@ -0,0 +1,80 @@ +/** + * DiscoveredServersView.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views; + +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.views.pages.VolumesPage; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Volume; + + +/** + * + */ +public class VolumesView extends ViewPart implements IDoubleClickListener { + public static final String ID = VolumesView.class.getName(); + private static final GUIHelper guiHelper = GUIHelper.getInstance(); + private EntityGroup volumes; + private VolumesPage page; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void createPartControl(Composite parent) { + if (volumes == null) { + Object selectedObj = guiHelper.getSelectedEntity(getSite(), EntityGroup.class); + if (selectedObj != null && ((EntityGroup) selectedObj).getEntityType() == Volume.class) { + volumes = (EntityGroup)selectedObj; + } + } + + page = new VolumesPage(parent, getSite(), volumes); + page.addDoubleClickListener(this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + page.setFocus(); + } + + @Override + public void doubleClick(DoubleClickEvent event) { + NavigationView clusterView = (NavigationView) guiHelper.getView(NavigationView.ID); + if (clusterView != null) { + clusterView.selectEntity((Entity) ((StructuredSelection) event.getSelection()).getFirstElement()); + } + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractDisksPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractDisksPage.java new file mode 100644 index 00000000..6d2959d2 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractDisksPage.java @@ -0,0 +1,335 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.TreeEditor; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.ImageHyperlink; +import org.gluster.storage.management.client.GlusterServersClient; +import org.gluster.storage.management.client.TasksClient; +import org.gluster.storage.management.console.Application; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.IEntityListener; +import org.gluster.storage.management.console.dialogs.InitDiskDialog; +import org.gluster.storage.management.console.utils.GlusterLogger; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.model.Event.EVENT_TYPE; + + +public abstract class AbstractDisksPage extends AbstractTableTreeViewerPage implements IEntityListener { + protected List disks; + protected static final GlusterLogger logger = GlusterLogger.getInstance(); + + /** + * @return Index of the "status" column in the table. Return -1 if status column is not displayed + */ + protected abstract int getStatusColumnIndex(); + + public AbstractDisksPage(final Composite parent, int style, IWorkbenchSite site, List disks) { + super(site, parent, style, false, true, disks); + this.disks = disks; + + // creates hyperlinks for "uninitialized" disks + setupStatusCellEditor(); + // Listen for disk status change events + Application.getApplication().addEntityListener(this); + } + + protected ClusterListener createClusterListener() { + return new DefaultClusterListener() { + @Override + public void serverChanged(GlusterServer server, Event event) { + super.serverChanged(server, event); + EVENT_TYPE eventType = event.getEventType(); + switch (eventType) { + case DEVICES_REMOVED: + case DEVICES_ADDED: + case DEVICES_CHANGED: + case GLUSTER_SERVER_CHANGED: + treeViewer.refresh(true); + default: + break; + } + } + }; + } + + private void createInitializeLink(final TreeItem item, final int rowNum, final Device uninitializedDevice) { + final Tree tree = treeViewer.getTree(); + final TreeEditor editor = new TreeEditor(tree); + editor.grabHorizontal = true; + editor.horizontalAlignment = SWT.RIGHT; + + tree.addPaintListener(new PaintListener() { + private TreeItem myItem = item; + private int myRowNum = rowNum; + private ImageHyperlink myLink = null; + private TreeEditor myEditor = null; + + private void createLinkFor(Device uninitializedDevice, TreeItem item1, int rowNum1) { + myItem = item1; + myRowNum = rowNum1; + + myEditor = new TreeEditor(tree); + myEditor.grabHorizontal = true; + myEditor.horizontalAlignment = SWT.RIGHT; + + myLink = toolkit.createImageHyperlink(tree, SWT.NONE); + // link.setImage(guiHelper.getImage(IImageKeys.DISK_UNINITIALIZED)); + myLink.setText("Initialize"); + myLink.addHyperlinkListener(new StatusLinkListener(myLink, myEditor, treeViewer, uninitializedDevice)); + + myEditor.setEditor(myLink, item1, getStatusColumnIndex()); + + myItem.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + myLink.dispose(); + myEditor.dispose(); + } + }); + } + + @Override + public void paintControl(PaintEvent e) { + int itemCount = tree.getItemCount(); + + // Find the table item corresponding to our disk + + Device device = null; + int rowNum1 = -1; + TreeItem item1 = null; + + mainloop: + for (int i = 0; i < itemCount; i++) { + item1 = tree.getItem(i); + + device = (Device) item1.getData(); + if (device != null && device == uninitializedDevice) { + // this is an uninitialized "disk" + rowNum1 = i; + break; + } + + int partitionCount = item1.getItemCount(); + for(int j = 0; j < partitionCount; j++) { + TreeItem partitionItem = item1.getItem(j); + // check each partition + Device partition = (Device)partitionItem.getData(); + if(partition != null && partition == uninitializedDevice) { + // this is an uninitialized "partition" + rowNum1 = i + j; + item1 = partitionItem; + device = partition; + // found the uninitialized device. break out. + break mainloop; + } + } + } + + if (rowNum1 == -1) { + // item disposed and disk not visible. nothing to do. + return; + } + + if (myEditor == null || myItem.isDisposed()) { + // item visible, and + // either editor never created, OR + // old item disposed. create the link for it + createLinkFor(device, item1, rowNum1); + } + + if (rowNum1 != myRowNum) { + // disk visible, but at a different row num. re-create the link + myLink.dispose(); + myEditor.dispose(); + createLinkFor(device, item1, rowNum1); + } + + myEditor.layout(); // IMPORTANT. Without this, the link location goes for a toss on maximize + restore + } + }); + } + + private void setupStatusCellEditor() { + final TreeViewer viewer = treeViewer; + final Tree tree = viewer.getTree(); + int rowNum = 0; + for (int i = 0; i < tree.getItemCount(); i++, rowNum++) { + final TreeItem item = tree.getItem(i); + if (item.isDisposed() || item.getData() == null) { + continue; + } + final Disk disk = (Disk) item.getData(); + if (disk.isUninitialized()) { + createInitializeLink(item, rowNum, disk); + } + + if (disk.hasPartitions()) { + for(int j = 0; j < disk.getPartitions().size(); j++, rowNum++) { + TreeItem partitionItem = item.getItem(j); + // check each partition + Device partition = (Device)partitionItem.getData(); + if (partition.isUninitialized()) { + createInitializeLink(partitionItem, rowNum, partition); + } + } + } + } + } + + private final class StatusLinkListener extends HyperlinkAdapter { + private final Device device; + private final TreeEditor myEditor; + private final ImageHyperlink myLink; + private final TreeViewer viewer; + + private StatusLinkListener(ImageHyperlink link, TreeEditor editor, TreeViewer viewer, Device device) { + this.device = device; + this.viewer = viewer; + this.myEditor = editor; + this.myLink = link; + } + + private void updateStatus(final DEVICE_STATUS status, final boolean disposeEditor) { + if (disposeEditor) { + myLink.dispose(); + myEditor.dispose(); + } + device.setStatus(status); + viewer.update(device, new String[] { "status" }); + Application.getApplication().entityChanged(device, new String[] { "status" }); + } + + @Override + public void linkActivated(HyperlinkEvent e) { + GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); + + // If the same task is already running return + String reference = device.getServerName() + ":" + device.getName(); + TaskInfo existingTaskInfo = modelManager.getTaskByReference(reference); + if (existingTaskInfo != null && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_SUCCESS + && existingTaskInfo.getStatus().getCode() != Status.STATUS_CODE_FAILURE) { + MessageDialog.openInformation(getShell(), "Initialize disk - Error", "Initializing disk [" + reference + + "] is already in progress! Try later."); + return; + } + + // To collect the available fsType + GlusterServersClient serversClient = new GlusterServersClient(); + List fsTypes = new ArrayList(); + try { + fsTypes = serversClient.getFSTypes(device.getServerName()); + } catch (GlusterRuntimeException e1) { + MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); + return; + } + + InitDiskDialog formatDialog = new InitDiskDialog(getShell(), device.getName(), fsTypes); + int userAction = formatDialog.open(); + if (userAction == Window.CANCEL) { + // formatDialog.cancelPressed(); + return; + } + + try { + + URI uri = serversClient.initializeDisk(device.getServerName(), device.getName(), formatDialog.getFSType(), formatDialog.getMountPoint()); + + TasksClient taskClient = new TasksClient(); + TaskInfo taskInfo = taskClient.getTaskInfo(uri); + + if (taskInfo != null) { + modelManager.addTask(taskInfo); + } + + if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_RUNNING) { + updateStatus(DEVICE_STATUS.INITIALIZING, true); + } else if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { + // If format completed (instantly), get the server details and update the server in the model + GlusterServer oldServer = modelManager.getModel().getCluster().getServer(device.getServerName()); + GlusterServer newServer = serversClient.getGlusterServer(device.getServerName()); + modelManager.glusterServerChanged(oldServer, newServer); + // updateStatus(DEVICE_STATUS.INITIALIZED, true); + // GlusterDataModelManager.getInstance().updateDeviceStatus(device.getServerName(), device.getName(), + // DEVICE_STATUS.INITIALIZED); + } else { + MessageDialog.openError(getShell(), "Initialize disk - Error", taskInfo.getStatus().getMessage()); + } + guiHelper.showTaskView(); + } catch (Exception e1) { + logger.error("Exception while initialize disk", e1); + MessageDialog.openError(getShell(), "Initialize disk - Error", e1.getMessage()); + } + } + } + + @Override + public void entityChanged(final Entity entity, final String[] paremeters) { + if (!(entity instanceof Device)) { + return; + } + final Device device = (Device) entity; + + Display.getDefault().syncExec(new Runnable() { + public void run() { + treeViewer.update(device, paremeters); + + if (device.isUninitialized()) { + Tree tree = treeViewer.getTree(); + + for (int rowNum = 0; rowNum < tree.getItemCount(); rowNum++) { + TreeItem item = tree.getItem(rowNum); + if (item.getData() == device) { + createInitializeLink(item, rowNum, device); + } + } + } + } + }); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java new file mode 100644 index 00000000..55535637 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableTreeViewerPage.java @@ -0,0 +1,191 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.layout.TreeColumnLayout; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.TreeColumn; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.Disk; + + +public abstract class AbstractTableTreeViewerPage extends Composite implements ISelectionListener { + + protected final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + protected TreeViewer treeViewer; + protected GUIHelper guiHelper = GUIHelper.getInstance(); + protected Composite parent; + protected IWorkbenchSite site; + private ClusterListener clusterListener; + + private Text filterText; + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(1, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private Composite createTreeViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + GridData layoutData = new GridData(); + layoutData.horizontalSpan=5; + layoutData.grabExcessHorizontalSpace = true; + layoutData.horizontalAlignment = SWT.FILL; + layoutData.verticalAlignment = SWT.FILL; + layoutData.grabExcessVerticalSpace = true; + tableViewerComposite.setLayoutData(layoutData); + + return tableViewerComposite; + } + + + public AbstractTableTreeViewerPage(IWorkbenchSite site, final Composite parent, int style, boolean useChechboxes, + boolean multiSelection, List allDisks) { + super(parent, style); + + setupPageLayout(); + //new FormToolkit(Display.getCurrent()).createButton(this, "test1", SWT.PUSH); + + this.parent = parent; + this.site = site; + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + parent.setLayoutData(data); + + filterText = guiHelper.createFilterText(toolkit, this); + + Composite tableViewerComposite = createTreeViewerComposite(); + createTreeViewer(allDisks, tableViewerComposite); + parent.layout(); // Important - this actually paints the table + + createListeners(parent); + } + + private void createListeners(final Composite parent) { + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + + clusterListener = createClusterListener(); + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + + addDisposeListener(new DisposeListener() { + + @Override + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } + }); + } + + protected abstract ClusterListener createClusterListener(); + protected abstract IBaseLabelProvider getLabelProvider(); + protected abstract IContentProvider getContentProvider(); + + private void createTreeViewer(List allDisks, Composite tableViewerComposite) { + treeViewer = new TreeViewer(tableViewerComposite); + treeViewer.getTree().setHeaderVisible(true); + treeViewer.getTree().setLinesVisible(true); + + TreeColumnLayout ad = new TreeColumnLayout(); + tableViewerComposite.setLayout(ad); + + TreeColumn column = new TreeColumn(treeViewer.getTree(),SWT.NONE); + column.setWidth(100); + column.setText("Disk"); + ad.setColumnData(column, new ColumnWeightData(50, 100)); + + column = new TreeColumn(treeViewer.getTree(),SWT.NONE); + column.setWidth(100); + column.setText("Partition"); + ad.setColumnData(column,new ColumnWeightData(50, 100)); + + column = new TreeColumn(treeViewer.getTree(),SWT.NONE); + column.setWidth(100); + column.setText("Free Space (GB)"); + ad.setColumnData(column, new ColumnWeightData(50, 100)); + + column = new TreeColumn(treeViewer.getTree(),SWT.NONE); + column.setWidth(100); + column.setText("Total Space (GB)"); + ad.setColumnData(column,new ColumnWeightData(50, 100)); + + column = new TreeColumn(treeViewer.getTree(),SWT.NONE); + column.setWidth(100); + column.setText("Status"); + ad.setColumnData(column,new ColumnWeightData(50, 100)); + + treeViewer.setLabelProvider(getLabelProvider()); + treeViewer.setContentProvider(getContentProvider()); + treeViewer.setInput(allDisks); + + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(treeViewer, filterText, false); + + treeViewer.expandAll(); + } + + + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java new file mode 100644 index 00000000..88468eb3 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/AbstractTableViewerPage.java @@ -0,0 +1,263 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchSite; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Hyperlink; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.console.utils.TableViewerComparator; +import org.gluster.storage.management.core.model.ClusterListener; + + +public abstract class AbstractTableViewerPage extends Composite implements ISelectionListener { + + private boolean useCheckboxes; + private boolean multiSelection; + + protected final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + protected TableViewer tableViewer; + protected GUIHelper guiHelper = GUIHelper.getInstance(); + protected Composite parent; + protected IWorkbenchSite site; + + private Hyperlink linkAll, linkNone; + private ClusterListener clusterListener; + + public AbstractTableViewerPage(IWorkbenchSite site, final Composite parent, int style, boolean useChechboxes, boolean multiSelection, Object model) { + super(parent, style); + this.parent = parent; + this.site = site; + + this.useCheckboxes = useChechboxes; + this.multiSelection = multiSelection; + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setupPageLayout(); + + createCheckboxSelectionLinks(); + + Text filterText = guiHelper.createFilterText(toolkit, this); + + setupTableViewer(site, filterText); + tableViewer.setInput(model); + // register as selection provider so that other views can listen to any selection events on the tree + site.setSelectionProvider(tableViewer); + site.getPage().addSelectionListener(this); + + + parent.layout(); // Important - this actually paints the table + + createListeners(parent); + } + + public void createCheckboxSelectionLinks() { + if (useCheckboxes) { + // create the "select all/none" links + toolkit.createLabel(this, "Select"); + linkAll = toolkit.createHyperlink(this, "all", SWT.NONE); + linkAll.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { + ((CheckboxTableViewer) tableViewer).setAllChecked(true); + tableViewer.setSelection(new StructuredSelection(getAllEntities())); + } + }); + + toolkit.createLabel(this, " / "); + + linkNone = toolkit.createHyperlink(this, "none", SWT.NONE); + linkNone.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) { + ((CheckboxTableViewer) tableViewer).setAllChecked(false); + tableViewer.setSelection(StructuredSelection.EMPTY); + } + }); + } else { + // create dummy labels to maintain layout + toolkit.createLabel(this, ""); + toolkit.createLabel(this, ""); + toolkit.createLabel(this, ""); + toolkit.createLabel(this, ""); + } + } + + private void createListeners(final Composite parent) { + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + + clusterListener = createClusterListener(); + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + + addDisposeListener(new DisposeListener() { + + @Override + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } + }); + } + + protected abstract ClusterListener createClusterListener(); + protected abstract String[] getColumnNames(); + protected abstract void setColumnProperties(Table table); + protected abstract IBaseLabelProvider getLabelProvider(); + protected abstract IContentProvider getContentProvider(); + protected abstract List getAllEntities(); + + public void addDoubleClickListener(IDoubleClickListener listener) { + tableViewer.addDoubleClickListener(listener); + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(5, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + protected void setupTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, getColumnNames()); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table); + } + + private void createTableViewer(Composite parent) { + int style = SWT.FLAT | SWT.FULL_SELECTION; + style |= (multiSelection ? SWT.MULTI : SWT.SINGLE); + + if(useCheckboxes) { + tableViewer = CheckboxTableViewer.newCheckList(parent, style); + } else { + tableViewer = new TableViewer(parent, style); + } + + tableViewer.setLabelProvider(getLabelProvider()); + tableViewer.setContentProvider(getContentProvider()); + setupTable(parent, tableViewer.getTable()); + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + tableViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + GridData layoutData = new GridData(); + layoutData.horizontalSpan=5; + layoutData.grabExcessHorizontalSpace = true; + layoutData.horizontalAlignment = SWT.FILL; + layoutData.verticalAlignment = SWT.FILL; + layoutData.grabExcessVerticalSpace = true; + tableViewerComposite.setLayoutData(layoutData); + + return tableViewerComposite; + } + + private void setupTableViewer(IWorkbenchSite site, final Text filterText) { + Composite tableViewerComposite = createTableViewerComposite(); + createTableViewer(tableViewerComposite); + site.setSelectionProvider(tableViewer); + + if(useCheckboxes) { + // make sure that table selection is driven by checkbox selection + guiHelper.configureCheckboxTableViewer((CheckboxTableViewer)tableViewer); + } + + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + + tableViewer.setComparator(createViewerComparator()); + for (int columnIndex = 0; columnIndex < tableViewer.getTable().getColumnCount(); columnIndex++) { + TableColumn column = tableViewer.getTable().getColumn(columnIndex); + column.addSelectionListener(getColumnSelectionAdapter(column, columnIndex)); + } + } + + private SelectionAdapter getColumnSelectionAdapter(final TableColumn column, final int columnIndex) { + return new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ViewerComparator viewerComparator = tableViewer.getComparator(); + if(viewerComparator instanceof TableViewerComparator) { + TableViewerComparator comparator = (TableViewerComparator)viewerComparator; + comparator.setColumn(columnIndex); + tableViewer.getTable().setSortDirection(comparator.getDirection()); + tableViewer.getTable().setSortColumn(column); + tableViewer.refresh(); + } + } + }; + } + + protected abstract ViewerComparator createViewerComparator(); + + /* (non-Javadoc) + * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/BricksPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/BricksPage.java new file mode 100644 index 00000000..c9660a77 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/BricksPage.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.BrickTableLabelProvider; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.Volume; + + +public class BricksPage extends AbstractTableViewerPage { + private List bricks; + + public enum BRICK_TABLE_COLUMN_INDICES { + SERVER, BRICK, FREE_SPACE, TOTAL_SPACE, STATUS + }; + + private static final String[] DISK_TABLE_COLUMN_NAMES = new String[] { "Server", "Brick Directory", "Free Space (GB)", + "Total Space (GB)", "Status" }; + + public BricksPage(Composite parent, int style, IWorkbenchSite site, final List bricks) { + super(site, parent, style, true, true, bricks); + this.bricks = bricks; + } + + @Override + protected ClusterListener createClusterListener() { + return new DefaultClusterListener() { + @SuppressWarnings("unchecked") + @Override + public void volumeChanged(Volume volume, Event event) { + switch (event.getEventType()) { + case BRICKS_ADDED: + tableViewer.add(((Collection) event.getEventData()).toArray()); + parent.update(); + break; + + case BRICKS_REMOVED: + tableViewer.remove(((Collection) event.getEventData()).toArray()); + parent.update(); + break; + + case BRICKS_CHANGED: + Object eventData = event.getEventData(); + Brick[] updatedBricks; + if(eventData instanceof Map) { + updatedBricks = ((Map) eventData).keySet().toArray(new Brick[0]); + } else { + updatedBricks = ((Collection)eventData).toArray(new Brick[0]); + } + tableViewer.update(updatedBricks, null); + parent.update(); + tableViewer.refresh(true); + default: + break; + } + } + }; + } + + @Override + protected String[] getColumnNames() { + return DISK_TABLE_COLUMN_NAMES; + } + + @Override + protected void setColumnProperties(Table table) { + guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.SERVER.ordinal(), SWT.CENTER, 100); + guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.BRICK.ordinal(), SWT.CENTER, 100); + guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.FREE_SPACE.ordinal(), SWT.CENTER, 90); + guiHelper.setColumnProperties(table, BRICK_TABLE_COLUMN_INDICES.TOTAL_SPACE.ordinal(), SWT.CENTER, 90); + } + + @Override + protected ITableLabelProvider getLabelProvider() { + return new BrickTableLabelProvider(); + } + + @Override + protected IContentProvider getContentProvider() { + return new ArrayContentProvider(); + } + + @Override + protected List getAllEntities() { + return bricks; + } + + @Override + protected ViewerComparator createViewerComparator() { + return null; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java new file mode 100644 index 00000000..a7518d3c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DiskTreeContentProvider.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Partition; + + +public class DiskTreeContentProvider implements ITreeContentProvider { + + private List disks = new ArrayList(); + + public DiskTreeContentProvider(List disks) { + this.disks = disks; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + return ((List) inputElement).toArray(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, + * java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + public Object[] getChildren(Object parentElement) { + if(parentElement instanceof Disk) { + return ((Disk)parentElement).getPartitions().toArray(); + } else { + return null; + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + public Object getParent(Object element) { + if (element == null) { + return null; + } + + if(element instanceof Partition) { + // find the disk of this partition and return + return getDiskForPartition((Partition)element); + } else { + return null; + } + } + + private Disk getDiskForPartition(Partition partition) { + for(Disk disk : disks) { + for(Partition diskPartition : disk.getPartitions()) { + if(partition.getName().equals(diskPartition.getName())) { + return disk; + } + } + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + public boolean hasChildren(Object element) { + return (element instanceof Disk && ((Disk)element).getPartitions().size() > 0); + } + + + +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DisksPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DisksPage.java new file mode 100644 index 00000000..21704d4c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/DisksPage.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.DeviceTableLabelProvider; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Entity; + + +public class DisksPage extends AbstractDisksPage { + + public enum DISK_TABLE_COLUMN_INDICES { + DISK, PARTITION, FREE_SPACE, TOTAL_SPACE, STATUS + }; + + private static final String[] DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Partition", "Free Space (GB)", + "Total Space (GB)", "Status" }; + + public DisksPage(final Composite parent, int style, IWorkbenchSite site, List disks) { + super(parent, style, site, disks); + } + + private String getDiskTableColumnDesc(DISK_TABLE_COLUMN_INDICES idx) { + return DISK_TABLE_COLUMN_NAMES[idx.ordinal()]; + } + + @Override + protected DeviceTableLabelProvider getLabelProvider() { + return new DeviceTableLabelProvider(); + } + + + @Override + protected IContentProvider getContentProvider() { + return new DiskTreeContentProvider(disks); + } + + @Override + protected int getStatusColumnIndex() { + return DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(); + } + + @Override + public void entityChanged(Entity entity, String[] paremeters) { + // TODO Auto-generated method stub + + } + +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/GlusterServersPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/GlusterServersPage.java new file mode 100644 index 00000000..bf0e797d --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/GlusterServersPage.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.EntityGroupContentProvider; +import org.gluster.storage.management.console.GlusterServerTableLabelProvider; +import org.gluster.storage.management.console.utils.TableViewerComparator; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.GlusterServer; + + +public class GlusterServersPage extends AbstractTableViewerPage { + private List glusterServers; + + public enum GLUSTER_SERVER_TABLE_COLUMN_INDICES { + NAME, IP_ADDRESSES, NUM_OF_CPUS, TOTAL_MEMORY, TOTAL_FREE_SPACE, TOTAL_DISK_SPACE, STATUS // Removed PREFERRED_NETWORK + }; + + private static final String[] GLUSTER_SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", "IP Address(es)", + "Number" + CoreConstants.NEWLINE + "of CPUs", "Total" + CoreConstants.NEWLINE + "Memory (GB)", + "Free Space (GB)", "Total " + CoreConstants.NEWLINE + " Space (GB)", "Status" }; // Removed "Preferred\nNetwork", + + public GlusterServersPage(IWorkbenchSite site, final Composite parent, int style, final EntityGroup servers) { + super(site, parent, style, true, true, servers); + this.glusterServers = servers.getEntities(); + } + + @Override + protected ViewerComparator createViewerComparator() { + return new TableViewerComparator(); + } + + @Override + protected ClusterListener createClusterListener() { + return new DefaultClusterListener() { + + @Override + public void serverAdded(GlusterServer server) { + tableViewer.add(server); + parent.update(); + } + + @Override + public void serverRemoved(GlusterServer server) { + tableViewer.remove(server); + parent.update(); + } + + @Override + public void serverChanged(GlusterServer server, Event event) { + tableViewer.update(server, null); + parent.update(); + } + }; + } + + @Override + protected void setColumnProperties(Table table) { + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.NAME, SWT.CENTER, 100); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.STATUS, SWT.CENTER, 70); + // setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.PREFERRED_NETWORK, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.NUM_OF_CPUS, SWT.CENTER, 90); + //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_MEMORY, SWT.CENTER, 90); + //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_FREE_SPACE, SWT.CENTER, 90); + setColumnProperties(table, GLUSTER_SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE, SWT.CENTER, 90); + //setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE, SWT.CENTER, 90); + } + + @Override + protected IBaseLabelProvider getLabelProvider() { + return new GlusterServerTableLabelProvider(); + } + + @Override + protected IContentProvider getContentProvider() { + return new EntityGroupContentProvider(); + } + + @Override + protected String[] getColumnNames() { + return GLUSTER_SERVER_TABLE_COLUMN_NAMES; + } + + @Override + protected List getAllEntities() { + return glusterServers; + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, GLUSTER_SERVER_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java new file mode 100644 index 00000000..676e0ee4 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionKeyEditingSupport.java @@ -0,0 +1,120 @@ +/** + * + */ +package org.gluster.storage.management.console.views.pages; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.ComboBoxCellEditor; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeOption; +import org.gluster.storage.management.core.model.VolumeOptionInfo; +import org.gluster.storage.management.core.model.VolumeOptions; + + +/** + * Editing support for the "value" column in volume options table viewer. + */ +public class OptionKeyEditingSupport extends EditingSupport { + private CellEditor cellEditor; + private Volume volume; + private List defaults = GlusterDataModelManager.getInstance().getVolumeOptionsInfo(); + private String[] allowedKeys; + private ColumnViewer viewer; + + public OptionKeyEditingSupport(ColumnViewer viewer, Volume volume) { + super(viewer); + this.volume = volume; + this.viewer = viewer; + } + + /** + * @return array of option keys that are not already set on the volume + */ + private String[] getAllowedKeys() { + ArrayList keys = new ArrayList(); + VolumeOptions volumeOptions = volume.getOptions(); + for(VolumeOptionInfo optionInfo : defaults) { + String optionName = optionInfo.getName(); + if(!volumeOptions.containsKey(optionName) || volumeOptions.get(optionName).isEmpty()) { + // key not set => available for setting + // value not set => this is the row being edited + keys.add(optionName); + } + } + return keys.toArray(new String[0]); + } + + @Override + protected void setValue(final Object element, final Object value) { + VolumeOption oldEntry = (VolumeOption)element; + Integer newValue = (Integer)value; + String newKey = allowedKeys[newValue]; + + if (((VolumeOption)element).getKey().equals(newKey)) { + // selected value is same as old one. + return; + } + + // value has changed. set new value and refresh the viewer. + volume.getOptions().remove(oldEntry.getKey()); + volume.setOption(newKey, ""); + getViewer().refresh(); + } + + @Override + protected Object getValue(Object element) { + VolumeOption entryBeingAdded = getEntryBeingAdded(); + if(entryBeingAdded == null) { + return cellEditor.getValue(); + } + + if(entryBeingAdded.getKey().isEmpty()) { + // editing just about to start. set first element as default. + return 0; + } + + return getIndexOfEntry(entryBeingAdded); + } + + @Override + protected CellEditor getCellEditor(Object element) { + allowedKeys = getAllowedKeys(); + cellEditor = new ComboBoxCellEditor((Composite) viewer.getControl(), allowedKeys, SWT.READ_ONLY); + return cellEditor; + } + + private int getIndexOfEntry(VolumeOption entryBeingAdded) { + for(int index = 0; index < allowedKeys.length; index++) { + if(allowedKeys[index].equals(entryBeingAdded.getKey())) { + return index; + } + } + return -1; + } + + protected VolumeOption getEntryBeingAdded() { + List options = volume.getOptions().getOptions(); + int size = options.size(); + String lastValue = options.get(size - 1).getValue(); + if(lastValue == null || lastValue.isEmpty()) { + // it's the LAST entry, and it's value is empty. + // means this is a new row being added in the table viewer. + return options.get(size - 1); + } + return null; + } + + @Override + protected boolean canEdit(Object element) { + VolumeOption entry = (VolumeOption)element; + return (entry.getKey().isEmpty() || entry.getValue().isEmpty()); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java new file mode 100644 index 00000000..b2493f0f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/OptionValueEditingSupport.java @@ -0,0 +1,110 @@ +/** + * + */ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.ColumnViewer; +import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.TextCellEditor; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeOption; +import org.gluster.storage.management.core.model.VolumeOptionInfo; + + +/** + * Editing support for the "value" column in volume options table viewer. + */ +public class OptionValueEditingSupport extends EditingSupport { + private CellEditor cellEditor; + private Volume volume; + private List defaults = GlusterDataModelManager.getInstance().getVolumeOptionsInfo(); + private GUIHelper guiHelper = GUIHelper.getInstance(); + + public OptionValueEditingSupport(ColumnViewer viewer, Volume volume) { + super(viewer); + this.volume = volume; + this.cellEditor = new TextCellEditor((Composite) viewer.getControl()); + } + + @Override + protected void setValue(final Object element, final Object value) { + final VolumeOption entry = (VolumeOption)element; + final String optionKey = entry.getKey(); + final String optionValue = (String)value; + final String oldValue = entry.getValue(); + + // It is not allowed to change value to empty string + if(optionValue.isEmpty()) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option", + "Option value can't be empty! Please enter a valid value."); + cellEditor.setFocus(); + return; + } + + if (oldValue.equals(optionValue)) { + // value is same as that present in the model. return without doing anything. + return; + } + + // value has changed. set volume option at back-end and update model accordingly + guiHelper.setStatusMessage("Setting option [" + optionKey + " = " + optionValue + "]..."); + getViewer().getControl().update(); + + BusyIndicator.showWhile(Display.getDefault(), new Runnable() { + + @Override + public void run() { + VolumesClient client = new VolumesClient(); + try { + client.setVolumeOption(volume.getName(), optionKey, optionValue); + GlusterDataModelManager.getInstance().setVolumeOption(volume, optionKey, optionValue); + } catch(Exception e) { + MessageDialog.openError(Display.getDefault().getActiveShell(), "Set Volume Option", e.getMessage()); + } + getViewer().update(entry, null); + } + }); + + guiHelper.clearStatusMessage(); + getViewer().getControl().update(); + } + + /** + * @param key Key whose default value is to be fetched + * @return Default value of the volume option with given key + */ + private String getDefaultValue(String key) { + for(VolumeOptionInfo optionInfo : defaults) { + if(optionInfo.getName().equals(key)) { + return optionInfo.getDefaultValue(); + } + } + return ""; + } + + @Override + protected Object getValue(Object element) { + VolumeOption entry = (VolumeOption) element; + return entry.getValue().isEmpty() ? getDefaultValue(entry.getKey()) : entry.getValue(); + } + + @Override + protected CellEditor getCellEditor(Object element) { + return cellEditor; + } + + @Override + protected boolean canEdit(Object element) { + return true; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerDisksPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerDisksPage.java new file mode 100644 index 00000000..da25e49f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerDisksPage.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.ServerDiskTableLabelProvider; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Entity; + + +public class ServerDisksPage extends AbstractDisksPage { + + public ServerDisksPage(Composite parent, int style, IWorkbenchSite site, List disks) { + super(parent, style, site, disks); + } + + public enum SERVER_DISK_TABLE_COLUMN_INDICES { + DISK, PARTITION, FREE_SPACE, TOTAL_SPACE, STATUS + }; + + private static final String[] SERVER_DISK_TABLE_COLUMN_NAMES = new String[] { "Disk", "Partition", "Free Space (GB)", + "Total Space (GB)", "Status" }; + + @Override + protected int getStatusColumnIndex() { + return SERVER_DISK_TABLE_COLUMN_INDICES.STATUS.ordinal(); + } + + @Override + protected ServerDiskTableLabelProvider getLabelProvider() { + // return new DeviceTableLabelProvider(); + return new ServerDiskTableLabelProvider(); + } + + + @Override + protected IContentProvider getContentProvider() { + return new DiskTreeContentProvider(disks); + } + + @Override + public void entityChanged(Entity entity, String[] paremeters) { + // TODO Auto-generated method stub + + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerLogsPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerLogsPage.java new file mode 100644 index 00000000..ec7c65c6 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServerLogsPage.java @@ -0,0 +1,199 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.model.GlusterServer; + + +public class ServerLogsPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Text text; + private Table table; + + public enum LOG_TABLE_COLUMN_INDICES { + DATE, TIME, DISK, SEVERITY, MESSAGE + }; + + private static final String[] LOG_TABLE_COLUMN_NAMES = new String[] { "Date", "Time", "Disk", "Severity", "Message" }; + + /** + * Create the composite. + * + * @param parent + * @param style + */ + public ServerLogsPage(Composite parent, int style, GlusterServer server) { + super(parent, style); + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setLayout(new GridLayout(1, false)); + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace = true; + layoutData.grabExcessVerticalSpace = true; + setLayoutData(layoutData); + + Composite composite = toolkit.createComposite(this, SWT.NONE); + toolkit.paintBordersFor(composite); + + Label lblScanLast = toolkit.createLabel(composite, "Scan last", SWT.NONE); + lblScanLast.setBounds(0, 15, 80, 20); + + text = toolkit.createText(composite, "100", SWT.NONE); + text.setBounds(85, 15, 60, 20); + text.setTextLimit(4); + text.addVerifyListener(new VerifyListener() { + + @Override + public void verifyText(VerifyEvent event) { + // Assume we allow it + event.doit = true; + + String text = event.text; + char[] chars = text.toCharArray(); + + // Don't allow if text contains non-digit characters + for (int i = 0; i < chars.length; i++) { + if (!Character.isDigit(chars[i])) { + event.doit = false; + break; + } + } + + } + }); + + Label lblMessagesAndFilter = toolkit.createLabel(composite, " messages from ", SWT.CENTER); + lblMessagesAndFilter.setBounds(160, 15, 110, 20); + + Combo combo = new Combo(composite, SWT.CENTER); + combo.setBounds(295, 15, 100, 20); + combo.setItems(new String[] { "syslog", "dmesg" }); + toolkit.adapt(combo); + toolkit.paintBordersFor(combo); + combo.select(0); + + Button btngo = toolkit.createButton(composite, "&Go", SWT.NONE); + btngo.setBounds(410, 13, 50, 30); + + Label separator = toolkit.createLabel(composite, "", SWT.SEPARATOR | SWT.HORIZONTAL | SWT.FILL); + separator.setBounds(0, 50, 500, 2); + + Label lblFilterString = toolkit.createLabel(composite, "Filter String", SWT.LEFT); + lblFilterString.setBounds(0, 65, 100, 20); + + text = guiHelper.createFilterText(toolkit, composite); + text.setBounds(105, 65, 250, 20); + + Composite logContentsComposite = createLogContentsComposite(toolkit); + // Text logContentsText = toolkit.createText(logContentsComposite, "", SWT.MULTI | SWT.FLAT | SWT.BORDER); + // logContentsText.setEditable(false); + // populateDummyLogContent(logContentsText); + + ListViewer logViewer = new ListViewer(logContentsComposite, SWT.BORDER | SWT.V_SCROLL | SWT.NO); + logViewer.setContentProvider(new ArrayContentProvider()); + guiHelper.createFilter(logViewer, text, false); + logViewer.setInput(getDummyLogContents()); + + // TODO: Link the filter string with the contents text + } + + private Composite createLogContentsComposite(FormToolkit toolkit) { + Composite tableViewerComposite = toolkit.createComposite(this, SWT.NONE); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + layoutData.verticalIndent = 10; + tableViewerComposite.setLayoutData(layoutData); + return tableViewerComposite; + } + + private String[] getDummyLogContents() { + + String[] logMessages = { + "Jan 19 13:43:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:44:08 shireesh-laptop dhclient: last message repeated 5 times", + "Jan 19 13:44:47 shireesh-laptop dhclient: last message repeated 2 times", + "Jan 19 13:44:47 shireesh-laptop dhclient: DHCPREQUEST of 192.168.1.174 on eth1 to 255.255.255.255 port 67", + "Jan 19 13:45:49 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:46:59 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:48:01 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:49:02 shireesh-laptop dhclient: last message repeated 5 times", + "Jan 19 13:50:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:51:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:52:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:53:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:54:08 shireesh-laptop dhclient: last message repeated 5 times", + "Jan 19 13:55:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:56:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:57:08 shireesh-laptop dhclient: last message repeated 3 times", + "Jan 19 13:58:08 shireesh-laptop dhclient: last message repeated 6 times", + "Jan 19 13:59:08 shireesh-laptop dhclient: last message repeated 4 times", + "Jan 19 13:59:40 shireesh-laptop dhclient: last message repeated 3 times", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: DHCP: device eth1 state changed bound -> expire", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: DHCP: device eth1 state changed expire -> preinit", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPOFFER of 192.168.1.174 from 192.168.1.1", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPREQUEST of 192.168.1.174 on eth1 to 255.255.255.255 port 67", + "Jan 19 13:59:40 shireesh-laptop dhclient: DHCPACK of 192.168.1.174 from 192.168.1.1", + "Jan 19 13:59:40 shireesh-laptop dhclient: bound to 192.168.1.174 -- renewal in 3205 seconds.", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: DHCP: device eth1 state changed preinit -> bound", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: address 192.168.1.174", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: prefix 24 (255.255.255.0)", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: gateway 192.168.1.1", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: nameserver '192.168.1.1'", + "Jan 19 13:59:40 shireesh-laptop NetworkManager: domain name 'in.gluster.com'", + "Jan 19 14:03:53 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", + "Jan 19 14:03:53 shireesh-laptop avahi-daemon[1098]: Received response from host 192.168.1.155 with invalid source port 37219 on interface 'eth0.0'", + "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", + "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Invalid legacy unicast query packet.", + "Jan 19 14:03:54 shireesh-laptop avahi-daemon[1098]: Received response from host 192.168.1.155 with invalid source port 37219 on interface 'eth0.0'", + "Jan 19 14:05:09 shireesh-laptop avahi-daemon[1098]: last message repeated 8 times", + "Jan 19 14:12:48 shireesh-laptop NetworkManager: [1295426568.002642] periodic_update(): Roamed from BSSID E0:CB:4E:C0:0B:7F (glfs) to (none) ((none))", + "Jan 19 14:12:54 shireesh-laptop NetworkManager: [1295426574.002448] periodic_update(): Roamed from BSSID (none) ((none)) to E0:CB:4E:C0:0B:7F (glfs)", + "Jan 19 14:17:01 shireesh-laptop CRON[5321]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)" }; + + return logMessages; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServersPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServersPage.java new file mode 100644 index 00000000..ae34e948 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/ServersPage.java @@ -0,0 +1,138 @@ + /******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.EntityGroupContentProvider; +import org.gluster.storage.management.console.ServerTableLabelProvider; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.Server; + + +public class ServersPage extends AbstractTableViewerPage { + private List servers; + + public enum SERVER_TABLE_COLUMN_INDICES { + NAME, IP_ADDRESSES, NUM_OF_DISKS, TOTAL_DISK_SPACE + }; + + private static final String[] SERVER_TABLE_COLUMN_NAMES = new String[] { "Name", "IP Address(es)", "Number of Disks", "Total Disk Space (GB)" }; + + public ServersPage(final Composite parent, IWorkbenchSite site, EntityGroup serversGroup) { + super(site, parent, SWT.NONE, true, true, serversGroup); + this.servers = serversGroup.getEntities(); + } + + @Override + protected ClusterListener createClusterListener() { + return new DefaultClusterListener() { + @Override + public void discoveredServerRemoved(Server server) { + tableViewer.remove(server); + parent.update(); + } + + @Override + public void discoveredServerAdded(Server server) { + tableViewer.add(server); + parent.update(); + } + + @Override + public void discoveredServerChanged(Server server, Event event) { + tableViewer.update(server, null); + parent.update(); + } + }; + } + + public void setInput(EntityGroup servers) { + tableViewer.setInput(servers); + tableViewer.refresh(); + } + + @Override + protected void setColumnProperties(Table table) { + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.NAME, SWT.CENTER, 70); + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.IP_ADDRESSES, SWT.CENTER, 100); + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.NUM_OF_DISKS, SWT.CENTER, 70); + setColumnProperties(table, SERVER_TABLE_COLUMN_INDICES.TOTAL_DISK_SPACE, SWT.CENTER, 70); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.NUM_OF_CPUS, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.CPU_USAGE, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.TOTAL_MEMORY, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.MEMORY_IN_USE, SWT.CENTER, 90); + // setColumnProperties(table, SERVER_DISK_TABLE_COLUMN_INDICES.DISK_SPACE_IN_USE, SWT.CENTER, 90); + } + + @Override + protected String[] getColumnNames() { + return SERVER_TABLE_COLUMN_NAMES; + } + + @Override + protected IBaseLabelProvider getLabelProvider() { + return new ServerTableLabelProvider(); + } + + @Override + protected IContentProvider getContentProvider() { + return new EntityGroupContentProvider(); + } + + @Override + protected List getAllEntities() { + return servers; + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + private void setColumnProperties(Table table, SERVER_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + @Override + protected ViewerComparator createViewerComparator() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/TasksPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/TasksPage.java new file mode 100644 index 00000000..aeea018c --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/TasksPage.java @@ -0,0 +1,151 @@ +/** + * TasksPage.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.TasksTableLabelProvider; +import org.gluster.storage.management.console.toolbar.GlusterToolbarManager; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.TaskInfo; + + +public class TasksPage extends AbstractTableViewerPage { + private List taskInfoList; + private TaskInfo selectedTask; + + public enum TASK_TABLE_COLUMN_INDICES { + TASK, STATUS + }; + + private static final String[] TASK_TABLE_COLUMN_NAMES = new String[] { "Task", "Status"}; + + + public TasksPage(IWorkbenchSite site, Composite parent, int style, List taskInfo) { + super(site, parent, style, false, false, taskInfo); + this.taskInfoList = taskInfo; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#createClusterListener() + */ + @Override + protected ClusterListener createClusterListener() { + return new DefaultClusterListener() { + @Override + public void taskAdded(TaskInfo taskInfo) { + tableViewer.add(taskInfo); + parent.update(); + } + + @Override + public void taskRemoved(TaskInfo taskInfo) { + tableViewer.remove(taskInfo); + parent.update(); + // hide the task related actionset as no task is selected + // site.getPage().hideActionSet(ActionConstants.ACTION_SET_TASK); + } + + @Override + public void taskUpdated(TaskInfo taskInfo) { + tableViewer.update(taskInfo, null); + parent.update(); + // fire selection event so that toolbar gets updated + // (the action class listens to selection and enables/disables automatically) + tableViewer.setSelection(new StructuredSelection(taskInfo)); + } + }; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getColumnNames() + */ + @Override + protected String[] getColumnNames() { + return TASK_TABLE_COLUMN_NAMES; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#setColumnProperties(org.eclipse.swt.widgets.Table) + */ + @Override + protected void setColumnProperties(Table table) { + guiHelper.setColumnProperties(table, TASK_TABLE_COLUMN_INDICES.TASK.ordinal(), SWT.LEFT, 50); + guiHelper.setColumnProperties(table, TASK_TABLE_COLUMN_INDICES.STATUS.ordinal(), SWT.LEFT, 50); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getLabelProvider() + */ + @Override + protected IBaseLabelProvider getLabelProvider() { + return new TasksTableLabelProvider(); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getContentProvider() + */ + @Override + protected IContentProvider getContentProvider() { + return new ArrayContentProvider(); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#getAllEntities() + */ + @Override + protected List getAllEntities() { + return taskInfoList; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.console.views.pages.AbstractTableViewerPage#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) + */ + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (selection instanceof StructuredSelection) { + Entity selectedEntity = (Entity) ((StructuredSelection) selection).getFirstElement(); + if (selectedEntity != null && selectedEntity instanceof TaskInfo && selectedEntity != selectedTask) { + selectedTask = (TaskInfo)selectedEntity; + new GlusterToolbarManager(part.getSite().getWorkbenchWindow()).updateToolbar(selectedTask); + } + } + } + + @Override + protected ViewerComparator createViewerComparator() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeLogsPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeLogsPage.java new file mode 100644 index 00000000..d32589bb --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeLogsPage.java @@ -0,0 +1,431 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DateTime; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.gluster.storage.management.client.VolumesClient; +import org.gluster.storage.management.console.VolumeLogTableLabelProvider; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.constants.GlusterConstants.VOLUME_LOG_LEVELS; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeLogMessage; + + +public class VolumeLogsPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private final GUIHelper guiHelper = GUIHelper.getInstance(); + private Text filterText; + private Text lineCountText; + private Volume volume; + + public enum LOG_TABLE_COLUMN_INDICES { + DATE, TIME, BRICK, SEVERITY, MESSAGE + }; + + private static final String[] LOG_TABLE_COLUMN_NAMES = new String[] { "Date", "Time", "Brick", "Severity", "Message" }; + private TableViewer tableViewer; + private Combo bricksCombo; + private Combo severityCombo; + private DateTime fromDate; + private DateTime fromTime; + private DateTime toDate; + private DateTime toTime; + private Button fromCheckbox; + private Button toCheckbox; + + /** + * Create the volume logs page + * + * @param parent + * @param style + * @param volume + * Volume for which the logs page is to be created + */ + public VolumeLogsPage(Composite parent, int style, Volume volume) { + super(parent, style); + this.volume = volume; + + addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + } + }); + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + configureLayout(); + + Composite composite = toolkit.createComposite(this, SWT.NONE); + toolkit.paintBordersFor(composite); + + createLineCountLabel(composite); + createLineCountText(composite); + + createBricksLabel(composite); + createBricksCombo(composite); + + createSeverityLabel(composite); + createSeverityCombo(composite); + + createFromDateLabel(composite); + createFromDateField(composite); + createFromTimeField(composite); + createFromCheckbox(composite); + + createToDateLabel(composite); + createToDateField(composite); + createToTimeField(composite); + createToCheckbox(composite); + + createSearchButton(composite); + + createSeparator(composite); + + createFilterLabel(composite); + createFilterText(composite); + + createLogTableViewer(); + } + + private void createLogTableViewer() { + Composite tableViewerComposite = createTableViewerComposite(); + + tableViewer = new TableViewer(tableViewerComposite, SWT.FLAT | SWT.FULL_SELECTION | SWT.MULTI); + tableViewer.setLabelProvider(new VolumeLogTableLabelProvider()); + tableViewer.setContentProvider(new ArrayContentProvider()); + + setupLogsTable(tableViewerComposite, tableViewer.getTable()); + guiHelper.createFilter(tableViewer, filterText, false); + } + + private void createFilterText(Composite composite) { + filterText = guiHelper.createFilterText(toolkit, composite); + filterText.setBounds(90, 105, 250, 20); + } + + private void createFilterLabel(Composite composite) { + Label lblFilterString = toolkit.createLabel(composite, "Filter String", SWT.LEFT); + lblFilterString.setBounds(0, 105, 85, 20); + } + + private void createSeparator(Composite composite) { + Label separator = toolkit.createLabel(composite, "", SWT.SEPARATOR | SWT.HORIZONTAL | SWT.FILL); + separator.setBounds(0, 95, 680, 2); + } + + private void createSearchButton(Composite composite) { + Button btnGo = toolkit.createButton(composite, "&Fetch Logs", SWT.NONE); + btnGo.setBounds (615, 55, 75, 30); + btnGo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + VolumesClient client = new VolumesClient(); + + Date fromTimestamp = null; + Date toTimestamp = null; + + if (fromCheckbox.getSelection()) { + fromTimestamp = extractTimestamp(fromDate, fromTime); + } + + if (toCheckbox.getSelection()) { + toTimestamp = extractTimestamp(toDate, toTime); + } + + if (!validateTimeRange(fromTimestamp, toTimestamp)) { + return; + } + + try { + List logMessages = client.getLogs(volume.getName(), bricksCombo.getText(), + severityCombo.getText(), fromTimestamp, toTimestamp, + Integer.parseInt(lineCountText.getText())); + tableViewer.setInput(logMessages.toArray(new VolumeLogMessage[0])); + tableViewer.refresh(); + } catch (Exception ex) { + MessageDialog.openError(getShell(), "Volume Logs", + "Error while fetching volume logs: [" + ex.getMessage() + "]"); + } + } + }); + } + + protected boolean validateTimeRange(Date fromTimestamp, Date toTimestamp) { + if (fromTimestamp == null && toTimestamp == null) { + // no time range selected. nothing to validate. + return true; + } + + Calendar calendar = Calendar.getInstance(); + Date now = calendar.getTime(); + if (fromTimestamp != null && fromTimestamp.after(now)) { + MessageDialog.openError(getShell(), "Volume Logs", "From time can't be greater than current time!"); + return false; + } + + if (toTimestamp != null) { + if (toTimestamp.after(now)) { + MessageDialog.openError(getShell(), "Volume Logs", "To time can't be greater than current time!"); + return false; + } + + if (fromTimestamp.after(toTimestamp)) { + MessageDialog.openError(getShell(), "Volume Logs", "From time can't be greater than To time!"); + return false; + } + } + + return true; + } + + private void createToCheckbox(Composite composite) { + toCheckbox = toolkit.createButton(composite, null, SWT.CHECK); + toCheckbox.setBounds(320, 60, 15, 20); + toCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (toCheckbox.getSelection()) { + toDate.setEnabled(true); + toTime.setEnabled(true); + } else { + toDate.setEnabled(false); + toTime.setEnabled(false); + } + } + }); + } + + private void createToTimeField(Composite composite) { + toTime = new DateTime(composite, SWT.BORDER | SWT.TIME); + toTime.setBounds(490, 60, 120, 20); + toTime.setEnabled(false); + toolkit.adapt(toTime); + toolkit.paintBordersFor(toTime); + } + + private void createToDateField(Composite composite) { + toDate = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN); + toDate.setBounds(365, 60, 120, 20); + toDate.setEnabled(false); + toolkit.adapt(toDate); + toolkit.paintBordersFor(toDate); + } + + private void createToDateLabel(Composite composite) { + Label lblTo = toolkit.createLabel(composite, "To", SWT.NONE); + lblTo.setBounds(340, 60, 25, 20); + } + + private void createFromCheckbox(Composite composite) { + fromCheckbox = toolkit.createButton(composite, null, SWT.CHECK); + fromCheckbox.setBounds(0, 60, 15, 20); + fromCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (fromCheckbox.getSelection()) { + fromDate.setEnabled(true); + fromTime.setEnabled(true); + } else { + fromDate.setEnabled(false); + fromTime.setEnabled(false); + } + } + }); + } + + private void createFromTimeField(Composite composite) { + fromTime = new DateTime(composite, SWT.BORDER | SWT.TIME); + fromTime.setBounds(190, 60, 120, 20); + fromTime.setEnabled(false); + toolkit.adapt(fromTime); + toolkit.paintBordersFor(fromTime); + } + + private void createFromDateField(Composite composite) { + fromDate = new DateTime(composite, SWT.BORDER | SWT.DROP_DOWN); + fromDate.setBounds(60, 60, 120, 20); + fromDate.setEnabled(false); + toolkit.adapt(fromDate); + toolkit.paintBordersFor(fromDate); + } + + private void createFromDateLabel(Composite composite) { + Label lblFrom = toolkit.createLabel(composite, "from", SWT.NONE); + lblFrom.setBounds(20, 60, 40, 20); + } + + private void createSeverityCombo(Composite composite) { + severityCombo = new Combo(composite, SWT.READ_ONLY); + severityCombo.setBounds(555, 15, 110, 20); + + severityCombo.setItems(GlusterConstants.VOLUME_LOG_LEVELS_ARR.toArray(new String[0])); + severityCombo.select(VOLUME_LOG_LEVELS.ERROR.ordinal()); + severityCombo.add(CoreConstants.ALL, 0); + + toolkit.adapt(severityCombo); + toolkit.paintBordersFor(severityCombo); + } + + private void createSeverityLabel(Composite composite) { + Label lblSeverity = toolkit.createLabel(composite, "Severity", SWT.NONE); + lblSeverity.setBounds(480, 15, 70, 20); + } + + private void createBricksCombo(Composite composite) { + bricksCombo = new Combo(composite, SWT.READ_ONLY); + bricksCombo.setBounds(365, 15, 100, 20); + bricksCombo.setItems( volume.getBrickDirectories().toArray(new String[0])); + bricksCombo.add(CoreConstants.ALL, 0); + toolkit.adapt(bricksCombo); + toolkit.paintBordersFor(bricksCombo); + bricksCombo.select(0); + } + + private void createBricksLabel(Composite composite) { + Label lblMessagesAndFilter = toolkit.createLabel(composite, "messages, and filter on bricks", SWT.NONE); + lblMessagesAndFilter.setBounds(160, 15, 200, 20); + } + + private void createLineCountText(Composite composite) { + lineCountText = toolkit.createText(composite, "100", SWT.NONE); + lineCountText.setBounds(85, 15, 60, 20); + lineCountText.setTextLimit(4); + lineCountText.addVerifyListener(new VerifyListener() { + + @Override + public void verifyText(VerifyEvent event) { + // Assume we allow it + event.doit = true; + + String text = event.text; + char[] chars = text.toCharArray(); + + // Don't allow if text contains non-digit characters + for (int i = 0; i < chars.length; i++) { + if (!Character.isDigit(chars[i])) { + event.doit = false; + break; + } + } + } + }); + } + + private void createLineCountLabel(Composite composite) { + Label lblScanLast = toolkit.createLabel(composite, "Scan last", SWT.NONE); + lblScanLast.setBounds(0, 15, 80, 20); + } + + private void configureLayout() { + setLayout(new GridLayout(1, false)); + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace = true; + layoutData.grabExcessVerticalSpace = true; + // layoutData.verticalIndent = 10; + setLayoutData(layoutData); + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + layoutData.verticalIndent = 10; + tableViewerComposite.setLayoutData(layoutData); + return tableViewerComposite; + } + + private void setupLogsTable(Composite parent, Table table) { + table.setHeaderVisible(true); + table.setLinesVisible(false); + + TableColumnLayout tableColumnLayout = guiHelper.createTableColumnLayout(table, LOG_TABLE_COLUMN_NAMES); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.DATE, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.TIME, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.BRICK, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.SEVERITY, SWT.CENTER, 50); + setColumnProperties(table, LOG_TABLE_COLUMN_INDICES.MESSAGE, SWT.LEFT, 100); + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + private void setColumnProperties(Table table, LOG_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + private Date extractTimestamp(DateTime date, DateTime time) { + Calendar calendar = Calendar.getInstance(); + calendar.setLenient(false); + calendar.set(Calendar.DAY_OF_MONTH, date.getDay()); + // in Calendar class, month starts with zero i.e. Jan = 0 + calendar.set(Calendar.MONTH, date.getMonth()); + calendar.set(Calendar.YEAR, date.getYear()); + calendar.set(Calendar.HOUR_OF_DAY, time.getHours()); + calendar.set(Calendar.MINUTE, time.getMinutes()); + calendar.set(Calendar.SECOND, time.getSeconds()); + return calendar.getTime(); + } + + public void addDoubleClickListener(IDoubleClickListener listener) { + tableViewer.addDoubleClickListener(listener); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeOptionsPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeOptionsPage.java new file mode 100644 index 00000000..4363b7e9 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumeOptionsPage.java @@ -0,0 +1,360 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.apache.commons.lang.WordUtils; +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ColumnLayoutData; +import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.gluster.storage.management.console.GlusterDataModelManager; +import org.gluster.storage.management.console.VolumeOptionsContentProvider; +import org.gluster.storage.management.console.VolumeOptionsTableLabelProvider; +import org.gluster.storage.management.console.utils.GUIHelper; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeOption; +import org.gluster.storage.management.core.model.VolumeOptionInfo; + + +public class VolumeOptionsPage extends Composite { + + private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); + private TableViewer tableViewer; + private GUIHelper guiHelper = GUIHelper.getInstance(); + private Volume volume; + private DefaultClusterListener clusterListener; + private Text filterText; + private List defaultVolumeOptions = GlusterDataModelManager.getInstance() + .getVolumeOptionsInfo(); + + public enum OPTIONS_TABLE_COLUMN_INDICES { + OPTION_KEY, OPTION_VALUE + }; + + private static final String[] OPTIONS_TABLE_COLUMN_NAMES = new String[] { "Option Key", "Option Value" }; + private Button addTopButton; + private Button addBottomButton; + private TableViewerColumn keyColumn; + private OptionKeyEditingSupport keyEditingSupport; + + public VolumeOptionsPage(final Composite parent, int style, Volume volume) { + super(parent, style); + + this.volume = volume; + + toolkit.adapt(this); + toolkit.paintBordersFor(this); + + setupPageLayout(); + addTopButton = createAddButton(); + filterText = guiHelper.createFilterText(toolkit, this); + + setupOptionsTableViewer(filterText); + + addBottomButton = createAddButton(); + + if (defaultVolumeOptions.size() == volume.getOptions().size()) { + setAddButtonsEnabled(false); + } + + tableViewer.setInput(volume.getOptions()); + + parent.layout(); // Important - this actually paints the table + registerListeners(parent); + } + + private void setAddButtonsEnabled(boolean enable) { + addTopButton.setEnabled(enable); + addBottomButton.setEnabled(enable); + } + + private Button createAddButton() { + return toolkit.createButton(this, "&Add", SWT.FLAT); + } + + private void registerListeners(final Composite parent) { + /** + * Ideally not required. However the table viewer is not getting laid out properly on performing + * "maximize + restore" So this is a hack to make sure that the table is laid out again on re-size of the window + */ + addPaintListener(new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + parent.layout(); + } + }); + + clusterListener = new DefaultClusterListener() { + @Override + public void volumeChanged(Volume volume, Event event) { + super.volumeChanged(volume, event); + + switch (event.getEventType()) { + case VOLUME_OPTIONS_RESET: + if (!tableViewer.getControl().isDisposed()) { + //While reseting the options, clear the filter text before refreshing the tree + filterText.setText(""); + tableViewer.refresh(); + setAddButtonsEnabled(true); + } + break; + + case VOLUME_OPTION_SET: + String key = (String)event.getEventData(); + if (isNewOption(volume, key)) { + // option has been set successfully by the user. re-enable the add button and search filter + // textbox + setAddButtonsEnabled(true); + filterText.setEnabled(true); + } + + if (defaultVolumeOptions.size() == volume.getOptions().size()) { + setAddButtonsEnabled(false); + } + + tableViewer.refresh(); + break; + case VOLUME_CHANGED: + tableViewer.refresh(); + if(volume.getOptions().size() == defaultVolumeOptions.size()) { + setAddButtonsEnabled(false); + } else { + setAddButtonsEnabled(true); + } + default: + break; + } + } + + private boolean isNewOption(Volume volume, String optionKey) { + if (filterText.getText().length() > 0) { + // user has been filtering the contents. adding new option is allowed only when contents are NOT + // filtered. Thus it's impossible that this is a newly added option + return false; + } + + // if this is the last option in the volume options, it must be the new option + return optionKey.equals(volume.getOptions().getOptions().get(volume.getOptions().size() - 1).getKey()); + } + }; + + SelectionListener addButtonSelectionListener = new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + // add an empty option to be filled up by user + volume.setOption("", ""); + + tableViewer.refresh(); + tableViewer.setSelection(new StructuredSelection(getEntry(""))); + keyColumn.getViewer().editElement(getEntry(""), 0); // edit newly created entry + + // disable the add button AND search filter textbox till user fills up the new option + setAddButtonsEnabled(false); + filterText.setEnabled(false); + } + + private VolumeOption getEntry(String key) { + for (VolumeOption entry : volume.getOptions().getOptions()) { + if (entry.getKey().equals(key)) { + return entry; + } + } + return null; + } + }; + addTopButton.addSelectionListener(addButtonSelectionListener); + addBottomButton.addSelectionListener(addButtonSelectionListener); + + // Make sure that add button is enabled only when search filter textbox is empty + filterText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + if (filterText.getText().length() > 0) { + setAddButtonsEnabled(false); + } else { + if (defaultVolumeOptions.size() == volume.getOptions().size()) { + setAddButtonsEnabled(false); + } else { + setAddButtonsEnabled(true); + } + } + } + }); + + GlusterDataModelManager.getInstance().addClusterListener(clusterListener); + + addDisposeListener(new DisposeListener() { + + @Override + public void widgetDisposed(DisposeEvent e) { + toolkit.dispose(); + + if (!(addTopButton.isEnabled() || addBottomButton.isEnabled())) { + // user has selected key, but not added value. Since this is not a valid entry, + // remove the last option (without value) from the volume + volume.getOptions().remove(keyEditingSupport.getEntryBeingAdded().getKey()); + } + + GlusterDataModelManager.getInstance().removeClusterListener(clusterListener); + } + }); + } + + private void setupPageLayout() { + final GridLayout layout = new GridLayout(2, false); + layout.verticalSpacing = 10; + layout.marginTop = 10; + setLayout(layout); + } + + private void setupOptionsTable(Composite parent) { + Table table = tableViewer.getTable(); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + TableColumnLayout tableColumnLayout = createTableColumnLayout(); + parent.setLayout(tableColumnLayout); + + setColumnProperties(table, OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY, SWT.CENTER, 100); + setColumnProperties(table, OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE, SWT.CENTER, 100); + } + + private TableColumnLayout createTableColumnLayout() { + TableColumnLayout tableColumnLayout = new TableColumnLayout(); + ColumnLayoutData defaultColumnLayoutData = new ColumnWeightData(100); + + tableColumnLayout.setColumnData(createKeyColumn(), defaultColumnLayoutData); + tableColumnLayout.setColumnData(createValueColumn(), defaultColumnLayoutData); + + return tableColumnLayout; + } + + private TableColumn createValueColumn() { + TableViewerColumn valueColumn = new TableViewerColumn(tableViewer, SWT.NONE); + valueColumn.getColumn() + .setText(OPTIONS_TABLE_COLUMN_NAMES[OPTIONS_TABLE_COLUMN_INDICES.OPTION_VALUE.ordinal()]); + valueColumn.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + return ((VolumeOption) element).getValue(); + } + }); + + // User can edit value of a volume option + valueColumn.setEditingSupport(new OptionValueEditingSupport(valueColumn.getViewer(), volume)); + + return valueColumn.getColumn(); + } + + private TableColumn createKeyColumn() { + keyColumn = new TableViewerColumn(tableViewer, SWT.NONE); + keyColumn.getColumn().setText(OPTIONS_TABLE_COLUMN_NAMES[OPTIONS_TABLE_COLUMN_INDICES.OPTION_KEY.ordinal()]); + keyColumn.setLabelProvider(new ColumnLabelProvider() { + @Override + public String getText(Object element) { + return ((VolumeOption) element).getKey(); + } + + @Override + public String getToolTipText(Object element) { + String key = ((VolumeOption) element).getKey(); + if (key.isEmpty()) { + return "Click to select a volume option key"; + } + + VolumeOptionInfo optionInfo = GlusterDataModelManager.getInstance().getVolumeOptionInfo(key); + // Wrap the description before adding to tooltip so that long descriptions are displayed properly + return WordUtils.wrap(optionInfo.getDescription(), 60) + CoreConstants.NEWLINE + "Default value: " + + optionInfo.getDefaultValue(); + } + }); + + // Editing support required when adding new key + keyEditingSupport = new OptionKeyEditingSupport(keyColumn.getViewer(), volume); + keyColumn.setEditingSupport(keyEditingSupport); + + return keyColumn.getColumn(); + } + + private void createOptionsTableViewer(Composite parent) { + tableViewer = new TableViewer(parent, SWT.FLAT | SWT.FULL_SELECTION | SWT.SINGLE); + tableViewer.setLabelProvider(new VolumeOptionsTableLabelProvider()); + tableViewer.setContentProvider(new VolumeOptionsContentProvider()); + tableViewer.getTable().setLinesVisible(true); + + setupOptionsTable(parent); + } + + private Composite createTableViewerComposite() { + Composite tableViewerComposite = new Composite(this, SWT.NO); + tableViewerComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); + + GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + layoutData.horizontalSpan = 2; + tableViewerComposite.setLayoutData(layoutData); + + return tableViewerComposite; + } + + private void setupOptionsTableViewer(final Text filterText) { + Composite tableViewerComposite = createTableViewerComposite(); + createOptionsTableViewer(tableViewerComposite); + ColumnViewerToolTipSupport.enableFor(tableViewer); + // Create a case insensitive filter for the table viewer using the filter text field + guiHelper.createFilter(tableViewer, filterText, false); + } + + private void setColumnProperties(Table table, OPTIONS_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } +} diff --git a/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumesPage.java b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumesPage.java new file mode 100644 index 00000000..60d00a7f --- /dev/null +++ b/src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/views/pages/VolumesPage.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.console.views.pages; + +import java.util.List; + +import org.eclipse.jface.layout.TableColumnLayout; +import org.eclipse.jface.viewers.ColumnWeightData; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.IWorkbenchSite; +import org.gluster.storage.management.console.EntityGroupContentProvider; +import org.gluster.storage.management.console.VolumeTableLabelProvider; +import org.gluster.storage.management.console.toolbar.GlusterToolbarManager; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.model.ClusterListener; +import org.gluster.storage.management.core.model.DefaultClusterListener; +import org.gluster.storage.management.core.model.EntityGroup; +import org.gluster.storage.management.core.model.Event; +import org.gluster.storage.management.core.model.Volume; + + +public class VolumesPage extends AbstractTableViewerPage { + private List volumes; + + final GlusterToolbarManager toolbarManager = new GlusterToolbarManager( site.getWorkbenchWindow()); + + public enum VOLUME_TABLE_COLUMN_INDICES { + NAME, VOLUME_TYPE, NUM_OF_BRICKS, TRANSPORT_TYPE, VOLUME_STATUS + }; + + private static final String[] VOLUME_TABLE_COLUMN_NAMES = new String[] { "Name", "Volume Type", + "Number of" + CoreConstants.NEWLINE + "Bricks", "Transport Type", "Status" }; + + public VolumesPage(final Composite parent, IWorkbenchSite site, EntityGroup volumes) { + super(site, parent, SWT.NONE, true, true, volumes); + this.volumes = volumes.getEntities(); + } + + @Override + protected String[] getColumnNames() { + return VOLUME_TABLE_COLUMN_NAMES; + } + + @Override + protected void setColumnProperties(Table table) { + setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.VOLUME_STATUS, SWT.CENTER, 50); + setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.NUM_OF_BRICKS, SWT.CENTER, 50); + setColumnProperties(table, VOLUME_TABLE_COLUMN_INDICES.TRANSPORT_TYPE, SWT.CENTER, 70); + } + + @Override + protected IBaseLabelProvider getLabelProvider() { + return new VolumeTableLabelProvider(); + } + + @Override + protected IContentProvider getContentProvider() { + return new EntityGroupContentProvider(); + } + + @Override + protected ClusterListener createClusterListener() { + return new DefaultClusterListener() { + @Override + public void volumeCreated(Volume volume) { + tableViewer.add(volume); + parent.update(); + toolbarManager.updateToolbar(volume); + } + + @Override + public void volumeDeleted(Volume volume) { + tableViewer.remove(volume); + parent.update(); + toolbarManager.updateToolbar(volume); + } + + @Override + public void volumeChanged(Volume volume, Event event) { + tableViewer.update(volume, null); + parent.update(); + toolbarManager.updateToolbar(volume); + } + }; + } + + /** + * Sets properties for alignment and weight of given column of given table + * + * @param table + * @param columnIndex + * @param alignment + * @param weight + */ + public void setColumnProperties(Table table, VOLUME_TABLE_COLUMN_INDICES columnIndex, int alignment, int weight) { + TableColumn column = table.getColumn(columnIndex.ordinal()); + column.setAlignment(alignment); + + TableColumnLayout tableColumnLayout = (TableColumnLayout) table.getParent().getLayout(); + tableColumnLayout.setColumnData(column, new ColumnWeightData(weight)); + } + + @Override + protected List getAllEntities() { + return volumes; + } + + @Override + protected ViewerComparator createViewerComparator() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/org.gluster.storage.management.console/src/test.xml b/src/org.gluster.storage.management.console/src/test.xml new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/src/org.gluster.storage.management.console/src/test.xml @@ -0,0 +1 @@ + diff --git a/src/org.gluster.storage.management.core/.classpath b/src/org.gluster.storage.management.core/.classpath new file mode 100644 index 00000000..b41cbcdb --- /dev/null +++ b/src/org.gluster.storage.management.core/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/org.gluster.storage.management.core/.project b/src/org.gluster.storage.management.core/.project new file mode 100644 index 00000000..4db56096 --- /dev/null +++ b/src/org.gluster.storage.management.core/.project @@ -0,0 +1,34 @@ + + + org.gluster.storage.management.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + com.instantiations.assist.eclipse.coverage.instrumentationBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + com.instantiations.assist.eclipse.coverage.codeCoverageNature + + diff --git a/src/org.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs b/src/org.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f22cedf1 --- /dev/null +++ b/src/org.gluster.storage.management.core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Dec 22 11:18:01 IST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/org.gluster.storage.management.core/META-INF/MANIFEST.MF b/src/org.gluster.storage.management.core/META-INF/MANIFEST.MF new file mode 100644 index 00000000..4f6c2282 --- /dev/null +++ b/src/org.gluster.storage.management.core/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Gluster Storage Platform Core +Bundle-SymbolicName: org.gluster.storage.management.core +Bundle-Version: 1.0.0 +Bundle-Vendor: GLUSTER +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: org.gluster.storage.management.core.constants, + org.gluster.storage.management.core.exceptions, + org.gluster.storage.management.core.model, + org.gluster.storage.management.core.response, + org.gluster.storage.management.core.utils +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0" +Bundle-ClassPath: . +Import-Package: org.gluster.storage.management.core.exceptions diff --git a/src/org.gluster.storage.management.core/build.properties b/src/org.gluster.storage.management.core/build.properties new file mode 100644 index 00000000..89d32a46 --- /dev/null +++ b/src/org.gluster.storage.management.core/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + lib/ +src.includes = lib/,\ + src/ diff --git a/src/org.gluster.storage.management.core/junit/core.junit.launch b/src/org.gluster.storage.management.core/junit/core.junit.launch new file mode 100644 index 00000000..3d6e7deb --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/core.junit.launch @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/AlertTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/AlertTest.java new file mode 100644 index 00000000..7ab59398 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/AlertTest.java @@ -0,0 +1,83 @@ +package org.gluster.storage.management.core.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.gluster.storage.management.core.model.Alert; +import org.gluster.storage.management.core.model.Alert.ALERT_TYPES; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * The class AlertTest contains tests for the class {@link Alert}. + * + * @generatedBy CodePro at 10/17/11 3:32 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class AlertTest { + + /** + * Run the void copyFrom(Alert) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 3:32 PM + */ + @Test + public void testCopyFrom_1() + throws Exception { + Alert fixture = new Alert(ALERT_TYPES.DISK_USAGE_ALERT, "server1:sda", + Alert.ALERT_TYPE_STR[ALERT_TYPES.DISK_USAGE_ALERT.ordinal()] + " [85% used] in disk [server1:sda]"); + Alert alert = new Alert(); + alert.copyFrom(fixture); + + assertEquals(fixture.getId(), alert.getId()); + assertEquals(fixture.getReference(), alert.getReference()); + assertEquals(fixture.getType(), alert.getType()); + assertEquals(fixture.getMessage(), alert.getMessage()); + assertNotNull(alert); + } + + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 10/17/11 3:32 PM + */ + @Before + public void setUp() + throws Exception { + // add additional set up code here + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 10/17/11 3:32 PM + */ + @After + public void tearDown() + throws Exception { + // Add additional tear down code here + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 10/17/11 3:32 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(AlertTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/BrickTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/BrickTest.java new file mode 100644 index 00000000..60cb7767 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/BrickTest.java @@ -0,0 +1,305 @@ +package org.gluster.storage.management.core.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * The class BrickTest contains tests for the class {@link Brick}. + * + * @generatedBy CodePro at 10/17/11 4:39 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class BrickTest { + /** + * Run the void copyFrom(Brick) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testCopyFrom_1() + throws Exception { + Brick fixture = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/songs"); + Brick newBrick = new Brick(); + newBrick.copyFrom(fixture); + + assertEquals(fixture.getServerName(), newBrick.getServerName()); + assertEquals(fixture.getBrickDirectory(), newBrick.getBrickDirectory()); + assertEquals(fixture.getStatus(), newBrick.getStatus()); + assertEquals(fixture.getQualifiedName(), newBrick.getQualifiedName()); + } + + /** + * Run the boolean equals(Object) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testEquals_1() + throws Exception { + Brick fixture = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/songs"); + Brick newBrick = new Brick(); + newBrick.copyFrom(fixture); + + boolean result = fixture.equals(newBrick); + assertTrue(result); + } + + /** + * Run the boolean equals(Object) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testEquals_2() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + Brick newBrick = new Brick(); + newBrick.copyFrom(fixture); + + boolean result = fixture.equals(newBrick); + assertTrue(result); + } + + /** + * Run the boolean equals(Object) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testEquals_3() + throws Exception { + Brick fixture = new Brick("", BRICK_STATUS.ONLINE, ""); + Brick newBrick = new Brick(); + newBrick.copyFrom(fixture); + + boolean result = fixture.equals(newBrick); + assertTrue(result); + } + + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testFilter_1() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String filterString = "Ser"; + boolean caseSensitive = true; + + boolean result = fixture.filter(filterString, caseSensitive); + assertTrue(result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testFilter_2() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String filterString = "ser"; + boolean caseSensitive = true; + + boolean result = fixture.filter(filterString, caseSensitive); + assertEquals(result, false); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testFilter_3() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String filterString = "Ser"; + boolean caseSensitive = false; + + boolean result = fixture.filter(filterString, caseSensitive); + assertTrue(result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testFilter_4() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.ONLINE, "/md1/test"); + + String filterString = "ser"; + boolean caseSensitive = false; + + boolean result = fixture.filter(filterString, caseSensitive); + assertTrue(result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testFilter_5() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String filterString = ""; + boolean caseSensitive = false; + + boolean result = fixture.filter(filterString, caseSensitive); + assertTrue(result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testFilter_6() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String filterString = ""; + boolean caseSensitive = true; + + boolean result = fixture.filter(filterString, caseSensitive); + assertTrue(result); + } + + + /** + * Run the String getQualifiedName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testGetQualifiedName_1() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String result = fixture.getQualifiedName(); + + assertNotNull(result); + assertEquals(result, "Server2:/md1/test"); + } + + /** + * Run the String getQualifiedName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testGetQualifiedName_2() + throws Exception { + Brick fixture = new Brick("", BRICK_STATUS.OFFLINE, ""); + + String result = fixture.getQualifiedName(); + + assertNotNull(result); + assertEquals(result, ":"); + } + + + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Test + public void testToString_1() + throws Exception { + Brick fixture = new Brick("Server2", BRICK_STATUS.OFFLINE, "/md1/test"); + + String result = fixture.toString(); + + assertNotNull(result); + assertEquals(result, "Server2:/md1/test"); + } + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @Before + public void setUp() + throws Exception { + // add additional set up code here + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + @After + public void tearDown() + throws Exception { + // Add additional tear down code here + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 10/17/11 4:39 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(BrickTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/ClusterTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/ClusterTest.java new file mode 100644 index 00000000..3b4e6f72 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/ClusterTest.java @@ -0,0 +1,211 @@ +package org.gluster.storage.management.core.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Cluster; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.model.Device.DEVICE_TYPE; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * The class ClusterTest contains tests for the class {@link Cluster}. + * + * @generatedBy CodePro at 10/18/11 2:53 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class ClusterTest { + private Cluster fixture; + + public List getDisks(Server server) { + List disks = new ArrayList(); + disks.add(new Disk(server, "sda", "", 12456.0, 0.0, DEVICE_STATUS.UNINITIALIZED)); + Disk disk = new Disk(server, "sdb1", "/export", 134342456.0, 120343.0, DEVICE_STATUS.INITIALIZED); + disk.setType(DEVICE_TYPE.DATA); + disks.add(disk); + disk = new Disk(server, "sdc2", "/export", 876534346.0, 56334.0, DEVICE_STATUS.INITIALIZED); + disk.setType(DEVICE_TYPE.DATA); + disks.add(disk); + return disks; + } + + public List getServers() { + List servers = new ArrayList(); + GlusterServer server1 = new GlusterServer("Server1", null, SERVER_STATUS.ONLINE, 2, 10, 8, 4); + server1.addDisks(getDisks(server1)); + servers.add(server1); + + GlusterServer server2 = new GlusterServer("Server2", null, SERVER_STATUS.ONLINE, 1, 90, 10, 9); + server2.addDisks(getDisks(server2)); + servers.add(server2); + + GlusterServer server3 = new GlusterServer("Server3", null, SERVER_STATUS.ONLINE, 4, 50, 6, 5); + server3.addDisks(getDisks(server3)); + servers.add(server3); + + GlusterServer server4 = new GlusterServer("Server4", null, SERVER_STATUS.ONLINE, 2, 40, 4, 3); + server4.addDisks(getDisks(server4)); + servers.add(server4); + + return servers; + } + + public List getBricks(String volumeName) { + List bricks = new ArrayList(); + Brick brick1 = new Brick("Server1", BRICK_STATUS.ONLINE, "/sda1/"+volumeName); + bricks.add(brick1); + Brick brick2 = new Brick("Server2", BRICK_STATUS.ONLINE, "/sdb1/"+volumeName); + bricks.add(brick2); + Brick brick3 = new Brick("Server3", BRICK_STATUS.ONLINE, "/sdc1/"+volumeName); + bricks.add(brick3); + Brick brick4 = new Brick("Server4", BRICK_STATUS.OFFLINE, "/sda2/"+volumeName); + bricks.add(brick4); + return bricks; + } + + + public void populateVolumes(Cluster cluster) { + Volume volume1 = new Volume("Songs", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.ONLINE); + volume1.addBricks(getBricks(volume1.getName())); + cluster.addVolume(volume1); + + Volume volume2 = new Volume("Movie", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.ONLINE); + volume2.addBricks(getBricks(volume1.getName())); + cluster.addVolume(volume2); + + Volume volume3 = new Volume("graphics", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.INFINIBAND, + VOLUME_STATUS.ONLINE); + volume3.addBricks(getBricks(volume1.getName())); + cluster.addVolume(volume3); + + Volume volume4 = new Volume("cartoon", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.ONLINE); + volume4.addBricks(getBricks(volume1.getName())); + cluster.addVolume(volume4); + return; + } + + /** + * Run the double getDiskSpaceInUse() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + @Test + public void testGetDiskSpaceInUse_1() + throws Exception { + double result = fixture.getDiskSpaceInUse(); + + assertEquals(706708.0, result, 0.1); + } + + /** + * Run the GlusterServer getServer(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + @Test + public void testGetServer_1() + throws Exception { + GlusterServer result = fixture.getServer("Server1"); + + assertNotNull(result); + assertEquals("Server1", result.getName()); + assertEquals(2, result.getNumOfCPUs()); + assertEquals(3, result.getNumOfDisks() ); + } + + /** + * Run the double getTotalDiskSpace() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + @Test + public void testGetTotalDiskSpace_1() + throws Exception { + double result = fixture.getTotalDiskSpace(); + assertEquals(4043557032.0, result, 0.1); // Including unformatted disks(!) + } + + /** + * Run the double getTotalDiskSpace() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + @Test + public void testGetVolume_1() + throws Exception { + populateVolumes(fixture); + Volume result = fixture.getVolume("Songs"); + assertNotNull(result); + assertTrue(result instanceof Volume); + } + + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + @Before + public void setUp() + throws Exception { + fixture = new Cluster(); + fixture.setServers(getServers()); + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + @After + public void tearDown() + throws Exception { + // Add additional tear down code here + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 10/18/11 2:53 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(ClusterTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/DiskTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/DiskTest.java new file mode 100644 index 00000000..0187eb87 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/DiskTest.java @@ -0,0 +1,487 @@ +package org.gluster.storage.management.core.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.Collection; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.gluster.storage.management.core.model.Device; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.model.Device.DEVICE_TYPE; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * The class DiskTest contains tests for the class {@link Disk}. + * + * @generatedBy CodePro at 10/19/11 6:26 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class DiskTest { + private Disk disk; + + /** + * Run the Disk() constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testDisk_1() + throws Exception { + + // add additional test code here + assertNotNull(disk); + assertEquals(new Double(5000.0), disk.getSpace()); + assertEquals("Hitachi HTS72323 ATA", disk.getDescription()); + assertEquals(true, disk.isReady()); + assertEquals(null, disk.getDiskInterface()); + assertEquals(null, disk.getRaidDisks()); + assertEquals(false, disk.hasPartitions()); + assertEquals(new Double(3000.0), disk.getSpaceInUse()); + assertEquals(DEVICE_TYPE.DATA, disk.getType()); + assertEquals(new Double(2000.0), disk.getFreeSpace()); + assertEquals(DEVICE_STATUS.INITIALIZED, disk.getStatus()); + assertEquals("Server1:sda1", disk.getQualifiedName()); + assertEquals(true, disk.isInitialized()); + assertEquals(false, disk.hasErrors()); + assertEquals("Server1", disk.getServerName()); + assertEquals("Available", disk.getStatusStr()); + assertEquals(false, disk.isUninitialized()); + assertEquals("/md0/sda1", disk.getMountPoint()); + assertEquals("ext4", disk.getFsType()); + assertEquals("3.2.3", disk.getFsVersion()); + assertEquals("sda1", disk.toString()); + assertEquals("sda1", disk.getName()); + assertTrue(disk.getParent() instanceof Server); + } + + /** + * Run the Disk(Server,String,String,Double,Double,DEVICE_STATUS) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testDisk_2() + throws Exception { + Server server = new Server(); + String name = ""; + String mountPoint = ""; + Double space = new Double(1.0); + Double spaceInUse = new Double(1.0); + Device.DEVICE_STATUS status = Device.DEVICE_STATUS.INITIALIZED; + + Disk newDisk = new Disk(server, name, mountPoint, space, spaceInUse, status); + + // add additional test code here + assertNotNull(newDisk); + assertEquals(new Double(1.0), newDisk.getSpace()); + assertEquals(null, newDisk.getDescription()); + assertEquals(false, newDisk.isReady()); + assertEquals(null, newDisk.getDiskInterface()); + assertEquals(null, newDisk.getRaidDisks()); + assertEquals(false, newDisk.hasPartitions()); + assertEquals(new Double(1.0), newDisk.getSpaceInUse()); + assertEquals(null, newDisk.getType()); + assertEquals(new Double(0.0), newDisk.getFreeSpace()); + assertEquals("null:", newDisk.getQualifiedName()); + assertEquals(true, newDisk.isInitialized()); + assertEquals(false, newDisk.hasErrors()); + assertEquals(null, newDisk.getServerName()); + assertEquals("Initialized", newDisk.getStatusStr()); + assertEquals(false, newDisk.isUninitialized()); + assertEquals("", newDisk.getMountPoint()); + assertEquals(null, newDisk.getFsType()); + assertEquals(null, newDisk.getFsVersion()); + assertEquals("", newDisk.toString()); + assertEquals("", newDisk.getName()); + } + + /** + * Run the void copyFrom(Disk) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testCopyFrom_1() + throws Exception { + Disk newDisk = new Disk(); + newDisk.copyFrom(disk); + + assertEquals(newDisk.getSpace(), disk.getSpace()); + assertEquals(newDisk.getDescription(), disk.getDescription()); + assertEquals(newDisk.isReady(), disk.isReady()); + assertEquals(newDisk.getDiskInterface(), disk.getDiskInterface()); + assertEquals(newDisk.getRaidDisks(), disk.getRaidDisks()); + assertEquals(newDisk.hasPartitions(), disk.hasPartitions()); + assertEquals(newDisk.getSpaceInUse(), disk.getSpaceInUse()); + assertEquals(newDisk.getType(), disk.getType()); + assertEquals(newDisk.getFreeSpace(), disk.getFreeSpace()); + assertEquals(newDisk.getStatus(), disk.getStatus()); + assertEquals(newDisk.getQualifiedName(), disk.getQualifiedName()); + assertEquals(newDisk.isInitialized(), disk.isInitialized()); + assertEquals(newDisk.hasErrors(), disk.hasErrors()); + assertEquals(newDisk.getServerName(), disk.getServerName()); + assertEquals(newDisk.getStatusStr(), disk.getStatusStr()); + assertEquals(newDisk.isUninitialized(), disk.isUninitialized()); + assertEquals(newDisk.getMountPoint(), disk.getMountPoint()); + assertEquals(newDisk.getFsType(), disk.getFsType()); + assertEquals(newDisk.getFsVersion(), disk.getFsVersion()); + assertEquals(newDisk.toString(), disk.toString()); + assertEquals(newDisk.getName(), disk.getName()); + assertEquals(newDisk.getParent(), disk.getParent()); + } + + /** + * Run the boolean equals(Object) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testEquals_1() + throws Exception { + + Disk newDisk = new Disk(); + newDisk.copyFrom(disk); + boolean result = newDisk.equals(disk); + + assertTrue(result); + } + + /** + * Run the boolean equals(Object) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testEquals_2() + throws Exception { + Server server = new Server(); + String name = ""; + String mountPoint = ""; + Double space = new Double(1.0); + Double spaceInUse = new Double(1.0); + Device.DEVICE_STATUS status = Device.DEVICE_STATUS.INITIALIZED; + Disk newDisk = new Disk(server, name, mountPoint, space, spaceInUse, status); + + boolean result = newDisk.equals(disk); + + assertTrue(!result); + } + + /** + * Run the boolean equals(Object) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testEquals_3() + throws Exception { + + Disk newDisk = new Disk(); + newDisk.copyFrom(disk); + boolean result = newDisk.equals(disk); + + assertTrue(result); + } + + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testFilter_1() + throws Exception { + String filterString = ""; + boolean caseSensitive = true; + boolean result = disk.filter(filterString, caseSensitive); + + assertTrue(result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testFilter_2() + throws Exception { + String filterString = "Serv"; + boolean caseSensitive = true; + boolean result = disk.filter(filterString, caseSensitive); + + assertTrue(result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testFilter_3() + throws Exception { + String filterString = "serv"; + boolean caseSensitive = true; + boolean result = disk.filter(filterString, caseSensitive); + assertTrue(!result); + } + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testFilter_4() + throws Exception { + String filterString = "hitachi"; + boolean caseSensitive = true; + + boolean result = disk.filter(filterString, caseSensitive); + assertTrue(!result); + } + + + + /** + * Run the boolean filter(String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testFilter_5() + throws Exception { + String filterString = "hitachi"; + boolean caseSensitive = false; + + boolean result = disk.filter(filterString, caseSensitive); + assertTrue(result); + } + + + /** + * Run the Double getSpace() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testGetSpace_1() + throws Exception { + Double result = disk.getSpace(); + assertNotNull(result); + assertTrue(result instanceof Double); + } + + + + /** + * Run the Double getSpaceInUse() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testGetSpaceInUse_1() + throws Exception { + Double result = disk.getSpaceInUse(); + assertNotNull(result); + assertTrue(result instanceof Double); + } + + + /** + * Run the boolean hasPartitions() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testHasPartitions_1() + throws Exception { + disk.setPartitions(new ArrayList()); + boolean result = disk.hasPartitions(); + assertTrue(!result); + } + + + + /** + * Run the boolean isReady() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testIsReady_1() + throws Exception { + boolean result = disk.isReady(); + System.out.println("Disk status is [" + result + "] on [" + disk.getName() +"] and Status is [" + disk.getStatusStr() +"]"); + assertTrue(result); + } + + /** + * Run the boolean isReady() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testIsReady_2() + throws Exception { + disk.setPartitions(new ArrayList()); + boolean result = disk.isReady(); + assertTrue(result); + } + + /** + * Run the boolean isReady() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testIsReady_3() + throws Exception { + disk.setStatus(DEVICE_STATUS.UNINITIALIZED); + boolean result = disk.isReady(); + assertTrue(!result); + } + + /** + * Run the boolean isReady() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testIsReady_4() + throws Exception { + disk.setStatus(DEVICE_STATUS.IO_ERROR); + boolean result = disk.isReady(); + + assertTrue(!result); + } + + /** + * Run the boolean isReady() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testIsReady_5() + throws Exception { + disk.setStatus(DEVICE_STATUS.INITIALIZING); + boolean result = disk.isReady(); + + assertTrue(!result); + } + + /** + * Run the boolean isReady() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Test + public void testIsReady_6() + throws Exception { + disk.setStatus(DEVICE_STATUS.UNKNOWN); + boolean result = disk.isReady(); + + assertTrue(!result); + } + + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @Before + public void setUp() + throws Exception { + Server server = new Server("Server1", null, 2, 25D, 5000D, 2000D); + disk = new Disk(server,"sda1", "/md0/sda1", 5000D, 3000D, DEVICE_STATUS.INITIALIZED); + disk.setDescription("Hitachi HTS72323 ATA"); + disk.setFsType("ext4"); + disk.setFsVersion("3.2.3"); + disk.setType(DEVICE_TYPE.DATA); + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + @After + public void tearDown() + throws Exception { + // Add additional tear down code here + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(DiskTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/TestAll.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/TestAll.java new file mode 100644 index 00000000..2df91d09 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/model/TestAll.java @@ -0,0 +1,35 @@ +package org.gluster.storage.management.core.model; + +import org.junit.runner.JUnitCore; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * The class TestAll builds a suite that can be used to run all + * of the tests within its package as well as within any subpackages of its + * package. + * + * @generatedBy CodePro at 10/19/11 6:26 PM + * @author root + * @version $Revision: 1.0 $ + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + BrickTest.class, + ClusterTest.class, + AlertTest.class, + DiskTest.class, +}) +public class TestAll { + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 10/19/11 6:26 PM + */ + public static void main(String[] args) { + JUnitCore.runClasses(new Class[] { TestAll.class }); + } +} diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/DateUtilTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/DateUtilTest.java new file mode 100644 index 00000000..df782b00 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/DateUtilTest.java @@ -0,0 +1,218 @@ +package org.gluster.storage.management.core.utils; + +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.utils.DateUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * The class DateUtilTest contains tests for the class {@link DateUtil}. + * + * @generatedBy CodePro at 9/27/11 12:31 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class DateUtilTest { + + private Date date = DateUtil.getDate(2011, 9, 29, 11, 17, 38, 10); + + /** + * Run the String dateToString(Date) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testDateToString_1() + throws Exception { + String result = DateUtil.dateToString(date); + + assertEquals("09/29/2011 11:17:38", result); + } + + /** + * Run the String dateToString(Date,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testDateToString_2() + throws Exception { + String dateFormat = ""; + + String result = DateUtil.dateToString(date, dateFormat); + assertEquals("", result); + } + + /** + * Run the String dateToString(Date,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testDateToString_3() + throws Exception { + String dateFormat = CoreConstants.PURE_DATE_FORMAT; + + String result = DateUtil.dateToString(date, dateFormat); + assertEquals("09/29/2011", result); + } + + /** + * Run the String formatDate(Date) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testFormatDate_1() + throws Exception { + String result = DateUtil.formatDate(date); + + assertEquals("09/29/2011", result); + } + + /** + * Run the String formatDate(Date) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testFormatDate_2() + throws Exception { + Date date1 = DateUtil.getDate(1965, 1, 12, 0, 0, 0, 0); + String result = DateUtil.formatDate(date1); + assertEquals("01/12/1965", result); + } + + /** + * Run the String formatTime(Date) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testFormatTime_1() + throws Exception { + String result = DateUtil.formatTime(date); + + // add additional test code here + assertEquals("11:17:38.010", result); + } + + /** + * Run the Date stringToDate(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test(expected=GlusterRuntimeException.class) + public void testStringToDate_1() + throws Exception { + DateUtil.stringToDate(""); + } + + /** + * Run the Date stringToDate(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test(expected=GlusterRuntimeException.class) + public void testStringToDate_2() + throws Exception { + String testDate = "09/29/2011"; + DateUtil.stringToDate(testDate); + } + + /** + * Run the Date stringToDate(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test + public void testStringToDate_3() + throws Exception { + String dateFormat = "MM/dd/yyyy"; + String input = "09/29/2011"; // MM/dd/yyyy HH:mm:ss + Date expectedDate = DateUtil.getDate(2011, 9, 29, 0, 0, 0, 0); + + Date result = DateUtil.stringToDate(input, dateFormat); + assertEquals(expectedDate, result); + } + + /** + * Run the Date stringToDate(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Test(expected = GlusterRuntimeException.class) + public void testStringToDate_4() + throws Exception { + String inputDate = ""; + String dateFormat = ""; + + DateUtil.stringToDate(inputDate, dateFormat); + } + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @Before + public void setUp() + throws Exception { + // add additional set up code here + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + @After + public void tearDown() + throws Exception { + // Add additional tear down code here + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 9/27/11 12:31 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(DateUtilTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/FileUtilTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/FileUtilTest.java new file mode 100644 index 00000000..db3dd177 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/FileUtilTest.java @@ -0,0 +1,482 @@ +package org.gluster.storage.management.core.utils; + +import static org.junit.Assert.*; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.utils.FileUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + + +/** + * The class FileUtilTest contains tests for the class {@link FileUtil}. + * + * @generatedBy CodePro at 9/29/11 2:39 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class FileUtilTest { + + + private static final String TEST_FILE_PATH = FileUtil.getTempDirName() + "/test.txt"; + private static final String TEST_FILE_CONTENT = "Welcome to Gluster Storage Management console."; + + + /** + * To write the text into given file. + * + * @generatedBy + */ + private boolean writeToFile(String fileName, String text) { + try { + Writer output = null; + File file = new File(fileName); + output = new BufferedWriter(new FileWriter(file)); + output.write(text); + output.close(); + return true; + } catch (Exception e) { + return false; + } + } + + private boolean createNestedDir(String path) { + File file = new File(path); + return file.mkdirs(); + } + + private boolean createEmptyFile(String fileName) { + File file = new File(fileName); + if (file.exists()) { + return true; + } + + try { + return file.createNewFile(); + } catch (IOException e) { + return false; + } + } + + /** + * Run the File createTempDir() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testCreateTempDir_1() + throws Exception { + + File result = FileUtil.createTempDir(); + + assertNotNull(result); + assertTrue(File.class.equals(result.getClass())); + } + + /** + * Run the File createTempDir() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testCreateTempDir_2() + throws Exception { + + File result1 = FileUtil.createTempDir(); + File result2 = FileUtil.createTempDir(); + + assertNotSame(result1, result2); + } + + + /** + * Run the void createTextFile(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test(expected=GlusterRuntimeException.class) + public void testCreateTextFile_1() + throws Exception { + String fileName = ""; + String contents = ""; + FileUtil.createTextFile(fileName, contents); + } + + /** + * Run the String getTempDirName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testGetTempDirName_1() + throws Exception { + String result = FileUtil.getTempDirName(); + + // while running on linux + assertEquals("/tmp", result); + } + + /** + * Run the byte[] readFileAsByteArray(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + + @Test(expected=GlusterRuntimeException.class) + public void testReadFileAsByteArray_1() + throws Exception { + File file = new File(""); + + byte[] result = FileUtil.readFileAsByteArray(file); + } + + /** + * Run the byte[] readFileAsByteArray(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testReadFileAsByteArray_2() + throws Exception { + File file = new File(TEST_FILE_PATH); + + byte[] result = FileUtil.readFileAsByteArray(file); + assertNotNull(result); + assertTrue(result instanceof byte[]); + assertTrue(TEST_FILE_CONTENT.equals(new String(result))); + } + + + /** + * Run the String readFileAsString(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + + @Test(expected=GlusterRuntimeException.class) + public void testReadFileAsString_1() + throws Exception { + File file = new File(""); + + FileUtil.readFileAsString(file); + } + + + /** + * Run the String readFileAsString(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testReadFileAsString_2() + throws Exception { + File file = new File(TEST_FILE_PATH); + String result = FileUtil.readFileAsString(file); + + assertNotNull(result); + assertTrue(result instanceof String); + assertTrue(result.equals(TEST_FILE_CONTENT)); + } + + /** + * Run the void recursiveDelete(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testRecursiveDelete_1() + throws Exception { + + //Delete empty directories recursively + File fileOrDir = new File(FileUtil.getTempDirName() + "/rd"); + + FileUtil.recursiveDelete(fileOrDir); + assertTrue(!fileOrDir.exists()); + } + + /** + * Run the void recursiveDelete(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + + @Test(expected=GlusterRuntimeException.class) + public void testRecursiveDelete_2() + throws Exception { + //Delete directories recursively (with some files) + File fileOrDir = new File(FileUtil.getTempDirName() + "/rdx"); + + FileUtil.recursiveDelete(fileOrDir); + assertTrue(!fileOrDir.exists()); + } + + /** + * Run the void recursiveDelete(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testRecursiveDelete_3() + throws Exception { + File fileOrDir = new File(FileUtil.getTempDirName() + "/rd"); + FileUtil.recursiveDelete(fileOrDir); + assertTrue(!fileOrDir.exists()); + } + + /** + * Run the void recursiveDelete(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testRecursiveDelete_4() + throws Exception { + File file = new File(FileUtil.getTempDirName() + "/rd/b/bc/mydoc.txt"); + assertTrue(!file.exists()); + + file = new File(FileUtil.getTempDirName() + "/rd//b/bc"); + assertTrue(!file.exists()); + } + + /** + * Run the void recursiveDelete(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test(expected=GlusterRuntimeException.class) + public void testRecursiveDelete_5() + throws Exception { + File fileOrDir = new File(FileUtil.getTempDirName() + "/rd/*"); //Wild cards + FileUtil.recursiveDelete(fileOrDir); + } + + + /** + * Run the void recursiveDelete(File) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test(expected=GlusterRuntimeException.class) + public void testRecursiveDelete_6() + throws Exception { + File fileOrDir = new File(FileUtil.getTempDirName() + "/abcxyz"); + FileUtil.recursiveDelete(fileOrDir); + } + + /** + * Run the void renameFile(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + + @Test(expected=GlusterRuntimeException.class) + public void testRenameFile_1() + throws Exception { + String fromPath = FileUtil.getTempDirName() + "/test.txt"; + new File(fromPath).createNewFile(); + String toPath = "~/abc.txt"; // Relative path + + FileUtil.renameFile(fromPath, toPath); + assertTrue(!new File(fromPath).exists()); + assertTrue(new File(toPath).exists()); + } + + /** + * Run the void renameFile(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Test + public void testRenameFile_2() + throws Exception { + String fromPath = FileUtil.getTempDirName() + "/test.txt"; + new File(fromPath).createNewFile(); + + String toPath = FileUtil.getTempDirName() + "/abc.txt"; // Absolute path example + FileUtil.renameFile(fromPath, toPath); + assertTrue(!new File(fromPath).exists()); + assertTrue(new File(toPath).exists()); + } + + @Test + public void testRenameFile_3() + throws Exception { + String fromPath = FileUtil.getTempDirName() + "/test.txt"; + new File(fromPath).createNewFile(); + + String toPath = FileUtil.getTempDirName() + "/renamefile.txt"; + FileUtil.renameFile(fromPath, toPath); + assertTrue(!new File(fromPath).exists()); + assertTrue(new File(toPath).exists()); + } + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @Before + public void setUp() + throws Exception { + + // testReadFileAsByteArray_2() + if (!writeToFile(TEST_FILE_PATH, TEST_FILE_CONTENT)) { + fail("Setup: Text file creation error!"); + } + + // testRecursiveDelete_1() + if (!createNestedDir(FileUtil.getTempDirName() + "/rd/b/c/d")) { + createEmptyFile(FileUtil.getTempDirName() + "/rd/b/mydoc.txt"); + createEmptyFile(FileUtil.getTempDirName() + "/rd/b/songs.mp3"); + createEmptyFile(FileUtil.getTempDirName() + "/rd/b/mysetup.cfg"); + + createEmptyFile(FileUtil.getTempDirName() + "/rd/b/bc/mydoc.txt"); + createEmptyFile(FileUtil.getTempDirName() + "/rd/songs.mp3"); + createEmptyFile(FileUtil.getTempDirName() + "/rd/b/bc/mysetup.cfg"); + + createEmptyFile(FileUtil.getTempDirName() + "/rd//b/mydoc.txt"); + createEmptyFile(FileUtil.getTempDirName() + "/rd/b/bc/songs.mp3"); + + } + + if (! createEmptyFile(FileUtil.getTempDirName() + "/renamefile.txt") ) { + fail("Failed to create file [/renamefile.txt]"); + } + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + @After + public void tearDown() + throws Exception { + File file = new File(TEST_FILE_PATH); + file.delete(); + file = new File(FileUtil.getTempDirName() + "/rd/b/c/d"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/rd/b/c"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/rd/b/mydoc.txt"); + if (file.exists()) { + file.delete(); + } + file = new File(FileUtil.getTempDirName() + "/rd/b/songs.mp3"); + if (file.exists()) { + file.delete(); + } + file = new File(FileUtil.getTempDirName() + "/rd/b/mysetup.cfg"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/rd/b/bc/mydoc.txt"); + if (file.exists()) { + file.delete(); + } + file = new File(FileUtil.getTempDirName() + "/rd/b/bc/mysetup.cfg"); + if (file.exists()) { + file.delete(); + } + file = new File(FileUtil.getTempDirName() + "/rd/b/bc/songs.mp3"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/rd/b/bc"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/rd/b"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/rd"); + if (file.exists()) { + file.delete(); + } + + file = new File(FileUtil.getTempDirName() + "/abc.txt"); + if (file.exists()) { + file.delete(); + } + file = new File("~/abc.txt"); + if (file.exists()) { + file.delete(); + } + file = new File(FileUtil.getTempDirName() + "/test.txt"); + if (file.exists()) { + file.delete(); + } + file = new File(FileUtil.getTempDirName() + "/renamefile.txt"); + if (file.exists()) { + file.delete(); + } + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 9/29/11 2:39 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(FileUtilTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/StringUtilTest.java b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/StringUtilTest.java new file mode 100644 index 00000000..d39723c4 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/org/gluster/storage/management/core/utils/StringUtilTest.java @@ -0,0 +1,310 @@ +package org.gluster.storage.management.core.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.gluster.storage.management.core.utils.StringUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + + +/** + * The class StringUtilTest contains tests for the class {@link StringUtil}. + * + * @generatedBy CodePro at 21/9/11 4:53 PM + * @author root + * @version $Revision: 1.0 $ + */ +public class StringUtilTest { + public enum Season { WINTER, SPRING, SUMMER, FALL }; + /** + * Run the String collectionToString(Collection,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testCollectionToString_1() + throws Exception { + List string = new ArrayList(); + string.add("test string"); + String delimiter = ""; + + String result = StringUtil.collectionToString(string, delimiter); + assertEquals("test string", result); + } + + /** + * Run the String collectionToString(Collection,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testCollectionToString_2() + throws Exception { + List string = new ArrayList(); + string.add("test string"); + string.add("welcome to world"); + String delimiter = "::"; + + String result = StringUtil.collectionToString(string, delimiter); + + assertEquals("test string::welcome to world", result); + } + + /** + * Run the String collectionToString(Collection,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testCollectionToString_3() + throws Exception { + List string = new ArrayList(); + string.add("test ## string"); + string.add("java world"); + String delimiter = "##"; + + String result = StringUtil.collectionToString(string, delimiter); + assertEquals("test ## string##java world", result); + } + + /** + * Run the String collectionToString(Collection,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testCollectionToString_4() + throws Exception { + List string = new ArrayList(); + String delimiter = ""; + + String result = StringUtil.collectionToString(string, delimiter); + assertEquals("", result); + } + + /** + * Run the List enumToArray(T[]) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testEnumToArray_1() + throws Exception { + + String[] expected = new String[] {"WINTER", "SPRING", "SUMMER", "FALL"}; + List result = StringUtil.enumToArray(Season.values()); + + assertNotNull(result); + assertEquals(4, result.size()); + } + + /** + * Run the List extractList(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testExtractList_1() + throws Exception { + String input = "This is test message"; + String delim = " "; + + List result = StringUtil.extractList(input, delim); + + assertNotNull(result); + assertEquals(4, result.size()); + } + + /** + * Run the List extractList(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testExtractList_2() + throws Exception { + String input = "welcome#to#java#world"; + String delim = "#"; + + List result = StringUtil.extractList(input, delim); + + assertNotNull(result); + assertEquals(4, result.size()); + } + + /** + * Run the List extractList(String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testExtractList_3() + throws Exception { + String input = "list$to%string"; + String delim = "%"; + + List result = StringUtil.extractList(input, delim); + + assertNotNull(result); + assertEquals(2, result.size()); + } + + /** + * Run the Map extractMap(String,String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testExtractMap_1() + throws Exception { + String input = "k1=v1,k2=v2,k3=v3"; + String majorDelim = ","; + String minorDelim = "="; + + Map result = StringUtil.extractMap(input, majorDelim, minorDelim); + + // add additional test code here + assertNotNull(result); + assertEquals(3, result.size()); + } + + /** + * Run the Map extractMap(String,String,String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testExtractMap_2() + throws Exception { + String input = "k1=>v1&k2=>v2&k3=>v3"; + String majorDelim = "&"; + String minorDelim = "=>"; + + Map result = StringUtil.extractMap(input, majorDelim, minorDelim); + + // add additional test code here + assertNotNull(result); + assertEquals(3, result.size()); + } + + /** + * Run the boolean filterString(String,String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testFilterString_1() + throws Exception { + String sourceString = "This is java program"; + String filterString = "Java"; + boolean caseSensitive = true; + + boolean result = StringUtil.filterString(sourceString, filterString, caseSensitive); + + assertEquals(false, result); + } + + /** + * Run the boolean filterString(String,String,boolean) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testFilterString_2() + throws Exception { + String sourceString = "This is java program"; + String filterString = "Java"; + boolean caseSensitive = false; + + boolean result = StringUtil.filterString(sourceString, filterString, caseSensitive); + + assertEquals(true, result); + } + + /** + * Run the String removeSpaces(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Test + public void testRemoveSpaces_1() + throws Exception { + String str = "this is test string"; + + String result = StringUtil.removeSpaces(str); + + // add additional test code here + assertEquals("thisisteststring", result); + } + + /** + * Perform pre-test initialization. + * + * @throws Exception + * if the initialization fails for some reason + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @Before + public void setUp() + throws Exception { + // add additional set up code here + } + + /** + * Perform post-test clean-up. + * + * @throws Exception + * if the clean-up fails for some reason + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + @After + public void tearDown() + throws Exception { + // Add additional tear down code here + } + + /** + * Launch the test. + * + * @param args the command line arguments + * + * @generatedBy CodePro at 21/9/11 4:53 PM + */ + public static void main(String[] args) { + new org.junit.runner.JUnitCore().run(StringUtilTest.class); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/junit/test/test.txt b/src/org.gluster.storage.management.core/junit/test/test.txt new file mode 100644 index 00000000..267ce144 --- /dev/null +++ b/src/org.gluster.storage.management.core/junit/test/test.txt @@ -0,0 +1 @@ +Test Resource \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/CoreConstants.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/CoreConstants.java new file mode 100644 index 00000000..c6806ce0 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/CoreConstants.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.constants; + + +/** + * + */ +public class CoreConstants { + public static final String NEWLINE = System.getProperty("line.separator"); + public static final String FILE_SEPARATOR = System.getProperty("file.separator"); + public static final String USER_HOME = System.getProperty("user.home"); + public static final String ENCODING_UTF8 = "UTF-8"; + public static final String ALL = "ALL"; + public static final String DATE_WITH_TIME_FORMAT = "MM/dd/yyyy HH:mm:ss"; + public static final String PURE_DATE_FORMAT = "MM/dd/yyyy"; + public static final String PURE_TIME_FORMAT = "HH:mm:ss.SSS"; + public static final String NA = "NA"; + public static final String DEFAULT_PASSWORD = "syst3m"; + public static final String OFFLINE = "OFFLINE"; + public static final String ONLINE = "ONLINE"; + public static final String UNKNOWN = "UNKNOWN"; + public static final String RUNNING_TASKS = "Tasks"; +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/GlusterConstants.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/GlusterConstants.java new file mode 100644 index 00000000..c5a8713d --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/GlusterConstants.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.constants; + +import java.util.List; + +import org.gluster.storage.management.core.utils.StringUtil; + + +/** + * + */ +public class GlusterConstants { + public enum VOLUME_LOG_LEVELS { + EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG, TRACE + }; + + public static final List VOLUME_LOG_LEVELS_ARR = StringUtil.enumToArray(VOLUME_LOG_LEVELS.values()); + public static final String FSTYPE_DEFAULT = "default"; + public static final String FSTYPE_EXT_3 = "ext3"; + public static final String FSTYPE_EXT_4 = "ext4"; + public static final String FSTYPE_XFS = "xfs"; + + public static final String ON = "on"; + public static final String OFF = "off"; + public static final String NONE = "none"; + + public static final String STATS_PERIOD_1DAY = "1d"; + public static final String STATS_PERIOD_1WEEK = "1w"; + public static final String STATS_PERIOD_1MONTH = "1m"; + public static final String STATS_PERIOD_1YEAR = "1y"; +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/RESTConstants.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/RESTConstants.java new file mode 100644 index 00000000..8d320fcc --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/constants/RESTConstants.java @@ -0,0 +1,125 @@ +/** + * RESTConstants.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.constants; + +/** + * All constants related to the Gluster REST server and client + */ +public class RESTConstants { + // REST Resource paths + public static final String RESOURCE_PATH_USERS = "/users"; + public static final String RESOURCE_PATH_CLUSTERS = "/clusters"; + public static final String RESOURCE_PATH_DISCOVERED_SERVERS = "/discoveredservers"; + public static final String RESOURCE_PATH_KEYS = "/keys"; + + // REST Resource names + public static final String RESOURCE_VOLUMES = "volumes"; + public static final String RESOURCE_DEFAULT_OPTIONS = "options"; + public static final String RESOURCE_OPTIONS = "options"; + public static final String RESOURCE_LOGS = "logs"; + public static final String RESOURCE_DOWNLOAD = "download"; + public static final String RESOURCE_BRICKS = "bricks"; + public static final String RESOURCE_DISKS = "disks"; + public static final String RESOURCE_ALERTS = "alerts"; + public static final String RESOURCE_SERVERS = "servers"; + public static final String RESOURCE_TASKS = "tasks"; + public static final String RESOURCE_KEYS = "keys"; + public static final String RESOURCE_STATISTICS = "statistics"; + public static final String RESOURCE_USERS = "users"; + public static final String RESOURCE_FSTYPES = "fstypes"; + + public static final String TASK_START = "start"; + public static final String TASK_PAUSE = "pause"; + public static final String TASK_RESUME = "resume"; + public static final String TASK_STOP = "stop"; + public static final String TASK_COMMIT = "commit"; + public static final String TASK_STATUS = "status"; + public static final String TASK_DELETE = "delete"; + public static final String TASK_LOG_ROTATE = "logRotate"; + public static final String TASK_REBALANCE_START = "rebalanceStart"; + public static final String TASK_REBALANCE_STATUS = "rebalanceStatus"; + public static final String TASK_REBALANCE_STOP = "rebalanceStop"; + + public static final String FORM_PARAM_VOLUME_NAME = "volumeName"; + public static final String FORM_PARAM_VOLUME_TYPE = "volumeType"; + public static final String FORM_PARAM_TRANSPORT_TYPE = "transportType"; + public static final String FORM_PARAM_REPLICA_COUNT = "replicaCount"; + public static final String FORM_PARAM_STRIPE_COUNT = "stripeCount"; + public static final String FORM_PARAM_BRICKS = "bricks"; + public static final String FORM_PARAM_ACCESS_PROTOCOLS = "accessProtocols"; + public static final String FORM_PARAM_VOLUME_OPTIONS = "options"; + public static final String FORM_PARAM_FSTYPE = "fsType"; + public static final String FORM_PARAM_CIFS_ENABLE = "enableCifs"; + public static final String FORM_PARAM_CIFS_USERS = "cifsUsers"; + public static final String FORM_PARAM_CIFS_CONFIG = "cifs-config"; + public static final String FORM_PARAM_LOG_ROTATE = "log-rotate"; + + public static final String FORM_PARAM_CLUSTER_NAME = "clusterName"; + public static final String FORM_PARAM_SERVER_NAME = "serverName"; + public static final String FORM_PARAM_DISKS = "disks"; + public static final String FORM_PARAM_OPERATION = "operation"; + public static final String FORM_PARAM_VALUE_STATUS = "status"; + public static final String FORM_PARAM_OPTION_KEY = "key"; + public static final String FORM_PARAM_OPTION_VALUE = "value"; + public static final String FORM_PARAM_SOURCE = "source"; + public static final String FORM_PARAM_TARGET = "target"; + public static final String FORM_PARAM_AUTO_COMMIT = "autoCommit"; + public static final String FORM_PARAM_FIX_LAYOUT = "fixLayout"; + public static final String FORM_PARAM_MIGRATE_DATA = "migrateData"; + public static final String FORM_PARAM_FORCED_DATA_MIGRATE = "forcedDataMigrate"; + public static final String FORM_PARAM_OLD_PASSWORD = "oldPassword"; + public static final String FORM_PARAM_NEW_PASSWORD = "newPassword"; + public static final String FORM_PARAM_FORCE = "force"; + public static final String FORM_PARAM_MOUNTPOINT = "mountPoint"; + + public static final String PATH_PARAM_FORMAT = "format"; + public static final String PATH_PARAM_VOLUME_NAME = "volumeName"; + public static final String PATH_PARAM_CLUSTER_NAME = "clusterName"; + public static final String PATH_PARAM_SERVER_NAME = "serverName"; + public static final String PATH_PARAM_TASK_ID = "taskId"; + public static final String PATH_PARAM_DISK_NAME = "diskName"; + public static final String PATH_PARAM_USER = "user"; + + public static final String QUERY_PARAM_BRICK_NAME = "brickName"; + public static final String QUERY_PARAM_DISKS = "disks"; + public static final String QUERY_PARAM_BRICKS = "bricks"; + public static final String QUERY_PARAM_LINE_COUNT = "lineCount"; + public static final String QUERY_PARAM_VOLUME_NAME = "volumeName"; + public static final String QUERY_PARAM_DELETE_OPTION = "deleteData"; + public static final String QUERY_PARAM_LOG_SEVERITY = "severity"; + public static final String QUERY_PARAM_FROM_TIMESTAMP = "fromTimeStamp"; + public static final String QUERY_PARAM_TO_TIMESTAMP = "toTimeStamp"; + public static final String QUERY_PARAM_DOWNLOAD = "download"; + public static final String QUERY_PARAM_SERVER_NAME = "serverName"; + public static final String QUERY_PARAM_DETAILS = "details"; + public static final String QUERY_PARAM_TYPE = "type"; + public static final String QUERY_PARAM_PERIOD = "period"; + public static final String QUERY_PARAM_INTERFACE = "interface"; + public static final String QUERY_PARAM_MAX_COUNT = "maxCount"; + public static final String QUERY_PARAM_NEXT_TO = "nextTo"; + + public static final String STATISTICS_TYPE_CPU = "cpu"; + public static final String STATISTICS_TYPE_NETWORK = "network"; + public static final String STATISTICS_TYPE_MEMORY = "memory"; + + public static final String FORMAT_XML = "xml"; + public static final String FORMAT_JSON = "json"; +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/ConnectionException.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/ConnectionException.java new file mode 100644 index 00000000..ac6f198c --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/ConnectionException.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.exceptions; + +/** + * + */ +public class ConnectionException extends GlusterRuntimeException { + + private static final long serialVersionUID = 1L; + + + public ConnectionException(String message) { + super(message); + } + + public ConnectionException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterRuntimeException.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterRuntimeException.java new file mode 100644 index 00000000..7d012644 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterRuntimeException.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.exceptions; + +public class GlusterRuntimeException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public GlusterRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + public GlusterRuntimeException(String message) { + super(message); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterValidationException.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterValidationException.java new file mode 100644 index 00000000..399106c7 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/exceptions/GlusterValidationException.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.exceptions; + +public class GlusterValidationException extends GlusterRuntimeException { + private static final long serialVersionUID = 1L; + + public GlusterValidationException(String message) { + super(message); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Alert.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Alert.java new file mode 100644 index 00000000..58a11049 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Alert.java @@ -0,0 +1,75 @@ +package org.gluster.storage.management.core.model; + +import org.eclipse.osgi.internal.signedcontent.Base64; + +public class Alert extends Entity { + + public enum ALERT_TYPES { + CPU_USAGE_ALERT, MEMORY_USAGE_ALERT, DISK_USAGE_ALERT, OFFLINE_VOLUME_BRICKS_ALERT, OFFLINE_SERVERS_ALERT, OFFLINE_VOLUME_ALERT + }; + + public static final String[] ALERT_TYPE_STR = { "High CPU Usage", "High Memory Usage", "Low Disk Space", + "Offline Brick", "Offline Server", "Offline Volume" }; + + // protected String id; + protected ALERT_TYPES type; + protected String reference; // [for server- "Server", for Disk- "Server:disk", for volume- "Volume:Server:disk"] + protected String message; + + public String getAlertType() { + return ALERT_TYPE_STR[type.ordinal()]; + } + + public Alert() { + } + + public Alert(ALERT_TYPES type, String reference, String Message) { + setType(type); + setReference(reference); + setMessage(Message); + setId(buildAlertId()); + } + + public String buildAlertId() { + return Base64.encode((getAlertType() + "-" + getReference()).getBytes()).toString(); + } + + public String getId() { + return getName(); + } + + public void setId(String id) { + setName(id); + } + + public ALERT_TYPES getType() { + return type; + } + + public void setType(ALERT_TYPES type) { + this.type = type; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public void copyFrom(Alert alert) { + this.setId(alert.getId()); + this.setReference(alert.getReference()); + this.setType(alert.getType()); + this.setMessage(alert.getMessage()); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Brick.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Brick.java new file mode 100644 index 00000000..2deaaccf --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Brick.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement +public class Brick extends Entity { + public enum BRICK_STATUS {ONLINE, OFFLINE}; + private String[] BRICK_STATUS_STR = {"Online", "Offline"}; + + private String serverName; + // private String deviceName; + private String brickDirectory; + private BRICK_STATUS status; + + public Brick() { + } + + @Override + @XmlTransient + public String getName() { + return getQualifiedName(); + } + + public BRICK_STATUS getStatus() { + return status; + } + + public String getStatusStr() { + return BRICK_STATUS_STR[getStatus().ordinal()]; + } + + public void setStatus(BRICK_STATUS status) { + this.status = status; + } + + public Brick(String serverName, BRICK_STATUS brickStatus, String brickDirectory) { + setServerName(serverName); + setStatus(brickStatus); + // setDeviceName(deviceName); + setBrickDirectory(brickDirectory); + } + + public void setServerName(String serverName) { + this.serverName = serverName; + } + + public String getServerName() { + return serverName; + } + + public void setBrickDirectory(String brickDirectory) { + this.brickDirectory = brickDirectory; + } + + public String getBrickDirectory() { + return brickDirectory; + } + +// public void setDeviceName(String deviceName) { +// this.deviceName = deviceName; +// } + +// public String getDeviceName() { +// return deviceName; +// } + + public String getQualifiedName() { + return serverName + ":" + brickDirectory; + } + + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getServerName() + getBrickDirectory() + getStatusStr(), filterString, + caseSensitive); + } + + @Override + public String toString() { + return getQualifiedName(); + } + + @Override + public boolean equals(Object obj) { + if(!(obj instanceof Brick)) { + return false; + } + + Brick brick = (Brick)obj; + if(getQualifiedName().equals(brick.getQualifiedName()) && getStatus() == brick.getStatus()) { + return true; + } + + return false; + } + + public void copyFrom(Brick newBrick) { + setServerName(newBrick.getServerName()); + setBrickDirectory(newBrick.getBrickDirectory()); + // setDeviceName(newBrick.getDeviceName()); + setStatus(newBrick.getStatus()); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Cluster.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Cluster.java new file mode 100644 index 00000000..ade82ea3 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Cluster.java @@ -0,0 +1,196 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="cluster") +public class Cluster extends Entity { + List servers = new ArrayList(); + List discoveredServers = new ArrayList(); + List volumes = new ArrayList(); + List taskInfoList = new ArrayList(); + List alerts = new ArrayList(); + ServerStats aggregatedCpuStats; + ServerStats aggregatedNetworkStats; + + public Cluster() { + } + + public List getServers() { + return servers; + } + + public void addServer(GlusterServer server) { + servers.add(server); + } + + public void removeServer(GlusterServer server) { + servers.remove(server); + } + + public void addDiscoveredServer(Server server) { + discoveredServers.add(server); + } + + public void removeDiscoveredServer(Server server) { + discoveredServers.remove(server); + } + + public void deleteVolume(Volume volume) { + volumes.remove(volume); + } + + public void setServers(List servers) { + this.servers = servers; + children.add(new EntityGroup("Servers", GlusterServer.class, this, servers)); + } + + public List getAutoDiscoveredServers() { + return discoveredServers; + } + + public void setAutoDiscoveredServers(List autoDiscoveredServers) { + this.discoveredServers = autoDiscoveredServers; + children.add(new EntityGroup("Discovered Servers", Server.class, this, autoDiscoveredServers)); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public EntityGroup getEntityGroup(Class type) { + for(Entity entity : getChildren()) { + if(entity instanceof EntityGroup && ((EntityGroup)entity).getEntityType() == type) { + return (EntityGroup)entity; + } + } + return null; + } + + public List getVolumes() { + return volumes; + } + + public void setVolumes(List volumes) { + this.volumes = volumes; + children.add(new EntityGroup("Volumes", Volume.class, this, volumes)); + } + + public void addVolume(Volume volume) { + this.volumes.add(volume); + } + + public void updateVolume(String volumeName, List bricks) { + Volume volume = getVolume(volumeName); + volume.setBricks(bricks); + } + + public Cluster(String name, Entity parent) { + super(name, parent); + } + + public Cluster(String name, Entity parent, List servers, List volumes) { + super(name, parent); + setServers(servers); + setVolumes(volumes); + } + + public List getTaskInfoList() { + return taskInfoList; + } + + public void setTaskInfoList(List taskInfoList) { + this.taskInfoList = taskInfoList; + } + + public void addTaskInfo(TaskInfo taskInfo) { + this.taskInfoList.add(taskInfo); + } + + public void removeTaskInfo(TaskInfo taskInfo) { + this.taskInfoList.remove(taskInfo); + } + + public List getAlerts() { + return alerts; + } + + public void setAlerts(List alerts) { + this.alerts = alerts; + } + + public void addAlert(Alert alert) { + this.alerts.add(alert); + } + + public void removeAlert(Alert alert) { + this.alerts.remove(alert); + } + + public double getTotalDiskSpace() { + double totalDiskSpace = 0; + for(GlusterServer server : getServers()) { + totalDiskSpace += server.getTotalDiskSpace(); + } + return totalDiskSpace; + } + + public double getDiskSpaceInUse() { + double diskSpaceInUse = 0; + for(GlusterServer server : getServers()) { + diskSpaceInUse += server.getDiskSpaceInUse(); + } + return diskSpaceInUse; + } + + public GlusterServer getServer(String serverName) { + for(GlusterServer server : servers) { + if (server.getName().equalsIgnoreCase(serverName) || server.getIpAddressesAsString().contains(serverName)) { + return server; + } + } + return null; + } + + public Volume getVolume(String volumeName) { + for (Volume volume : getVolumes() ) { + if (volume.getName().equals(volumeName)) { + return volume; + } + } + return null; + } + + public ServerStats getAggregatedCpuStats() { + return aggregatedCpuStats; + } + + public void setAggregatedCpuStats(ServerStats aggregatedCpuStats) { + this.aggregatedCpuStats = aggregatedCpuStats; + } + + public ServerStats getAggregatedNetworkStats() { + return aggregatedNetworkStats; + } + + public void setAggregatedNetworkStats(ServerStats aggregatedNetworkStats) { + this.aggregatedNetworkStats = aggregatedNetworkStats; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ClusterListener.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ClusterListener.java new file mode 100644 index 00000000..f13cb7c6 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ClusterListener.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +/** + * Interface for a cluster listener. Every registered listener will be notified + * on various events happening on the cluster. + */ +public interface ClusterListener { + public void discoveredServerAdded(Server server); + + public void discoveredServerRemoved(Server server); + + public void discoveredServerChanged(Server server, Event event); + + public void serverAdded(GlusterServer server); + + public void serverRemoved(GlusterServer server); + + public void serverChanged(GlusterServer server, Event event); + + public void volumeChanged(Volume volume, Event event); + + public void volumeCreated(Volume volume); + + public void volumeDeleted(Volume volume); + + public void taskAdded(TaskInfo taskInfo); + + public void taskRemoved(TaskInfo taskInfo); + + public void taskUpdated(TaskInfo taskInfo); + + public void alertsGenerated(); + + public void aggregatedStatsChanged(); + + public void alertRemoved(Alert alert); + + public void alertCreated(Alert alert); +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ConnectionDetails.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ConnectionDetails.java new file mode 100644 index 00000000..f0fbb852 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ConnectionDetails.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +/** + * Class used for binding UI fields on login / password-change dialog boxes + */ +public class ConnectionDetails { + private String userId, password, newPassword, confirmNewPassword; + + public ConnectionDetails() { + + } + + public ConnectionDetails(String userId, String password) { + this.userId = userId; + this.password = password; + this.confirmNewPassword = ""; + } + + public String getUserId() { + return userId; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setNewPassword(String newPassword) { + this.newPassword = newPassword; + } + + public String getNewPassword() { + return newPassword; + } + + public void setConfirmNewPassword(String confirmNewPassword) { + this.confirmNewPassword = confirmNewPassword; + } + + public String getConfirmNewPassword() { + return confirmNewPassword; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/DefaultClusterListener.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/DefaultClusterListener.java new file mode 100644 index 00000000..593afb51 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/DefaultClusterListener.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +/** + * Default listener - doesn't do anything. Sub-class and override the method for + * the event you want to handle. + */ +public class DefaultClusterListener implements ClusterListener { + + @Override + public void serverAdded(GlusterServer server) { + modelChanged(); + } + + @Override + public void serverRemoved(GlusterServer server) { + modelChanged(); + } + + @Override + public void serverChanged(GlusterServer server, Event event) { + modelChanged(); + } + + @Override + public void volumeChanged(Volume volume, Event event) { + modelChanged(); + } + + @Override + public void discoveredServerAdded(Server server) { + modelChanged(); + } + + @Override + public void discoveredServerRemoved(Server server) { + modelChanged(); + } + + @Override + public void volumeCreated(Volume volume) { + modelChanged(); + } + + @Override + public void volumeDeleted(Volume volume) { + modelChanged(); + } + + + @Override + public void taskAdded(TaskInfo taskInfo) { + modelChanged(); + } + + + @Override + public void taskRemoved(TaskInfo taskInfo) { + modelChanged(); + } + + + @Override + public void taskUpdated(TaskInfo taskInfo) { + modelChanged(); + } + + /** + * This method is called by every other event method. Thus, if a view/listener is interested in performing the same + * task on any change happening in the data model, it can simply override this method and implement the + * logic. e.g. A view may simply refresh its tree/table viewer whenever the data model changes. + */ + public void modelChanged() { + + } + + @Override + public void discoveredServerChanged(Server server, Event event) { + modelChanged(); + } + + @Override + public void alertsGenerated() { + modelChanged(); + } + + @Override + public void aggregatedStatsChanged() { + modelChanged(); + } + + @Override + public void alertRemoved(Alert alert) { + modelChanged(); + } + + @Override + public void alertCreated(Alert alert) { + modelChanged(); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Device.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Device.java new file mode 100644 index 00000000..5619c4ae --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Device.java @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.gluster.storage.management.core.utils.StringUtil; + + + +/** + * + */ +public class Device extends Entity { + public enum DEVICE_STATUS { + //TODO: Status "READY" to be removed after python script is changed accordingly + INITIALIZED, UNINITIALIZED, INITIALIZING, IO_ERROR, UNKNOWN + }; + + public enum DEVICE_TYPE { + DATA, BOOT, SWAP, UNKNOWN + }; + + private static final String[] DEVICE_STATUS_STR = { "Initialized", "Uninitialized", "Initializing", "I/O Error", "Unknown" }; + private static final String[] DEVICE_TYPE_STR = { "Data", "Boot", "Swap", "Unknown" }; + + // type = data, boot, other + private DEVICE_TYPE type; + + private String fsType; + private String fsVersion; + + private String serverName; + private String mountPoint; + + private Double space = 0.0; + private Double spaceInUse = 0.0; + private DEVICE_STATUS status; + + public Device() { + } + + public Device(Server server, String name, String mountPoint, Double space, Double spaceInUse, DEVICE_STATUS status) { + super(name, server); + setServerName(server != null ? server.getName() : ""); + setMountPoint(mountPoint); + setSpace(space); + setSpaceInUse(spaceInUse); + setStatus(status); + } + + @XmlElement(name="size") + public Double getSpace() { + return space; + } + + public Double getFreeSpace() { + return (getSpace() - getSpaceInUse()); + } + + public void setSpace(Double space) { + this.space = space; + } + + public boolean isUninitialized() { + return getStatus() == DEVICE_STATUS.UNINITIALIZED; + } + + public boolean hasErrors() { + return getStatus() == DEVICE_STATUS.IO_ERROR; + } + + public boolean isInitialized() { + return getStatus() == DEVICE_STATUS.INITIALIZED; + } + + public boolean isReady() { + return (getStatus() == DEVICE_STATUS.INITIALIZED && getType() == DEVICE_TYPE.DATA); + } + + public DEVICE_STATUS getStatus() { + return status; + } + + public String getStatusStr() { + if (getStatus() == null) { + // Return as Unknown + return DEVICE_STATUS_STR[DEVICE_STATUS.UNKNOWN.ordinal()]; + } + + if(isReady()) { + return "Available"; + } + return DEVICE_STATUS_STR[getStatus().ordinal()]; + } + + public void setStatus(DEVICE_STATUS status) { + this.status = status; + } + + public Double getSpaceInUse() { + return spaceInUse; + } + + public void setSpaceInUse(Double spaceInUse) { + this.spaceInUse = spaceInUse; + } + + @XmlTransient + public String getServerName() { + return serverName; + } + + public void setServerName(String serverName) { + this.serverName = serverName; + } + + public void setMountPoint(String mountPoint) { + this.mountPoint = mountPoint; + } + + public String getMountPoint() { + return mountPoint; + } + + public DEVICE_TYPE getType() { + return type; + } + + public String getTypeStr() { + return DEVICE_TYPE_STR[type.ordinal()]; + } + + public void setType(DEVICE_TYPE diskType) { + this.type = diskType; + } + + public String getFsType() { + return fsType; + } + + public void setFsType(String fsType) { + this.fsType = fsType; + } + + public String getFsVersion() { + return fsVersion; + } + + public void setFsVersion(String fsVersion) { + this.fsVersion = fsVersion; + } + + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getServerName() + getName() + getStatusStr() + getSpace() + getFreeSpace() + + getType(), filterString, caseSensitive); + } + + public String getQualifiedName() { + return getServerName() + ":" + getName(); + } + + public String getQualifiedBrickName(String volumeName) { + return getServerName() + ":" + getMountPoint() + "/" + volumeName; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) { + return true; + } + + if(!(obj instanceof Device)) { + return false; + } + + Device device = (Device)obj; + + String oldMountPoint = (getMountPoint() == null ? "" : getMountPoint()); + String oldFsType = (getFsType() == null ? "" : getFsType()); + String oldFsVersion = (getFsVersion() == null ? "" : getFsVersion()); + + String newMountPoint = (device.getMountPoint() == null ? "" : getMountPoint()); + String newFsType = (device.getFsType() == null ? "" : getFsType()); + String newFsVersion = (device.getFsVersion() == null ? "" : getFsVersion()); + + if (getName().equals(device.getName()) && getServerName().equals(device.getServerName()) + && oldMountPoint.equals(newMountPoint) && getStatus() == device.getStatus() + && getSpace().equals(device.getSpace()) && getSpaceInUse().equals(device.getSpaceInUse()) + && oldFsType.equals(newFsType) && oldFsVersion.equals(newFsVersion) + && getType() == device.getType()) { + return true; + } + + return false; + } + + public void copyFrom(Device newDevice) { + setName(newDevice.getName()); + setParent(newDevice.getParent()); + setMountPoint(newDevice.getMountPoint()); + setServerName(newDevice.getServerName()); + setStatus(newDevice.getStatus()); + setFsType(newDevice.getFsType()); + setType(newDevice.getType()); + setFsVersion(newDevice.getFsVersion()); + setSpace(newDevice.getSpace()); + setSpaceInUse(newDevice.getSpaceInUse()); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Disk.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Disk.java new file mode 100644 index 00000000..854fe744 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Disk.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.Collection; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement(name="disk") +public class Disk extends Device { + private String description; + + // interface = pci, raid0, raid3, etc + private String diskInterface; + + private Collection partitions = new ArrayList(); + + // In case of a software raid, the disk will contain an array of other disks + private Collection raidDisks; + + public Disk() { + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + @XmlElement(name="interface") + public String getDiskInterface() { + return diskInterface; + } + + public void setDiskInterface(String diskInterface) { + this.diskInterface = diskInterface; + } + + @XmlElementWrapper(name="raidDisks") + @XmlElement(name="disk", type=Disk.class) + public Collection getRaidDisks() { + return raidDisks; + } + + public void setRaidDisks(Collection raidDisks) { + this.raidDisks = raidDisks; + } + + public void setPartitions(Collection partitions) { + this.partitions = partitions; + } + + @XmlElementWrapper(name="partitions") + @XmlElement(name="partition", type=Partition.class) + public Collection getPartitions() { + return partitions; + } + + public boolean hasPartitions() { + return (partitions != null && partitions.size() > 0); + } + + public Disk(Server server, String name, String mountPoint, Double space, Double spaceInUse, DEVICE_STATUS status) { + super(server, name, mountPoint, space, spaceInUse, status); + } + + @Override + public boolean filter(String filterString, boolean caseSensitive) { + if (StringUtil.filterString(getServerName() + getName() + getStatusStr() + getSpace() + getFreeSpace() + + getType() + getDescription(), filterString, caseSensitive)) { + return true; + } + + // disk doesn't match. check if any of the partitions of this disk match the filter + for(Partition partition : getPartitions()) { + if(partition.filter(filterString, caseSensitive)) { + return true; + } + } + + return false; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) { + return true; + } + + if(!(obj instanceof Disk)) { + return false; + } + + Disk disk = (Disk)obj; + + if (!(super.equals(obj) && getDescription().equals(disk.getDescription()) && (getDiskInterface() == disk.getDiskInterface() || getDiskInterface().equals( + disk.getDiskInterface()) ))) { + return false; + } + + if (raidDisks != null) { + for (Disk raidDisk : raidDisks) { + // check if the disk contains same raid disks + if (!(raidDisk.equals(GlusterCoreUtil.getEntity(disk.getRaidDisks(), raidDisk.getName(), false)))) { + return false; + } + } + } + +// // check if the disk contains same partitions +// if (partitions != null) { +// for (Partition partition : partitions) { +// if (!(partition.equals(GlusterCoreUtil.getEntity(disk.getPartitions(), partition.getName(), false)))) { +// return false; +// } +// } +// } + return true; + } + + public void copyFrom(Disk newDisk) { + super.copyFrom(newDisk); + setDescription(newDisk.getDescription()); + setDiskInterface(newDisk.getDiskInterface()); + setPartitions(newDisk.getPartitions()); + setRaidDisks(newDisk.getRaidDisks()); + } + + @Override + public boolean isReady() { + if (hasPartitions()) { + for (Partition partition : getPartitions()) { + if (partition.isReady()) { + return true; + } + } + return false; + } else { + return super.isReady(); + } + } + + @Override + public Double getSpace() { + Double space = 0d; + if (hasPartitions()) { + for (Partition partition : getPartitions()) { + space += partition.getSpace(); + } + return space; + } else { + return super.getSpace(); + } + } + + @Override + public Double getSpaceInUse() { + Double spaceInUse = 0d; + if (hasPartitions()) { + for (Partition partition : getPartitions()) { + if (partition.isInitialized()) { + spaceInUse += partition.getSpaceInUse(); + } + } + return spaceInUse; + } else { + return super.getSpaceInUse(); + } + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Entity.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Entity.java new file mode 100644 index 00000000..927bbac4 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Entity.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.eclipse.core.runtime.PlatformObject; +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement +public class Entity extends PlatformObject implements Filterable { + private static final long serialVersionUID = 1L; + + protected String name; + protected List children = new ArrayList(); + private Entity parent; + + public Entity() { + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlTransient + public Entity getParent() { + return parent; + } + + public void setParent(Entity parent) { + this.parent = parent; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public Entity(String name, Entity parent) { + this.name = name; + this.parent = parent; + } + + public Entity(String name, Entity parent, List children) { + this.name = name; + this.parent = parent; + this.children = children; + } + + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getName(), filterString, caseSensitive); + } + + @Override + public String toString() { + return name; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/EntityGroup.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/EntityGroup.java new file mode 100644 index 00000000..351e40e5 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/EntityGroup.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.List; + +public class EntityGroup extends Entity { + private Class type; + + public EntityGroup(String name, Class type, Cluster cluster) { + this(name, type, cluster, null); + } + + @SuppressWarnings("unchecked") + public EntityGroup(String name, Class type, Cluster cluster, List entities) { + super(name, cluster, (List)entities); + this.type = type; + } + + public List getEntities() { + return (List)children; + } + + public void setEntities(List entities) { + children = (List)entities; + } + + public Class getEntityType() { + return type; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Event.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Event.java new file mode 100644 index 00000000..085e1f66 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Event.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +public class Event { + public enum EVENT_TYPE { + BRICKS_ADDED, + BRICKS_REMOVED, + BRICKS_CHANGED, + VOLUME_STATUS_CHANGED, + ALERT_CREATED, + ALERT_REMOVED, + VOLUME_OPTIONS_RESET, + VOLUME_OPTION_SET, + VOLUME_CHANGED, + GLUSTER_SERVER_CHANGED, + DEVICES_ADDED, + DEVICES_REMOVED, + DEVICES_CHANGED, + DISCOVERED_SERVER_CHANGED + } + + private EVENT_TYPE eventType; + private Object eventData; + + public Event(EVENT_TYPE eventType, Object eventData) { + this.eventType = eventType; + this.eventData = eventData; + } + + public EVENT_TYPE getEventType() { + return eventType; + } + + public void setEventType(EVENT_TYPE eventType) { + this.eventType = eventType; + } + + public Object getEventData() { + return eventData; + } + + public void setEventData(Object eventData) { + this.eventData = eventData; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Filterable.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Filterable.java new file mode 100644 index 00000000..20243d17 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Filterable.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +/** + * By default, the {@link EntityViewerFilter} filters the objects by parsing the + * output of {@link Object#toString()} with the filter string. Classes that need + * specific filtering logic can implement this interface. The default logic will + * then be overridden by the method {@link Filterable#filter(String)}. + */ +public interface Filterable { + /** + * @param filterString + * String to be used for filtering + * @param caseSensitive + * Flag indicating whether the filtering should be case sensitive + * @return true if the object can be selected using the filter string, else + * false + */ + public boolean filter(String filterString, boolean caseSensitive); +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDataModel.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDataModel.java new file mode 100644 index 00000000..99b283c2 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDataModel.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +public class GlusterDataModel extends Entity { + public GlusterDataModel(String name, List clusters) { + super(name, null); + children.addAll(clusters); + } + + public GlusterDataModel(String name) { + this(name, new ArrayList()); + } + + public void setClusters(List clusters) { + children.clear(); + children.addAll(clusters); + } + + public void addCluster(Cluster cluster) { + children.add(cluster); + } + + public Cluster getCluster() { + return (Cluster) children.get(0); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDummyModel.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDummyModel.java new file mode 100644 index 00000000..1bb3ddab --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterDummyModel.java @@ -0,0 +1,252 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.gluster.storage.management.core.model.Device.DEVICE_STATUS; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; + + +public class GlusterDummyModel { + // private Server discoveredServer1, discoveredServer2, discoveredServer3, discoveredServer4, discoveredServer5; + private GlusterServer server1, server2, server3, server4, server5; + private Volume volume1, volume2, volume3, volume4, volume5; + private Disk s1da, s1db, s2da, s2db, s2dc, s2dd, s3da, s4da, s5da, s5db; + private static List logMessages = new ArrayList(); + private static GlusterDummyModel instance = new GlusterDummyModel(); + private GlusterDataModel model; + + private GlusterDummyModel() { + model = initializeModel(); + } + + public GlusterDataModel getModel() { + return model; + } + + public static GlusterDummyModel getInstance() { + return instance; + } + + // Renamed preferredInterfaceName to interfaceName + private GlusterServer addGlusterServer(List servers, Entity parent, String name, + SERVER_STATUS status, String interfaceName, int numOfCPUs, double cpuUsage, double totalMemory, + double memoryInUse) { + GlusterServer glusterServer = new GlusterServer(name, parent, status, numOfCPUs, cpuUsage, totalMemory, + memoryInUse); + NetworkInterface networkInterface = addNetworkInterface(glusterServer, interfaceName); + + servers.add(glusterServer); + return glusterServer; + } + + private NetworkInterface addNetworkInterface(Server server, String interfaceName) { + NetworkInterface networkInterface = new NetworkInterface(interfaceName, server, "00:00:00:00", "IPV6-IN-IPV4", + "1000MB/S", "192.168.1." + Math.round(Math.random() * 255), "255.255.255.0", "192.168.1.1"); + server.setNetworkInterfaces(Arrays.asList(new NetworkInterface[] { networkInterface })); + return networkInterface; + } + + private void addDiscoveredServer(List servers, Entity parent, String name, int numOfCPUs, double cpuUsage, + double totalMemory, double memoryInUse, double totalDiskSpace, double diskSpaceInUse) { + Server server = new Server(name, parent, numOfCPUs, cpuUsage, totalMemory, memoryInUse); + server.addDisk(new Disk(server, "sda", "/export/md0", totalDiskSpace, diskSpaceInUse, DEVICE_STATUS.INITIALIZED)); + addNetworkInterface(server, "eth0"); + + servers.add(server); + } + + private GlusterDataModel initializeModel() { + // Create the dummy data model for demo + GlusterDataModel model = new GlusterDataModel("Clusters"); + Cluster cluster = new Cluster("Home", model); + + initializeGlusterServers(cluster); + initializeVolumes(cluster); + initializeAutoDiscoveredServers(cluster); + initializeDisks(); + addDisksToServers(); + addVolumeOptions(); + + createDummyLogMessages(); + + model.addCluster(cluster); + return model; + } + + private void addVolumeOptions() { + for (Volume vol : new Volume[] { volume1, volume2, volume3, volume4, volume5 }) { + for (int i = 1; i <= 5; i++) { + String key = vol.getName() + "key" + i; + String value = vol.getName() + "value" + i; + vol.setOption(key, value); + } + } + } + + private Volume addVolume(List volumes, String name, Cluster cluster, VOLUME_TYPE volumeType, + TRANSPORT_TYPE transportType, VOLUME_STATUS status) { + Volume volume = new Volume(name, cluster, volumeType, transportType, status); + volumes.add(volume); + + return volume; + } + + private void initializeVolumes(Cluster cluster) { + List volumes = new ArrayList(); + + volume1 = addVolume(volumes, "Volume1", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.ONLINE); + + volume2 = addVolume(volumes, "Volume2", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.ONLINE); + + volume3 = addVolume(volumes, "Volume3", cluster, VOLUME_TYPE.DISTRIBUTED_REPLICATE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.OFFLINE); + volume3.setReplicaCount(2); + + volume4 = addVolume(volumes, "Volume4", cluster, VOLUME_TYPE.DISTRIBUTE, TRANSPORT_TYPE.ETHERNET, + VOLUME_STATUS.ONLINE); + + volume5 = addVolume(volumes, "Volume5", cluster, VOLUME_TYPE.DISTRIBUTED_STRIPE, TRANSPORT_TYPE.INFINIBAND, + VOLUME_STATUS.OFFLINE); + volume5.setStripeCount(3); + + cluster.setVolumes(volumes); + } + + private void initializeDisks() { + s1da = new Disk(server1, "sda", "/export/md0", 100d, 80d, DEVICE_STATUS.INITIALIZED); + s1db = new Disk(server1, "sdb", "/export/md1", 100d, 67.83, DEVICE_STATUS.INITIALIZED); + + s2da = new Disk(server2, "sda", "/export/md0", 200d, 157.12, DEVICE_STATUS.INITIALIZED); + s2db = new Disk(server2, "sdb", "/export/md1", 200d, 182.27, DEVICE_STATUS.INITIALIZED); + s2dc = new Disk(server2, "sdc", "/export/md0", 200d, -1d, DEVICE_STATUS.UNINITIALIZED); + s2dd = new Disk(server2, "sdd", "/export/md1", 200d, 124.89, DEVICE_STATUS.INITIALIZED); + + s4da = new Disk(server4, "sda", "/export/md0", 100d, 85.39, DEVICE_STATUS.INITIALIZED); + + s5da = new Disk(server5, "sda", "/export/md1", 100d, 92.83, DEVICE_STATUS.INITIALIZED); + s5db = new Disk(server5, "sdb", "/export/md1", 200d, 185.69, DEVICE_STATUS.INITIALIZED); + } + + private void addDisksToServers() { + server1.addDisk(s1da); + server1.addDisk(s1db); + + server2.addDisk(s2da); + server2.addDisk(s2db); + server2.addDisk(s2dc); + server2.addDisk(s2dd); + + // server3.addDisk(s3da); + + server4.addDisk(s4da); + + server5.addDisk(s5da); + server5.addDisk(s5db); + } + + private void initializeGlusterServers(Cluster cluster) { + List servers = new ArrayList(); + server1 = addGlusterServer(servers, cluster, "Server1", SERVER_STATUS.ONLINE, "eth0", 4, 56.3, 16, 8.4); + server2 = addGlusterServer(servers, cluster, "Server2", SERVER_STATUS.ONLINE, "eth1", 8, 41.92, 32, 18.76); + server3 = addGlusterServer(servers, cluster, "Server3", SERVER_STATUS.OFFLINE, "eth0", -1, -1, -1, -1); + server4 = addGlusterServer(servers, cluster, "Server4", SERVER_STATUS.ONLINE, "eth0", 1, 92.83, 4, 3.18); + server5 = addGlusterServer(servers, cluster, "Server5", SERVER_STATUS.ONLINE, "inf0", 2, 87.24, 8, 7.23); + + cluster.setServers(servers); + } + + private void initializeAutoDiscoveredServers(Cluster cluster) { + List servers = new ArrayList(); + addDiscoveredServer(servers, cluster, "ADServer1", 4, 56.3, 16, 8.4, 200, 147.83); + addDiscoveredServer(servers, cluster, "ADServer2", 8, 41.92, 32, 18.76, 800, 464.28); + addDiscoveredServer(servers, cluster, "ADServer3", 2, 84.28, 2, 1.41, 120, 69.93); + addDiscoveredServer(servers, cluster, "ADServer4", 1, 92.83, 4, 3.18, 100, 85.39); + addDiscoveredServer(servers, cluster, "ADServer5", 2, 87.24, 8, 7.23, 250, 238.52); + cluster.setAutoDiscoveredServers(servers); + } + + private void addMessages(List messages, Disk disk, String severity, int count) { + for (int i = 1; i <= count; i++) { + String message = severity + "message" + i; + messages.add(new VolumeLogMessage(new Date(), disk.getMountPoint(), severity, message)); + } + } + + private void addMessagesForDisk(List logMessages, Disk disk) { + addMessages(logMessages, disk, "SEVERE", 5); + addMessages(logMessages, disk, "WARNING", 5); + addMessages(logMessages, disk, "DEBUG", 5); + addMessages(logMessages, disk, "INFO", 5); + } + + public List createDummyLogMessages() { + addMessagesForDisk(logMessages, s1da); + addMessagesForDisk(logMessages, s1db); + addMessagesForDisk(logMessages, s2da); + addMessagesForDisk(logMessages, s2db); + addMessagesForDisk(logMessages, s2dc); + addMessagesForDisk(logMessages, s2dd); + addMessagesForDisk(logMessages, s4da); + addMessagesForDisk(logMessages, s5da); + addMessagesForDisk(logMessages, s5db); + return logMessages; + } + + public static List getDummyLogMessages() { + return logMessages; + } + + public Disk getVolumeDisk(String volumeDisk) { + List allDisks = getReadyDisksOfAllServers(); + String brickInfo[] = volumeDisk.split(":"); + for (Disk disk : allDisks) { + if (disk.getServerName() == brickInfo[0] && disk.getName() == brickInfo[1]) { + return disk; + } + } + return null; + } + + public List getReadyDisksOfAllServers() { + return getReadyDisksOfAllServersExcluding(new ArrayList()); + } + + public List getReadyDisksOfAllServersExcluding(List excludeDisks) { + List disks = new ArrayList(); + + for (Server server : ((Cluster) model.getChildren().get(0)).getServers()) { + for (Disk disk : server.getDisks()) { + if (disk.isReady() && !excludeDisks.contains(disk)) { + disks.add(disk); + } + } + } + return disks; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterServer.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterServer.java new file mode 100644 index 00000000..6d6d9b74 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/GlusterServer.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement(name = "glusterServer") +public class GlusterServer extends Server { + private String uuid; + + public GlusterServer() { + } + + public GlusterServer(String name) { + super(name); + } + + public GlusterServer(String name, Entity parent, SERVER_STATUS status, int numOfCPUs, double cpuUsage, + double totalMemory, double memoryInUse) { + super(name, parent, numOfCPUs, cpuUsage, totalMemory, memoryInUse); + setStatus(status); + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + /** + * Filter matches if any of the properties name and status contains the filter string + */ + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getName() + getStatusStr(), filterString, caseSensitive); + } + + @Override + public boolean equals(Object obj) { + if(this == obj) { + return true; + } + + if(!(obj instanceof GlusterServer)) { + return false; + } + GlusterServer server = (GlusterServer)obj; + + if (super.equals(server) && getUuid().equals(server.getUuid()) && getStatus() == server.getStatus()) { + return true; + } + + return false; + } + + public void copyFrom(GlusterServer server) { + super.copyFrom(server); + setUuid(server.getUuid()); + setStatus(server.getStatus()); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/InitDiskStatusResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/InitDiskStatusResponse.java new file mode 100644 index 00000000..eb844613 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/InitDiskStatusResponse.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * InitDiskStatusResponse.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="response") +public class InitDiskStatusResponse { + + public enum FORMAT_STATUS { + IN_PROGRESS, COMPLETED, NOT_RUNNING + }; + + private String[] FORMAT_STATUS_STR = { "In Progress", "Completed", "Not Running" }; + + private String device; + private String message; + private float totalBlocks; + private float completedBlocks; + private FORMAT_STATUS formatStatus; + + public InitDiskStatusResponse() { + + } + + public void setDevice(String device) { + this.device = device; + } + + public String getDevice() { + return device; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + + public void setTotalBlocks(float totalBlocks) { + this.totalBlocks = totalBlocks; + } + + public float getTotalBlocks() { + return totalBlocks; + } + + public void setCompletedBlocks(float completedBlocks) { + this.completedBlocks = completedBlocks; + } + + public float getCompletedBlocks() { + return completedBlocks; + } + + public String getFormatStatusStr() { + return FORMAT_STATUS_STR[getFormatStatus().ordinal()]; + } + + public FORMAT_STATUS getFormatStatus() { + return formatStatus; + } + + public void setFormatStatus(FORMAT_STATUS status) { + this.formatStatus = status; + } + +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/NetworkInterface.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/NetworkInterface.java new file mode 100644 index 00000000..a07c0658 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/NetworkInterface.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "networkInterface") +public class NetworkInterface extends Entity { + private String hwAddr; + private String model; + private String speed; + private String ipAddress; + private String netMask; + private String defaultGateway; + + public NetworkInterface() { + + } + + public NetworkInterface(String name, Entity parent, String hwAddr, String model, String speed, String ipAddress, + String netMask, String defaultGateway) { + super(name, parent); + setHwAddr(hwAddr); + setModel(model); + setSpeed(speed); + setIpAddress(ipAddress); + setNetMask(netMask); + setDefaultGateway(defaultGateway); + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getNetMask() { + return netMask; + } + + public void setNetMask(String netMask) { + this.netMask = netMask; + } + + public String getDefaultGateway() { + return defaultGateway; + } + + public void setDefaultGateway(String defaultGateway) { + this.defaultGateway = defaultGateway; + } + + public String getHwAddr() { + return hwAddr; + } + + public void setHwAddr(String hwAddr) { + this.hwAddr = hwAddr; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getSpeed() { + return speed; + } + + public void setSpeed(String speed) { + this.speed = speed; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof NetworkInterface)) { + return false; + } + + NetworkInterface networkInterface = (NetworkInterface) obj; + if (getName().equals(networkInterface.getName()) && getHwAddr().equals(networkInterface.getHwAddr()) + && getIpAddress().equals(networkInterface.getIpAddress()) + && getDefaultGateway().equals(networkInterface.getDefaultGateway()) + && getNetMask().equals(networkInterface.getNetMask()) && getSpeed().equals(networkInterface.getSpeed()) + && getModel().equals(networkInterface.getModel())) { + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Partition.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Partition.java new file mode 100644 index 00000000..90722087 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Partition.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="partition") +public class Partition extends Device { + + public Partition() { + super(); + } + + public Partition(Server server, String name, String mountPoint, Double space, Double spaceInUse, + DEVICE_STATUS status) { + super(server, name, mountPoint, space, spaceInUse, status); + } + +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Response.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Response.java new file mode 100644 index 00000000..b27bd6f7 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Response.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +/** + * Interface for server response. Any request handled by the Gluster Management + * Server will result in a response that must be an instance of a class + * implementing this interface. + */ +public interface Response { + /** + * @return Status of request processing + */ + public Status getStatus(); + + /** + * @return Data associated with the response. e.g. A "discover servers" + * request will return the list of discovered servers. + */ + public T getData(); +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Server.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Server.java new file mode 100644 index 00000000..9ba7b886 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Server.java @@ -0,0 +1,248 @@ +/******************************************************************************* + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement(name = "server") +public class Server extends Entity { + public enum SERVER_STATUS { + ONLINE, OFFLINE + }; + + protected static final String[] STATUS_STR = new String[] { "Online", "Offline" }; + + private int numOfCPUs; + private double cpuUsage; + private double totalMemory; + private double memoryInUse; + private List disks = new ArrayList(); + private List networkInterfaces = new ArrayList(); + private SERVER_STATUS status; + + public Server() { + + } + + public Server(String name) { + super(name, null); + } + + public Server(String name, Entity parent, int numOfCPUs, double cpuUsage, double totalMemory, double memoryInUse) { + super(name, parent); + setNumOfCPUs(numOfCPUs); + setCpuUsage(cpuUsage); + setTotalMemory(totalMemory); + setMemoryInUse(memoryInUse); + } + + public int getNumOfCPUs() { + return numOfCPUs; + } + + public void setNumOfCPUs(int numOfCPUs) { + this.numOfCPUs = numOfCPUs; + } + + public double getCpuUsage() { + return cpuUsage; + } + + public void setCpuUsage(double cpuUsage) { + this.cpuUsage = cpuUsage; + } + + public double getTotalMemory() { + return totalMemory; + } + + public void setTotalMemory(double totalMemory) { + this.totalMemory = totalMemory; + } + + public double getMemoryInUse() { + return memoryInUse; + } + + public void setMemoryInUse(double memoryInUse) { + this.memoryInUse = memoryInUse; + } + + public double getTotalDiskSpace() { + double totalDiskSpace = 0; + for (Disk disk : getDisks()) { + totalDiskSpace += disk.getSpace(); + } + return totalDiskSpace; + } + + public double getDiskSpaceInUse() { + double diskSpaceInUse = 0; + for(Disk disk : getDisks()) { + if(disk.isReady()) { + diskSpaceInUse += disk.getSpaceInUse(); + } + } + return diskSpaceInUse; + } + + public double getFreeDiskSpace() { + return getTotalDiskSpace() - getDiskSpaceInUse(); + } + + @XmlElementWrapper(name = "networkInterfaces") + @XmlElement(name = "networkInterface", type = NetworkInterface.class) + public List getNetworkInterfaces() { + return networkInterfaces; + } + + public void setNetworkInterfaces(List networkInterfaces) { + this.networkInterfaces = networkInterfaces; + } + + @XmlElementWrapper(name = "disks") + @XmlElement(name = "disk", type = Disk.class) + public List getDisks() { + return disks; + } + + public void addNetworkInterface(NetworkInterface networkInterface) { + networkInterfaces.add(networkInterface); + } + + public void addDisk(Disk disk) { + disks.add(disk); + } + + public void addDisks(Collection disks) { + for (Disk disk : disks) { + addDisk(disk); + } + } + + public void removeDisk(Disk disk) { + disks.remove(disk); + } + + public void removeAllDisks() { + disks.clear(); + } + + public void setDisks(List disks) { + removeAllDisks(); + addDisks(disks); + } + + public int getNumOfDisks() { + return disks.size(); + } + + public String getIpAddressesAsString() { + String ipAddresses = ""; + for (NetworkInterface networkInterface : getNetworkInterfaces()) { + String ipAddr = networkInterface.getIpAddress(); + if(!ipAddr.equals("127.0.0.1")) { + ipAddresses += (ipAddresses.isEmpty() ? ipAddr : ", " + ipAddr); + } + } + return ipAddresses; + } + + public String getStatusStr() { + return STATUS_STR[getStatus().ordinal()]; + } + + public SERVER_STATUS getStatus() { + return status; + } + + public void setStatus(SERVER_STATUS status) { + this.status = status; + } + + public Boolean isOnline() { + return getStatus() == SERVER_STATUS.ONLINE; + } + + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getName() + getIpAddressesAsString(), filterString, caseSensitive); + } + + /** + * Note: this method doesn't copy the disks. Clients should write separate code to identify added/removed/modified + * disks and update the server disks appropriately. + * + * @param server + */ + public void copyFrom(Server server) { + setName(server.getName()); + setParent(server.getParent()); + setChildren((List) server.getChildren()); + setNetworkInterfaces(server.getNetworkInterfaces()); + setNumOfCPUs(server.getNumOfCPUs()); + setCpuUsage(server.getCpuUsage()); + setTotalMemory(server.getTotalMemory()); + setMemoryInUse(server.getMemoryInUse()); + setStatus(server.getStatus()); + } + + @Override + public boolean equals(Object obj) { + if(this == obj) { + return true; + } + + if(!(obj instanceof Server)) { + return false; + } + Server server = (Server)obj; + + if (!(getName().equals(server.getName()) && getNumOfCPUs() == server.getNumOfCPUs() + && getCpuUsage() == server.getCpuUsage() && getTotalMemory() == server.getTotalMemory() + && getMemoryInUse() == server.getMemoryInUse() && getDisks().size() == server.getDisks().size() && getNetworkInterfaces() + .size() == server.getNetworkInterfaces().size())) { + return false; + } + + for(Disk disk : getDisks()) { + if (!disk.equals(GlusterCoreUtil.getEntity(server.getDisks(), disk.getName(), false))) { + return false; + } + } + + for (NetworkInterface networkInterface : getNetworkInterfaces()) { + if (!networkInterface.equals(GlusterCoreUtil.getEntity(server.getNetworkInterfaces(), + networkInterface.getName(), false))) { + return false; + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStats.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStats.java new file mode 100644 index 00000000..7dc94948 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStats.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + */ +@XmlRootElement(name="xport") +public class ServerStats { + private StatsMetadata metadata; + private List rows; + + public ServerStats() { + } + + public ServerStats(ServerStats newStats) { + copyFrom(newStats); + } + + public void setRows(List rows) { + this.rows = rows; + } + + @XmlElementWrapper(name="data") + @XmlElement(name="row", type=ServerStatsRow.class) + public List getRows() { + return rows; + } + + public void setMetadata(StatsMetadata metadata) { + this.metadata = metadata; + } + + @XmlElement(name="meta") + public StatsMetadata getMetadata() { + return metadata; + } + + public void copyFrom(ServerStats newStats) { + setMetadata(newStats.getMetadata()); + + List newRows = newStats.getRows(); + int rowCount = newRows.size(); + + rows = new ArrayList(rowCount); + for(ServerStatsRow newRow : newRows) { + rows.add(new ServerStatsRow(newRow)); + } + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStatsRow.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStatsRow.java new file mode 100644 index 00000000..a6280be0 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/ServerStatsRow.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + */ +@XmlRootElement(name="row") +public class ServerStatsRow { + private Long timestamp; + private List usageData; + + public ServerStatsRow() { + } + + public ServerStatsRow(ServerStatsRow newRow) { + copyFrom(newRow); + } + + private void copyFrom(ServerStatsRow newRow) { + setTimestamp(newRow.getTimestamp()); + + List myData = new ArrayList(newRow.getUsageData().size()); + for(Double dataElement : newRow.getUsageData()) { + myData.add(dataElement); + } + setUsageData(myData); + } + + @XmlElement(name="t") + public Long getTimestamp() { + return timestamp; + } + + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } + + public void setUsageData(List usageData) { + this.usageData = usageData; + } + + @XmlElement(name="v") + public List getUsageData() { + return usageData; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/StatsMetadata.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/StatsMetadata.java new file mode 100644 index 00000000..db5db29e --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/StatsMetadata.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + */ +@XmlRootElement(name="meta") +public class StatsMetadata { + private Long startTimestamp; + private Long endTimestamp; + private Integer step; + private Integer rowCount; + private List legend = new ArrayList(); + + @XmlElement(name="start") + public Long getStartTimestamp() { + return startTimestamp; + } + + public void setStartTimestamp(Long startTimestamp) { + this.startTimestamp = startTimestamp; + } + + @XmlElement(name="end") + public Long getEndTimestamp() { + return endTimestamp; + } + + public void setEndTimestamp(Long endTimestamp) { + this.endTimestamp = endTimestamp; + } + + @XmlElement(name="step") + public Integer getStep() { + return step; + } + + public void setStep(Integer step) { + this.step = step; + } + + @XmlElement(name="rows") + public Integer getRowCount() { + return rowCount; + } + + public void setRowCount(Integer rowCount) { + this.rowCount = rowCount; + } + + @XmlElementWrapper(name="legend") + @XmlElement(name="entry", type=String.class) + public List getLegend() { + return legend; + } + + public void setLegend(List legend) { + this.legend = legend; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Status.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Status.java new file mode 100644 index 00000000..912ec409 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Status.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.utils.ProcessResult; + + +@XmlRootElement(name = "status") +public class Status { + // TODO: Convert the status codes to an enumeration + public static final int STATUS_CODE_SUCCESS = 0; + public static final int STATUS_CODE_FAILURE = 1; + public static final int STATUS_CODE_PART_SUCCESS = 2; + public static final int STATUS_CODE_RUNNING = 3; + public static final int STATUS_CODE_PAUSE = 4; + public static final int STATUS_CODE_WARNING = 5; + public static final int STATUS_CODE_COMMIT_PENDING = 6; + public static final Status STATUS_SUCCESS = new Status(STATUS_CODE_SUCCESS, "Success"); + public static final Status STATUS_FAILURE = new Status(STATUS_CODE_FAILURE, "Failure"); + + // public static final Status + + private Integer code; + private String message; + + public Status() { + } + + public boolean isSuccess() { + return code == STATUS_CODE_SUCCESS; + } + + public boolean isPartSuccess() { + return code == STATUS_CODE_PART_SUCCESS; + } + + public Status(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Status(ProcessResult result) { + this.code = result.getExitValue(); + this.message = result.getOutput(); + } + + public Status(Exception e) { + this.code = STATUS_CODE_FAILURE; + this.message = e.getMessage(); + } + + @XmlElement(name = "code", type = Integer.class) + public Integer getCode() { + return code; + } + + public void setCode(Integer executionStatus) { + this.code = executionStatus; + } + + @XmlElement + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return isSuccess() ? "Success" : "[" + getCode() + "][" + getMessage() + "]"; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskInfo.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskInfo.java new file mode 100644 index 00000000..cecc1c26 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskInfo.java @@ -0,0 +1,141 @@ +/** + * TaskInfo.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement +public class TaskInfo extends Entity { + public enum TASK_TYPE { + DISK_FORMAT, BRICK_MIGRATE, VOLUME_REBALANCE + } + + private TASK_TYPE type; + private String reference; + private String description; + private Boolean pauseSupported; + private Boolean stopSupported; + private Boolean commitSupported; + private TaskStatus status; + + public TaskInfo() { + } + + @XmlElement(name="id") + public String getName() { + return super.getName(); + } + + public TASK_TYPE getType() { + return type; + } + + public void setType(TASK_TYPE type) { + this.type = type; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public TaskStatus getStatus() { + return status; + } + + public void setStatus(TaskStatus status) { + this.status = status; + } + + public Boolean getPauseSupported() { + return pauseSupported; + } + + public void setPauseSupported(Boolean canPause) { + this.pauseSupported = canPause; + } + + public Boolean getStopSupported() { + return stopSupported; + } + + public void setStopSupported(Boolean canStop) { + this.stopSupported = canStop; + } + + public Boolean getCommitSupported() { + return this.commitSupported; + } + + public void setCommitSupported(Boolean canCommit) { + this.commitSupported = canCommit; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.core.model.Entity#filter(java.lang.String, boolean) + */ + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getDescription() + getStatus().getMessage(), filterString, caseSensitive); + } + + public void copyFrom(TaskInfo newTask) { + setName(newTask.getName()); + setDescription(newTask.getDescription()); + setReference(newTask.getReference()); + setStatus(newTask.getStatus()); + setType(newTask.getType()); + setPauseSupported(newTask.getPauseSupported()); + setStopSupported(newTask.getStopSupported()); + } + + @Override + public boolean equals(Object obj) { + if(!(obj instanceof TaskInfo)) { + return false; + } + + TaskInfo newTask = (TaskInfo)obj; + if (newTask.getName().equals(getName()) && newTask.getDescription().equals(getDescription()) + && newTask.getReference().equals(getReference()) && newTask.getStatus().equals(getStatus()) + && newTask.getType() == getType() && newTask.getPauseSupported() == getPauseSupported() + && newTask.getStopSupported() == getStopSupported()) { + return true; + } + + return false; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskStatus.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskStatus.java new file mode 100644 index 00000000..e24fdd41 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/TaskStatus.java @@ -0,0 +1,64 @@ +/** + * TaskStatus.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.model; + +public class TaskStatus extends Status { + + private boolean isPercentageSupported = false; + private float percentCompleted; + private String description; + + public TaskStatus() { + + } + + public TaskStatus(Status status) { + super(status.getCode(), status.getMessage()); + } + + public boolean isCommitPending() { + return getCode() == STATUS_CODE_COMMIT_PENDING; + } + + public boolean isPercentageSupported() { + return isPercentageSupported; + } + + public void setPercentageSupported(boolean isPercentageSupported) { + this.isPercentageSupported = isPercentageSupported; + } + + public float getPercentCompleted() { + return percentCompleted; + } + + public void setPercentCompleted(float percentCompleted) { + this.percentCompleted = percentCompleted; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/User.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/User.java new file mode 100644 index 00000000..d6a1e230 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/User.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +@XmlRootElement +public class User { + private String userId; + private String password; + + public String getUserId() { + return userId; + } + public void setUserId(String userId) { + this.userId = userId; + } + + @XmlTransient + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Version.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Version.java new file mode 100644 index 00000000..447fa1d5 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Version.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +/** + * + */ +public class Version implements Comparable { + public int major = 0; + public int minor = 0; + public int maintenance = 0; + + public Version(String version) { + String[] versionParts = version.split(".", -1); + major = Integer.valueOf(versionParts[0]); + if(versionParts.length > 1) { + minor = Integer.valueOf(versionParts[1]); + } + if(versionParts.length > 2) { + maintenance = Integer.valueOf(versionParts[2]); + } + } + + @Override + public int compareTo(Version newVer) { + if(this.major < newVer.major) { + return -1; + } else if(this.major > newVer.major) { + return 1; + } + + // major version is same + if(this.minor < newVer.minor) { + return -1; + } else if(this.minor > newVer.minor) { + return 1; + } + + // major.minor is same + if(this.maintenance < newVer.maintenance) { + return -1; + } else if(this.maintenance > newVer.maintenance) { + return 1; + } + + // major.minor.maintenance is same + return 0; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Volume.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Volume.java new file mode 100644 index 00000000..41e9d291 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/Volume.java @@ -0,0 +1,368 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement +public class Volume extends Entity { + public enum VOLUME_STATUS { + ONLINE, OFFLINE + }; + + public enum VOLUME_TYPE { + DISTRIBUTE, REPLICATE, DISTRIBUTED_REPLICATE, STRIPE, DISTRIBUTED_STRIPE + }; + + public enum TRANSPORT_TYPE { + ETHERNET, INFINIBAND + }; + + public enum NAS_PROTOCOL { + GLUSTERFS, NFS, CIFS + }; + + + public static final int DEFAULT_REPLICA_COUNT = 2; + public static final int DEFAULT_STRIPE_COUNT = 4; + + public static final String OPTION_AUTH_ALLOW = "auth.allow"; + public static final String OPTION_NFS_DISABLE = "nfs.disable"; + + private static final String[] VOLUME_TYPE_STR = new String[] { "Distribute", "Replicate", "Distributed Replicate", + "Stripe", "Distributed Stripe" }; + + private static final String[] TRANSPORT_TYPE_STR = new String[] { "Ethernet", "Infiniband" }; + private static final String[] STATUS_STR = new String[] { "Online", "Offline" }; + private static final String[] NAS_PROTOCOL_STR = new String[] { "Gluster", "NFS", "CIFS" }; + + private VOLUME_TYPE volumeType; + private TRANSPORT_TYPE transportType; + private VOLUME_STATUS status; + private int replicaCount; + private int stripeCount; + private VolumeOptions options = new VolumeOptions(); + private List bricks = new ArrayList(); + private List cifsUsers; + + public Volume() { + } + + // Only GlusterFS is enabled + private Set nasProtocols = new LinkedHashSet(Arrays.asList(new NAS_PROTOCOL[] { + NAS_PROTOCOL.GLUSTERFS })); + + public String getVolumeTypeStr() { + return getVolumeTypeStr(getVolumeType()); + } + + public static String getVolumeTypeStr(VOLUME_TYPE volumeType) { + return VOLUME_TYPE_STR[volumeType.ordinal()]; + } + + public static VOLUME_TYPE getVolumeTypeByStr(String volumeTypeStr) { + return VOLUME_TYPE.valueOf(volumeTypeStr); + } + + public static TRANSPORT_TYPE getTransportTypeByStr(String transportTypeStr) { + return TRANSPORT_TYPE.valueOf(transportTypeStr); + } + + public String getTransportTypeStr() { + return TRANSPORT_TYPE_STR[getTransportType().ordinal()]; + } + + public String getStatusStr() { + return STATUS_STR[getStatus().ordinal()]; + } + + public int getNumOfBricks() { + return bricks.size(); + } + + public VOLUME_TYPE getVolumeType() { + return volumeType; + } + + public void setVolumeType(VOLUME_TYPE volumeType) { + this.volumeType = volumeType; + // TODO find a way to get the replica / strip count + if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + setReplicaCount(0); + setStripeCount(DEFAULT_STRIPE_COUNT); + } else if (volumeType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { + setReplicaCount(DEFAULT_REPLICA_COUNT); + setStripeCount(0); + } else { + setReplicaCount(0); + setStripeCount(0); + } + } + + public TRANSPORT_TYPE getTransportType() { + return transportType; + } + + public void setTransportType(TRANSPORT_TYPE transportType) { + this.transportType = transportType; + } + + public VOLUME_STATUS getStatus() { + return status; + } + + public int getReplicaCount() { + return replicaCount; + } + + public void setReplicaCount(int replicaCount) { + this.replicaCount = replicaCount; + } + + public int getStripeCount() { + return stripeCount; + } + + public void setStripeCount(int stripeCount) { + this.stripeCount = stripeCount; + } + + public void setStatus(VOLUME_STATUS status) { + this.status = status; + } + + @XmlElementWrapper(name = "nasProtocols") + @XmlElement(name = "nasProtocol", type=NAS_PROTOCOL.class) + public Set getNASProtocols() { + return nasProtocols; + } + + public void setNASProtocols(Set nasProtocols) { + this.nasProtocols = nasProtocols; + } + + public String getNASProtocolsStr() { + String protocolsStr = ""; + for (NAS_PROTOCOL protocol : nasProtocols) { + String protocolStr = NAS_PROTOCOL_STR[protocol.ordinal()]; + protocolsStr += (protocolsStr.isEmpty() ? protocolStr : ", " + protocolStr); + } + return protocolsStr; + } + + @XmlTransient + public String getAccessControlList() { + return options.get(OPTION_AUTH_ALLOW); + } + + public void setAccessControlList(String accessControlList) { + setOption(OPTION_AUTH_ALLOW, accessControlList); + } + + @XmlTransient + public boolean isNfsEnabled() { + String nfsDisabled = options.get(OPTION_NFS_DISABLE); + if(nfsDisabled == null || nfsDisabled.equalsIgnoreCase(GlusterConstants.OFF)) { + return true; + } else { + return false; + } + } + + @XmlElement(name="options") + public VolumeOptions getOptions() { + return options; + } + + public void setOption(String key, String value) { + options.put(key, value); + } + + public void setOptions(VolumeOptions options) { + this.options = options; + } + + public void setOptions(LinkedHashMap options) { + List volumeOptions = new ArrayList(); + for(Entry entry : options.entrySet()) { + volumeOptions.add(new VolumeOption(entry.getKey(), entry.getValue())); + } + this.options.setOptions(volumeOptions); + } + + public void addBrick(Brick brick) { + bricks.add(brick); + } + + public void addBricks(Collection bricks) { + this.bricks.addAll(bricks); + } + + + public void setBricks(List bricks) { + this.bricks = bricks; + } + + public void removeBrick(Brick brick) { + bricks.remove(brick); + } + + @XmlElementWrapper(name = "bricks") + @XmlElement(name = "brick", type=Brick.class) + public List getBricks() { + return bricks; + } + + public void enableNFS() { + nasProtocols.add(NAS_PROTOCOL.NFS); + setOption(OPTION_NFS_DISABLE, GlusterConstants.OFF); + } + + public void disableNFS() { + nasProtocols.remove(NAS_PROTOCOL.NFS); + setOption(OPTION_NFS_DISABLE, GlusterConstants.ON); + } + + public void enableCifs() { + if (!nasProtocols.contains(NAS_PROTOCOL.CIFS)) { + nasProtocols.add(NAS_PROTOCOL.CIFS); + } + } + + public void disableCifs() { + nasProtocols.remove(NAS_PROTOCOL.CIFS); + } + + public boolean isCifsEnable() { + return nasProtocols.contains(NAS_PROTOCOL.CIFS); + } + + public void setCifsUsers(List cifsUsers) { + this.cifsUsers = cifsUsers; + } + + public List getCifsUsers() { + return cifsUsers; + } + + + public Volume(String name, Entity parent, VOLUME_TYPE volumeType, TRANSPORT_TYPE transportType, VOLUME_STATUS status) { + super(name, parent); + setVolumeType(volumeType); + setTransportType(transportType); + setStatus(status); + } + + /** + * Filter matches if any of the properties name, volume type, transport type, status and number of disks contains + * the filter string + */ + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getName() + getVolumeTypeStr() + getTransportTypeStr() + getStatusStr() + + getNumOfBricks(), filterString, caseSensitive); + } + + public List getBrickDirectories() { + List brickDirectories = new ArrayList(); + for(Brick brick : getBricks()) { + brickDirectories.add(brick.getQualifiedName()); + } + return brickDirectories; + } + + @Override + public boolean equals(Object obj) { + if(!(obj instanceof Volume)) { + return false; + } + + Volume volume = (Volume)obj; + + if (!(getName().equals(volume.getName()) && getVolumeType() == volume.getVolumeType() + && getTransportType() == volume.getTransportType() && getStatus() == volume.getStatus() + && getReplicaCount() == volume.getReplicaCount() && getStripeCount() == volume.getStripeCount() + && getOptions().equals(volume.getOptions()))) { + return false; + } + + for(NAS_PROTOCOL nasProtocol : getNASProtocols()) { + if(!(volume.getNASProtocols().contains(nasProtocol))) { + return false; + } + } + + List oldBricks = getBricks(); + List newBricks = volume.getBricks(); + if(oldBricks.size() != newBricks.size()) { + return false; + } + + if(!GlusterCoreUtil.getAddedEntities(oldBricks, newBricks, false).isEmpty()) { + return false; + } + + if(!GlusterCoreUtil.getAddedEntities(newBricks, oldBricks, false).isEmpty()) { + return false; + } + + Map modifiedBricks = GlusterCoreUtil.getModifiedEntities(oldBricks, newBricks); + if(modifiedBricks.size() > 0) { + return false; + } + + return true; + } + + /** + * Note: this method doesn't copy the bricks. Clients should write separate code to identify added/removed/modified + * bricks and update the volume bricks appropriately. + * + * @param newVolume + */ + public void copyFrom(Volume newVolume) { + setName(newVolume.getName()); + setVolumeType(newVolume.getVolumeType()); + setTransportType(newVolume.getTransportType()); + setStatus(newVolume.getStatus()); + setReplicaCount(newVolume.getReplicaCount()); + setStripeCount(newVolume.getStripeCount()); + setNASProtocols(newVolume.getNASProtocols()); + setCifsUsers(newVolume.getCifsUsers()); + getOptions().copyFrom(newVolume.getOptions()); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeLogMessage.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeLogMessage.java new file mode 100644 index 00000000..de038a70 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeLogMessage.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import org.gluster.storage.management.core.model.adapters.VolumeLogDateAdapter; +import org.gluster.storage.management.core.utils.StringUtil; + + +@XmlRootElement +public class VolumeLogMessage implements Filterable { + private Date timestamp; + private String brick; + private String severity; + private String message; + + public VolumeLogMessage() { + } + + public VolumeLogMessage(String logMessage) { + // TODO: Parse the log message and extract fields + } + + @XmlElement(name = "timestamp", required = true) + @XmlJavaTypeAdapter(VolumeLogDateAdapter.class) + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setBrick(String brick) { + this.brick = brick; + } + + @XmlElement(name = "brick") + public String getBrick() { + return brick; + } + + public VolumeLogMessage(Date timestamp, String brickDirectory, String severity, String message) { + setTimestamp(timestamp); + setBrick(brickDirectory); + setSeverity(severity); + setMessage(message); + } + + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getSeverity() + getTimestamp() + getBrick() + getMessage(), filterString, + caseSensitive); + } + +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOption.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOption.java new file mode 100644 index 00000000..40736751 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOption.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.utils.StringUtil; + + +/** + * + */ +@XmlRootElement(name="option") +public class VolumeOption implements Filterable { + private String key; + private String value; + + public VolumeOption() { + } + + public VolumeOption(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return key + "=" + value; + } + + @Override + public boolean filter(String filterString, boolean caseSensitive) { + return StringUtil.filterString(getKey() + getValue(), filterString, caseSensitive); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptionInfo.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptionInfo.java new file mode 100644 index 00000000..264095f7 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptionInfo.java @@ -0,0 +1,66 @@ +/** + * VolumeOptionInfo.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Class to hold information about a volume option + */ +@XmlRootElement(name = "option") +public class VolumeOptionInfo { + private String name; + private String description; + private String defaultValue; + + public VolumeOptionInfo() { + } + + public VolumeOptionInfo(String name, String description, String defaultValue) { + setName(name); + setDescription(description); + setDefaultValue(defaultValue); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptions.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptions.java new file mode 100644 index 00000000..618feede --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/VolumeOptions.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.model; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + */ +@XmlRootElement(name="options") +public class VolumeOptions { + private List options = new ArrayList(); + + public VolumeOptions() { + } + + public String get(String key) { + for(VolumeOption option : options) { + if(option.getKey().equals(key)) { + return option.getValue(); + } + } + return null; + } + + public void put(String key, String value) { + VolumeOption option = getOption(key); + if(option != null) { + option.setValue(value); + } else { + options.add(new VolumeOption(key, value)); + } + } + + @XmlElement(name="option", type=VolumeOption.class) + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + + public void clear() { + options.clear(); + } + + public boolean remove(String key) { + return options.remove(getOption(key)); + } + + public VolumeOption getOption(String key) { + for(VolumeOption option : options) { + if(option.getKey().equals(key)) { + return option; + } + } + return null; + } + + public int size() { + return options.size(); + } + + public boolean containsKey(String key) { + return get(key) != null; + } + + @Override + public boolean equals(Object obj) { + if(!(obj instanceof VolumeOptions)) { + return false; + } + + VolumeOptions options = (VolumeOptions)obj; + if(getOptions().size() != options.size()) { + return false; + } + + for(VolumeOption option : getOptions()) { + if(!(option.getValue().equals(options.get(option.getKey())))) { + return false; + } + } + + return true; + } + + public void copyFrom(VolumeOptions options) { + this.options.clear(); + this.options.addAll(options.getOptions()); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java new file mode 100644 index 00000000..7656249c --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/model/adapters/VolumeLogDateAdapter.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ + +package org.gluster.storage.management.core.model.adapters; + +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import org.gluster.storage.management.core.utils.DateUtil; + + +/** + * Adapter class used for converting timestamp from Gluster volume log files to Date object. + */ +public class VolumeLogDateAdapter extends XmlAdapter { + private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; + + /* (non-Javadoc) + * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) + */ + @Override + public Date unmarshal(String input) { + input = input.trim(); + if(input.length() > DATE_FORMAT.length()) { + input = input.substring(0, DATE_FORMAT.length()); + } + return DateUtil.stringToDate(input, DATE_FORMAT); + } + + /* (non-Javadoc) + * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) + */ + @Override + public String marshal(Date input) { + return DateUtil.dateToString(input, DATE_FORMAT); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/AbstractResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/AbstractResponse.java new file mode 100644 index 00000000..14eab4eb --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/AbstractResponse.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import org.gluster.storage.management.core.model.Response; +import org.gluster.storage.management.core.model.Status; + +public abstract class AbstractResponse implements Response { + private Status status; + + @Override + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ClusterNameListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ClusterNameListResponse.java new file mode 100644 index 00000000..87904f67 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ClusterNameListResponse.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Response object for transferring cluster names during REST communication. This is just a wrapper over a list of + * Strings, and is required because the jersey rest framework can't transfer lists directly. + */ +@XmlRootElement(name="clusters") +public class ClusterNameListResponse { +private List clusterNames = new ArrayList(); + + public ClusterNameListResponse() { + } + + public ClusterNameListResponse(List clusterNames) { + this.clusterNames = clusterNames; + } + + @XmlElement(name = "cluster", type = String.class) + public List getClusterNames() { + return clusterNames; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/FsTypeListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/FsTypeListResponse.java new file mode 100644 index 00000000..c2762706 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/FsTypeListResponse.java @@ -0,0 +1,47 @@ +/** + * FsTypesListResponse.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.response; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "fsTypes") +public class FsTypeListResponse { + private List fsTypes; + + public FsTypeListResponse() { + } + + public FsTypeListResponse(List fsTypes) { + setFsTypes(fsTypes); + } + + @XmlElement(name = "fsType", type=String.class) + public List getFsTypes() { + return fsTypes; + } + + public void setFsTypes(List fsTypes) { + this.fsTypes = fsTypes; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerListResponse.java new file mode 100644 index 00000000..2c985796 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerListResponse.java @@ -0,0 +1,55 @@ +/** + * GlusterServerListResponse.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.GlusterServer; + + +/** + * + */ +@XmlRootElement(name = "servers") +public class GlusterServerListResponse { + private List servers = new ArrayList(); + + public GlusterServerListResponse() { + } + + public GlusterServerListResponse(List servers) { + setServers(servers); + } + + @XmlElement(name = "server", type=GlusterServer.class) + public List getServers() { + return servers; + } + + public void setServers(List servers) { + this.servers = servers; + } +} + diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerResponse.java new file mode 100644 index 00000000..af029893 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/GlusterServerResponse.java @@ -0,0 +1,36 @@ +package org.gluster.storage.management.core.response; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Status; + + +@XmlRootElement(name = "response") +public class GlusterServerResponse extends AbstractResponse { + private GlusterServer glusterServer; + + public GlusterServerResponse() { + } + + public GlusterServerResponse(Status status, GlusterServer server) { + setStatus(status); + setGlusterServer(server); + } + + public GlusterServer getGlusterServer() { + return glusterServer; + } + + public void setGlusterServer(GlusterServer glusterServer) { + this.glusterServer = glusterServer; + } + + @XmlTransient + @Override + public GlusterServer getData() { + return getGlusterServer(); + } + +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/LogMessageListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/LogMessageListResponse.java new file mode 100644 index 00000000..0036cacd --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/LogMessageListResponse.java @@ -0,0 +1,34 @@ +/** + * + */ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.VolumeLogMessage; + + +@XmlRootElement(name = "logMessages") +public class LogMessageListResponse { + private List logMessages = new ArrayList(); + + public LogMessageListResponse() { + } + + public LogMessageListResponse(List logMessages) { + setLogMessages(logMessages); + } + + @XmlElement(name = "logMessage", type = VolumeLogMessage.class) + public List getLogMessages() { + return logMessages; + } + + public void setLogMessages(List logMessages) { + this.logMessages = logMessages; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerListResponse.java new file mode 100644 index 00000000..7c9b2ad5 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerListResponse.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.Server; + + +@XmlRootElement(name = "servers") +public class ServerListResponse { + private List servers = new ArrayList(); + + public ServerListResponse() { + } + + public ServerListResponse(List servers) { + setServers(servers); + } + + @XmlElement(name = "server", type=Server.class) + public List getServers() { + return servers; + } + + public void setServers(List servers) { + this.servers = servers; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerNameListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerNameListResponse.java new file mode 100644 index 00000000..2313f4d9 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/ServerNameListResponse.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Response object for transferring cluster names during REST communication. This is just a wrapper over a list of + * Strings, and is required because the jersey rest framework can't transfer lists directly. + */ +@XmlRootElement(name="servers") +public class ServerNameListResponse { +private List serverNames = new ArrayList(); + + public ServerNameListResponse() { + } + + public ServerNameListResponse(List serverNames) { + this.serverNames = serverNames; + } + + @XmlElement(name = "server", type = String.class) + public List getServerNames() { + return serverNames; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/StringListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/StringListResponse.java new file mode 100644 index 00000000..aaae7e0e --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/StringListResponse.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.Status; + + +@XmlRootElement(name = "response") +public class StringListResponse extends AbstractResponse { + private List data = new ArrayList(); + + public StringListResponse() { + } + + public StringListResponse(List data) { + this.data = data; + setStatus(Status.STATUS_SUCCESS); + } + + @Override + @XmlElementWrapper(name = "list") + @XmlElement(name = "value", type = String.class) + public List getData() { + return data; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskIdResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskIdResponse.java new file mode 100644 index 00000000..d585d7ad --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskIdResponse.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + */ +@XmlRootElement(name="task") +public class TaskIdResponse { + private String id; + + public TaskIdResponse() { + } + + public TaskIdResponse(String id) { + setId(id); + } + + public void setId(String id) { + this.id = id; + } + + @XmlElement(name="id") + public String getId() { + return id; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskInfoListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskInfoListResponse.java new file mode 100644 index 00000000..939d21c6 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskInfoListResponse.java @@ -0,0 +1,52 @@ +/** + * TaskListResponse.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.TaskInfo; + + +@XmlRootElement(name = "tasks") +public class TaskInfoListResponse { + private List taskInfoList = new ArrayList(); + + public TaskInfoListResponse() { + + } + + public TaskInfoListResponse(List taskInfoList) { + this.taskInfoList = taskInfoList; + } + + @XmlElement(name="task", type=TaskInfo.class) + public List getTaskList() { + return taskInfoList; + } + + public void setTaskList(List taskInfoList) { + this.taskInfoList = taskInfoList; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskResponse.java new file mode 100755 index 00000000..00e1de87 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/TaskResponse.java @@ -0,0 +1,53 @@ +/** + * TaskInfoResponse.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.response; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; + + +@XmlRootElement(name = "response") +public class TaskResponse extends AbstractResponse { + private TaskInfo taskInfo; + private Status status; + + public TaskResponse() { + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public void setData(TaskInfo taskInfo) { + this.taskInfo = taskInfo; + } + + @Override + public TaskInfo getData() { + return taskInfo; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeListResponse.java new file mode 100644 index 00000000..8cb4c577 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeListResponse.java @@ -0,0 +1,32 @@ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.Volume; + + +@XmlRootElement(name = "volumes") +public class VolumeListResponse { + private List volumes = new ArrayList(); + + public VolumeListResponse() { + + } + + public VolumeListResponse(List volumes) { + setVolumes(volumes); + } + + @XmlElement(name = "volume", type = Volume.class) + public List getVolumes() { + return this.volumes; + } + + public void setVolumes(List volumes) { + this.volumes = volumes; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java new file mode 100644 index 00000000..36a4dcb2 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/response/VolumeOptionInfoListResponse.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.response; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.gluster.storage.management.core.model.VolumeOptionInfo; + + +@XmlRootElement(name = "options") +public class VolumeOptionInfoListResponse { + private List options = new ArrayList(); + + public VolumeOptionInfoListResponse() { + } + + @XmlElement(name = "option", type=VolumeOptionInfo.class) + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/DateUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/DateUtil.java new file mode 100644 index 00000000..6daeeb1c --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/DateUtil.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; + + +public class DateUtil { + + /** + * Formats given date in pure date format (without time component) using default format + * {@link CoreConstants#PURE_DATE_FORMAT} + * + * @param inputDate + * Date to be formatted + * @return Formatted String representation of the given date + */ + public static final String formatDate(Date inputDate) { + return dateToString(inputDate, CoreConstants.PURE_DATE_FORMAT); + } + + /** + * Formats given date in pure time format (without date component) using default format + * {@link CoreConstants#PURE_TIME_FORMAT} + * + * @param inputDate + * Date to be formatted + * @return Formatted String representation of the given date + */ + public static final String formatTime(Date inputDate) { + return dateToString(inputDate, CoreConstants.PURE_TIME_FORMAT); + } + + /** + * Converts given date object to string by formatting it in given format + * + * @param date + * Date to be formatted + * @param dateFormat + * Date format + * @return String representation of the given Date + */ + public static final String dateToString(Date date, String dateFormat) { + SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat); + return dateFormatter.format(date); + } + + /** + * Converts given date object to string by formatting it using default date format + * {@link CoreConstants#DATE_WITH_TIME_FORMAT} + * + * @param date + * Date to be formatted + * @param dateFormat + * Date format + * @return String representation of the given Date + */ + public static final String dateToString(Date date) { + return dateToString(date, CoreConstants.DATE_WITH_TIME_FORMAT); + } + + /** + * Converts given string to date using the given date format + * + * @param input + * Input string + * @param dateFormat + * The date format to be used + * @return Date object + */ + public static final Date stringToDate(String input, String dateFormat) { + try { + SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat); + return dateFormatter.parse(input); + } catch (ParseException e) { + throw new GlusterRuntimeException("Error trying to parse string [" + input + "] in to date using format [" + + dateFormat + "]", e); + } + } + + /** + * Converts given string to date using the default date format {@link CoreConstants#DATE_WITH_TIME_FORMAT} + * + * @param input + * Input string + * @return Date object + */ + public static final Date stringToDate(String input) { + return stringToDate(input, CoreConstants.DATE_WITH_TIME_FORMAT); + } + + public static final Date getDate(int year, int month, int day, int hour, int min, int sec, int msec) { + Calendar calendar = Calendar.getInstance(); + calendar.set(year, month-1, day, hour, min, sec); + calendar.set(Calendar.MILLISECOND, msec); + return calendar.getTime(); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/FileUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/FileUtil.java new file mode 100644 index 00000000..10c03fe1 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/FileUtil.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.util.UUID; + +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; + + +public class FileUtil { + public static String readFileAsString(File file) { + try { + return new String(readFileAsByteArray(file), CoreConstants.ENCODING_UTF8); + } catch (Exception e) { + e.printStackTrace(); + throw new GlusterRuntimeException("Could not read file [" + file + "]", e); + } + } + + public static byte[] readFileAsByteArray(File file) { + try { + FileInputStream fileInputStream = new FileInputStream(file); + byte[] data = new byte[fileInputStream.available()]; + fileInputStream.read(data); + fileInputStream.close(); + return data; + } catch (Exception e) { + throw new GlusterRuntimeException("Exception while reading file [" + file.getName() + "]: " + + e.getMessage(), e); + } + } + + public static void createTextFile(String fileName, String contents) { + try { + FileWriter writer = new FileWriter(fileName); + writer.write(contents); + writer.close(); + } catch (Exception e) { + throw new GlusterRuntimeException("Exception while trying to create text file [" + fileName + "]", e); + } + } + + public static String getTempDirName() { + return System.getProperty("java.io.tmpdir"); + } + + /** + * Create a new temporary directory. Use something like + * {@link #recursiveDelete(File)} to clean this directory up since it isn't + * deleted automatically + * @return the new directory + * @throws IOException if there is an error creating the temporary directory + */ + public static File createTempDir() + { + final File sysTempDir = new File(getTempDirName()); + File newTempDir; + final int maxAttempts = 9; + int attemptCount = 0; + do + { + attemptCount++; + if(attemptCount > maxAttempts) + { + throw new GlusterRuntimeException( + "The highly improbable has occurred! Failed to " + + "create a unique temporary directory after " + + maxAttempts + " attempts."); + } + String dirName = UUID.randomUUID().toString(); + newTempDir = new File(sysTempDir, dirName); + } while(newTempDir.exists()); + + if(newTempDir.mkdirs()) + { + return newTempDir; + } + else + { + throw new GlusterRuntimeException( + "Failed to create temp dir named " + + newTempDir.getAbsolutePath()); + } + } + + /** + * Recursively delete file or directory + * + * @param fileOrDir + * the file or dir to delete + * @return true if all files are successfully deleted + */ + public static void recursiveDelete(File fileOrDir) + { + if(fileOrDir.isDirectory()) + { + // recursively delete contents + for(File innerFile: fileOrDir.listFiles()) + { + recursiveDelete(innerFile); + } + } + + if(!fileOrDir.delete()) { + throw new GlusterRuntimeException("Couldn't delete file/directory [" + fileOrDir + "]"); + } + } + + public static void renameFile(String fromPath, String toPath) { + File fromFile = new File(fromPath); + File toFile = new File(toPath); + + if(!fromFile.renameTo(toFile)) { + throw new GlusterRuntimeException("Couldn't rename [" + fromFile + "] to [" + toFile + "]"); + } + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/GlusterCoreUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/GlusterCoreUtil.java new file mode 100644 index 00000000..47121da1 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/GlusterCoreUtil.java @@ -0,0 +1,206 @@ +/** + * GlusterCoreUtil.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Disk; +import org.gluster.storage.management.core.model.Entity; +import org.gluster.storage.management.core.model.Partition; +import org.gluster.storage.management.core.model.Server; + + + +public class GlusterCoreUtil { + // Convert from Disk list to Qualified disk name list + public static final List getQualifiedDiskNames(List diskList) { + List qualifiedDiskNames = new ArrayList(); + for (Disk disk : diskList) { + qualifiedDiskNames.add(disk.getQualifiedName()); + } + return qualifiedDiskNames; + } + + public static final List getQualifiedBrickList(Set bricks) { + List qualifiedBricks = new ArrayList(); + for (Brick brick : bricks) { + qualifiedBricks.add(brick.getQualifiedName()); + } + return qualifiedBricks; + } + + /** + * Compares the two entity lists and returns the list of entities from first list that have been modified in the second + * + * @param oldEntities + * @param newEntities + * @return List of entities that have been modified + */ + public static Map getModifiedEntities(List oldEntities, List newEntities) { + Map modifiedEntities = new HashMap(); + for (T oldEntity : oldEntities) { + T newEntity = getEntity(newEntities, oldEntity.getName(), false); + if(newEntity != null && !oldEntity.equals(newEntity)) { + // old and new entities differ. mark it as modified. + modifiedEntities.put(oldEntity, newEntity); + } + } + return modifiedEntities; + } + + /** + * Compares the two entity lists and returns the list of entities present only in the second argument + * newEntities + * + * @param oldEntities + * @param newEntities + * @param caseInsensitive If true, the entity name comparison will be done in case insensitive manner + * @return List of entities that are present only in the second argument newEntities + */ + public static Set getAddedEntities(List oldEntities, List newEntities, + boolean caseInsensitive) { + Set addedEntities = new HashSet(); + for (T newEntity : newEntities) { + if (!containsEntity(oldEntities, newEntity, caseInsensitive)) { + // old entity list doesn't contain this entity. mark it as new. + addedEntities.add(newEntity); + } + } + return addedEntities; + } + + public static boolean containsEntity(List entityList, Entity searchEntity, + boolean caseInsensitive) { + return getEntity(entityList, searchEntity.getName(), caseInsensitive) != null; + } + + public static boolean containsEntityWithName(List entityList, String searchName, + boolean caseInsensitive) { + return getEntity(entityList, searchName, caseInsensitive) != null; + } + + public static T getEntity(Collection entityList, String searchEntityName, boolean caseInsensitive) { + for (T entity : entityList) { + String nextEntityName = entity.getName(); + if (nextEntityName.equals(searchEntityName) + || (caseInsensitive && nextEntityName.equalsIgnoreCase(searchEntityName))) { + return entity; + } + } + + return null; + } + + public static void updateServerNameOnDevices(Server server) { + String serverName = server.getName(); + for(Disk disk : server.getDisks()) { + disk.setServerName(serverName); + + if (disk.getRaidDisks() != null) { + for (Disk raidDisk : disk.getRaidDisks()) { + raidDisk.setServerName(serverName); + } + } + + if (disk.getPartitions() != null) { + for (Partition partition : disk.getPartitions()) { + partition.setServerName(serverName); + } + } + } + } + + /** + * Skips (removes) the entities from given list till (including) the given {@code tillServer}, upto a maximum of + * {@code maxCount} entities
    + * + * @param entities + * List of entities to be pruned + * @param maxCount + * Maximum number of entities to be returned + * @param tillEntity + * A list of entities after skipping the ones appearing before, and including {@code tillEntity}. If the + * resulting list is bigger than {@code maxCount}, then the first {@code maxCount} number of entities + * will be returned. + */ + public static List skipEntities(List entities, Integer maxCount, String tillEntity) { + List servers = skipEntitiesTill(entities, tillEntity); + return skipEntitiesByMaxCount(servers, maxCount); + } + + /** + * Removes extra entities from given list to return the first (or maximum of) {@code maxCount} entities
    + * + * @param entities + * List of entities to be pruned + * @param maxCount + * Maximum number of entities to be returned + * @param tillEntity + * the first (or a maximum of) {@code maxCount} entities from the given list + */ + public static List skipEntitiesByMaxCount(List entities, Integer maxCount) { + if(maxCount == null || maxCount <= 0 || maxCount > entities.size()) { + return entities; + } + + return entities.subList(0, maxCount); + } + + /** + * Skips (removes) the entities from given list till (including) the given entity.
    + * + * @param entities + * List of entities to be pruned + * @param tillEntity + * A list of entities after skipping the ones appearing before, and including {@code tillEntity} + */ + public static List skipEntitiesTill(List entities, String tillEntity) { + if(tillEntity == null) { + return entities; + } + + int index = indexOfEntity(entities, tillEntity); + if(index == -1) { + // given entity not found. return an empty list. + return new ArrayList(); + } else { + return entities.subList(index + 1, entities.size()); + } + } + + public static int indexOfEntity(List entities, String entityName) { + int index = -1; + for(int i = 0; i < entities.size(); i++) { + if(entities.get(i).getName().equalsIgnoreCase(entityName)) { + index = i; + break; + } + } + return index; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/JavaUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/JavaUtil.java new file mode 100644 index 00000000..6487c0bf --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/JavaUtil.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import java.util.List; + +/** + * + */ +public class JavaUtil { + @SuppressWarnings("rawtypes") + public static boolean listsDiffer(List list1, List list2) { + if(list1.size() != list2.size()) { + return true; + } + + for(Object obj : list1) { + if(!list2.contains(obj)) { + return true; + } + } + + return false; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/LRUCache.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/LRUCache.java new file mode 100644 index 00000000..67b35476 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/LRUCache.java @@ -0,0 +1,55 @@ +/** + * LRUCache.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.core.utils; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * An LRU cache, based on LinkedHashMap. + *

    + * This cache has a fixed maximum number of elements (cacheSize). If the cache is full and another entry is + * added, the LRU (least recently used) entry is dropped. + * + */ +public class LRUCache extends LinkedHashMap { + + private static final long serialVersionUID = 1L; + private static final float loadFactor = 0.75f; + private int cacheSize; + + /** + * Creates a new LRU cache. + * + * @param cacheSize + * the maximum number of entries that will be kept in this cache. + */ + public LRUCache(int cacheSize) { + super((int) Math.ceil(cacheSize / loadFactor) + 1, loadFactor, true); + this.cacheSize = cacheSize; + } + + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > cacheSize; + } + +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5.java new file mode 100644 index 00000000..08f38fb8 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5.java @@ -0,0 +1,504 @@ +/* + * MD5 in Java JDK Beta-2 + * written Santeri Paavolainen, Helsinki Finland 1996 + * (c) Santeri Paavolainen, Helsinki Finland 1996 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * See http://www.cs.hut.fi/~santtu/java/ for more information on this + * class. + * + * This is rather straight re-implementation of the reference implementation + * given in RFC1321 by RSA. + * + * Passes MD5 test suite as defined in RFC1321. + * + * + * This Java class has been derivedfrom the RSA Data Security, Inc. MD5 + * Message-Digest Algorithm and its reference implementation. + * + * + * $Log: MD5.java,v $ + * Revision 1.1 2004/07/12 13:35:20 aubryp + * initial commit + * + * Revision 1.3 2002/03/16 01:46:39 broccol + * Moved the MD5 classes into the md5 package to make 1.4 javac happy + * + * Revision 1.2 1999/11/04 21:38:00 broccol + * Got MD5Crypt calculating the same hash as the OpenBSD md5crypt.c routine. + * + * Revision 1.1 1999/08/05 22:07:03 broccol + * Added support for the MD5 classes. + * + * Revision 1.3 1996/04/15 07:28:09 santtu + * Added GPL statements, and RSA derivate statements. + * + * Revision 1.2 1996/03/04 08:05:48 santtu + * Added offsets to Update method + * + * Revision 1.1 1996/01/07 20:51:59 santtu + * Initial revision + * + */ +package org.gluster.storage.management.core.utils; + +/** + * Contains internal state of the MD5 class + * + * @author Santeri Paavolainen + */ + +class MD5State { + /** + * 128-byte state + */ + int state[]; + + /** + * 64-bit character count (could be true Java long?) + */ + int count[]; + + /** + * 64-byte buffer (512 bits) for storing to-be-hashed characters + */ + byte buffer[]; + + public MD5State() { + buffer = new byte[64]; + count = new int[2]; + state = new int[4]; + + state[0] = 0x67452301; + state[1] = 0xefcdab89; + state[2] = 0x98badcfe; + state[3] = 0x10325476; + + count[0] = count[1] = 0; + } + + /** Create this State as a copy of another state */ + public MD5State(MD5State from) { + this (); + + int i; + + for (i = 0; i < buffer.length; i++) + this .buffer[i] = from.buffer[i]; + + for (i = 0; i < state.length; i++) + this .state[i] = from.state[i]; + + for (i = 0; i < count.length; i++) + this .count[i] = from.count[i]; + } +}; + +/** + * Implementation of RSA's MD5 hash generator + * + * @version $Revision: 1.1 $ + * @author Santeri Paavolainen + */ + +public class MD5 { + /** + * MD5 state + */ + MD5State state; + + /** + * If Final() has been called, finals is set to the current finals + * state. Any Update() causes this to be set to null. + */ + MD5State finals; + + /** + * Padding for Final() + */ + static byte padding[] = { (byte) 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + /** + * Initialize MD5 internal state (object can be reused just by + * calling Init() after every Final() + */ + public synchronized void Init() { + state = new MD5State(); + finals = null; + } + + /** + * Class constructor + */ + public MD5() { + this .Init(); + } + + /** + * Initialize class, and update hash with ob.toString() + * + * @param ob Object, ob.toString() is used to update hash + * after initialization + */ + public MD5(Object ob) { + this (); + Update(ob.toString()); + } + + public String debugDump() { + return asHex(); + } + + private int rotate_left(int x, int n) { + return (x << n) | (x >>> (32 - n)); + } + + /* I wonder how many loops and hoops you'll have to go through to + get unsigned add for longs in java */ + + private int uadd(int a, int b) { + long aa, bb; + aa = ((long) a) & 0xffffffffL; + bb = ((long) b) & 0xffffffffL; + + aa += bb; + + return (int) (aa & 0xffffffffL); + } + + private int uadd(int a, int b, int c) { + return uadd(uadd(a, b), c); + } + + private int uadd(int a, int b, int c, int d) { + return uadd(uadd(a, b, c), d); + } + + private int FF(int a, int b, int c, int d, int x, int s, int ac) { + a = uadd(a, ((b & c) | (~b & d)), x, ac); + return uadd(rotate_left(a, s), b); + } + + private int GG(int a, int b, int c, int d, int x, int s, int ac) { + a = uadd(a, ((b & d) | (c & ~d)), x, ac); + return uadd(rotate_left(a, s), b); + } + + private int HH(int a, int b, int c, int d, int x, int s, int ac) { + a = uadd(a, (b ^ c ^ d), x, ac); + return uadd(rotate_left(a, s), b); + } + + private int II(int a, int b, int c, int d, int x, int s, int ac) { + a = uadd(a, (c ^ (b | ~d)), x, ac); + return uadd(rotate_left(a, s), b); + } + + private int[] Decode(byte buffer[], int len, int shift) { + int out[]; + int i, j; + + out = new int[16]; + + for (i = j = 0; j < len; i++, j += 4) { + out[i] = ((int) (buffer[j + shift] & 0xff)) + | (((int) (buffer[j + 1 + shift] & 0xff)) << 8) + | (((int) (buffer[j + 2 + shift] & 0xff)) << 16) + | (((int) (buffer[j + 3 + shift] & 0xff)) << 24); + } + + return out; + } + + private void Transform(MD5State state, byte buffer[], int shift) { + int a = state.state[0], b = state.state[1], c = state.state[2], d = state.state[3], x[]; + + x = Decode(buffer, 64, shift); + + /* Round 1 */ + a = FF(a, b, c, d, x[0], 7, 0xd76aa478); /* 1 */ + d = FF(d, a, b, c, x[1], 12, 0xe8c7b756); /* 2 */ + c = FF(c, d, a, b, x[2], 17, 0x242070db); /* 3 */ + b = FF(b, c, d, a, x[3], 22, 0xc1bdceee); /* 4 */ + a = FF(a, b, c, d, x[4], 7, 0xf57c0faf); /* 5 */ + d = FF(d, a, b, c, x[5], 12, 0x4787c62a); /* 6 */ + c = FF(c, d, a, b, x[6], 17, 0xa8304613); /* 7 */ + b = FF(b, c, d, a, x[7], 22, 0xfd469501); /* 8 */ + a = FF(a, b, c, d, x[8], 7, 0x698098d8); /* 9 */ + d = FF(d, a, b, c, x[9], 12, 0x8b44f7af); /* 10 */ + c = FF(c, d, a, b, x[10], 17, 0xffff5bb1); /* 11 */ + b = FF(b, c, d, a, x[11], 22, 0x895cd7be); /* 12 */ + a = FF(a, b, c, d, x[12], 7, 0x6b901122); /* 13 */ + d = FF(d, a, b, c, x[13], 12, 0xfd987193); /* 14 */ + c = FF(c, d, a, b, x[14], 17, 0xa679438e); /* 15 */ + b = FF(b, c, d, a, x[15], 22, 0x49b40821); /* 16 */ + + /* Round 2 */ + a = GG(a, b, c, d, x[1], 5, 0xf61e2562); /* 17 */ + d = GG(d, a, b, c, x[6], 9, 0xc040b340); /* 18 */ + c = GG(c, d, a, b, x[11], 14, 0x265e5a51); /* 19 */ + b = GG(b, c, d, a, x[0], 20, 0xe9b6c7aa); /* 20 */ + a = GG(a, b, c, d, x[5], 5, 0xd62f105d); /* 21 */ + d = GG(d, a, b, c, x[10], 9, 0x2441453); /* 22 */ + c = GG(c, d, a, b, x[15], 14, 0xd8a1e681); /* 23 */ + b = GG(b, c, d, a, x[4], 20, 0xe7d3fbc8); /* 24 */ + a = GG(a, b, c, d, x[9], 5, 0x21e1cde6); /* 25 */ + d = GG(d, a, b, c, x[14], 9, 0xc33707d6); /* 26 */ + c = GG(c, d, a, b, x[3], 14, 0xf4d50d87); /* 27 */ + b = GG(b, c, d, a, x[8], 20, 0x455a14ed); /* 28 */ + a = GG(a, b, c, d, x[13], 5, 0xa9e3e905); /* 29 */ + d = GG(d, a, b, c, x[2], 9, 0xfcefa3f8); /* 30 */ + c = GG(c, d, a, b, x[7], 14, 0x676f02d9); /* 31 */ + b = GG(b, c, d, a, x[12], 20, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + a = HH(a, b, c, d, x[5], 4, 0xfffa3942); /* 33 */ + d = HH(d, a, b, c, x[8], 11, 0x8771f681); /* 34 */ + c = HH(c, d, a, b, x[11], 16, 0x6d9d6122); /* 35 */ + b = HH(b, c, d, a, x[14], 23, 0xfde5380c); /* 36 */ + a = HH(a, b, c, d, x[1], 4, 0xa4beea44); /* 37 */ + d = HH(d, a, b, c, x[4], 11, 0x4bdecfa9); /* 38 */ + c = HH(c, d, a, b, x[7], 16, 0xf6bb4b60); /* 39 */ + b = HH(b, c, d, a, x[10], 23, 0xbebfbc70); /* 40 */ + a = HH(a, b, c, d, x[13], 4, 0x289b7ec6); /* 41 */ + d = HH(d, a, b, c, x[0], 11, 0xeaa127fa); /* 42 */ + c = HH(c, d, a, b, x[3], 16, 0xd4ef3085); /* 43 */ + b = HH(b, c, d, a, x[6], 23, 0x4881d05); /* 44 */ + a = HH(a, b, c, d, x[9], 4, 0xd9d4d039); /* 45 */ + d = HH(d, a, b, c, x[12], 11, 0xe6db99e5); /* 46 */ + c = HH(c, d, a, b, x[15], 16, 0x1fa27cf8); /* 47 */ + b = HH(b, c, d, a, x[2], 23, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + a = II(a, b, c, d, x[0], 6, 0xf4292244); /* 49 */ + d = II(d, a, b, c, x[7], 10, 0x432aff97); /* 50 */ + c = II(c, d, a, b, x[14], 15, 0xab9423a7); /* 51 */ + b = II(b, c, d, a, x[5], 21, 0xfc93a039); /* 52 */ + a = II(a, b, c, d, x[12], 6, 0x655b59c3); /* 53 */ + d = II(d, a, b, c, x[3], 10, 0x8f0ccc92); /* 54 */ + c = II(c, d, a, b, x[10], 15, 0xffeff47d); /* 55 */ + b = II(b, c, d, a, x[1], 21, 0x85845dd1); /* 56 */ + a = II(a, b, c, d, x[8], 6, 0x6fa87e4f); /* 57 */ + d = II(d, a, b, c, x[15], 10, 0xfe2ce6e0); /* 58 */ + c = II(c, d, a, b, x[6], 15, 0xa3014314); /* 59 */ + b = II(b, c, d, a, x[13], 21, 0x4e0811a1); /* 60 */ + a = II(a, b, c, d, x[4], 6, 0xf7537e82); /* 61 */ + d = II(d, a, b, c, x[11], 10, 0xbd3af235); /* 62 */ + c = II(c, d, a, b, x[2], 15, 0x2ad7d2bb); /* 63 */ + b = II(b, c, d, a, x[9], 21, 0xeb86d391); /* 64 */ + + state.state[0] += a; + state.state[1] += b; + state.state[2] += c; + state.state[3] += d; + } + + /** + * Updates hash with the bytebuffer given (using at maximum length bytes from + * that buffer) + * + * @param stat Which state is updated + * @param buffer Array of bytes to be hashed + * @param offset Offset to buffer array + * @param length Use at maximum `length' bytes (absolute + * maximum is buffer.length) + */ + public void Update(MD5State stat, byte buffer[], int offset, + int length) { + int index, partlen, i, start; + + finals = null; + + /* Length can be told to be shorter, but not inter */ + if ((length - offset) > buffer.length) + length = buffer.length - offset; + + /* compute number of bytes mod 64 */ + index = (int) (stat.count[0] >>> 3) & 0x3f; + + if ((stat.count[0] += (length << 3)) < (length << 3)) + stat.count[1]++; + + stat.count[1] += length >>> 29; + + partlen = 64 - index; + + if (length >= partlen) { + for (i = 0; i < partlen; i++) + stat.buffer[i + index] = buffer[i + offset]; + + Transform(stat, stat.buffer, 0); + + for (i = partlen; (i + 63) < length; i += 64) + Transform(stat, buffer, i); + + index = 0; + } else + i = 0; + + /* buffer remaining input */ + if (i < length) { + start = i; + for (; i < length; i++) + stat.buffer[index + i - start] = buffer[i + offset]; + } + } + + /* + * Update()s for other datatypes than byte[] also. Update(byte[], int) + * is only the main driver. + */ + + /** + * Plain update, updates this object + */ + + public void Update(byte buffer[], int offset, int length) { + Update(this .state, buffer, offset, length); + } + + public void Update(byte buffer[], int length) { + Update(this .state, buffer, 0, length); + } + + /** + * Updates hash with given array of bytes + * + * @param buffer Array of bytes to use for updating the hash + */ + public void Update(byte buffer[]) { + Update(buffer, 0, buffer.length); + } + + /** + * Updates hash with a single byte + * + * @param b Single byte to update the hash + */ + public void Update(byte b) { + byte buffer[] = new byte[1]; + buffer[0] = b; + + Update(buffer, 1); + } + + /** + * Update buffer with given string. + * + * @param s String to be update to hash (is used as + * s.getBytes()) + */ + public void Update(String s) { + byte chars[]; + + chars = s.getBytes(); + + Update(chars, chars.length); + } + + private byte[] Encode(int input[], int len) { + int i, j; + byte out[]; + + out = new byte[len]; + + for (i = j = 0; j < len; i++, j += 4) { + out[j] = (byte) (input[i] & 0xff); + out[j + 1] = (byte) ((input[i] >>> 8) & 0xff); + out[j + 2] = (byte) ((input[i] >>> 16) & 0xff); + out[j + 3] = (byte) ((input[i] >>> 24) & 0xff); + } + + return out; + } + + /** + * Returns array of bytes (16 bytes) representing hash as of the + * current state of this object. Note: getting a hash does not + * invalidate the hash object, it only creates a copy of the real + * state which is finalized. + * + * @return Array of 16 bytes, the hash of all updated bytes + */ + public synchronized byte[] Final() { + byte bits[]; + int index, padlen; + MD5State fin; + + if (finals == null) { + fin = new MD5State(state); + + bits = Encode(fin.count, 8); + + index = (int) ((fin.count[0] >>> 3) & 0x3f); + padlen = (index < 56) ? (56 - index) : (120 - index); + + Update(fin, padding, 0, padlen); + /**/ + Update(fin, bits, 0, 8); + + /* Update() sets finalds to null */ + finals = fin; + } + + return Encode(finals.state, 16); + } + + /** + * Turns array of bytes into string representing each byte as + * unsigned hex number. + * + * @param hash Array of bytes to convert to hex-string + * @return Generated hex string + */ + public static String asHex(byte hash[]) { + StringBuffer buf = new StringBuffer(hash.length * 2); + int i; + + for (i = 0; i < hash.length; i++) { + if (((int) hash[i] & 0xff) < 0x10) + buf.append("0"); + + buf.append(Long.toString((int) hash[i] & 0xff, 16)); + } + + return buf.toString(); + } + + /** + * Returns 32-character hex representation of this objects hash + * + * @return String of this object's hash + */ + public String asHex() { + return asHex(this .Final()); + } + + /** + * One-stop md5 string encrypting. + */ + + public static String md5crypt(String input) { + MD5 md5 = new MD5(); + md5.Init(); + md5.Update(input); + return md5.asHex(); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5Crypt.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5Crypt.java new file mode 100644 index 00000000..3d101ab6 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/MD5Crypt.java @@ -0,0 +1,339 @@ +/*------------------------------------------------------------------------------ + class + MD5Crypt + ------------------------------------------------------------------------------*/ + +package org.gluster.storage.management.core.utils; + + +/** + *

    This class defines a method, + * {@link MD5Crypt#crypt(java.lang.String, java.lang.String) crypt()}, which + * takes a password and a salt string and generates an OpenBSD/FreeBSD/Linux-compatible + * md5-encoded password entry.

    + * + *

    Created: 3 November 1999

    + *

    Release: $Name: $

    + *

    Version: $Revision: 1.1 $

    + *

    Last Mod Date: $Date: 2004/07/12 13:35:20 $

    + *

    Java Code By: Jonathan Abbey, jonabbey@arlut.utexas.edu

    + *

    Original C Version:

    + * ----------------------------------------------------------------------------
    + * "THE BEER-WARE LICENSE" (Revision 42):
    + *  wrote this file.  As long as you retain this notice you
    + * can do whatever you want with this stuff. If we meet some day, and you think
    + * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
    + * ----------------------------------------------------------------------------
    + * 

    + * + * @author Jonathan Abbey + */ +public final class MD5Crypt { + + /** + * + * Command line test rig. + * + */ + + static public void main(String argv[]) { + if ((argv.length < 1) || (argv.length > 3)) { + System.err + .println("Usage: MD5Crypt [-apache] password salt"); + System.exit(1); + } + + if (argv.length == 3) { + System.err.println(MD5Crypt.apacheCrypt(argv[1], argv[2])); + } else if (argv.length == 2) { + System.err.println(MD5Crypt.crypt(argv[0], argv[1])); + } else { + System.err.println(MD5Crypt.crypt(argv[0])); + } + + System.exit(0); + } + + static private final String SALTCHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + + static private final String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + + static private final String to64(long v, int size) { + StringBuffer result = new StringBuffer(); + + while (--size >= 0) { + result.append(itoa64.charAt((int) (v & 0x3f))); + v >>>= 6; + } + + return result.toString(); + } + + static private final void clearbits(byte bits[]) { + for (int i = 0; i < bits.length; i++) { + bits[i] = 0; + } + } + + /** + * convert an encoded unsigned byte value into a int + * with the unsigned value. + */ + + static private final int bytes2u(byte inp) { + return (int) inp & 0xff; + } + + /** + *

    This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible + * md5-encoded password hash from a plaintext password and a + * salt.

    + * + *

    The resulting string will be in the form '$1$<salt>$<hashed mess>

    + * + * @param password Plaintext password + * + * @return An OpenBSD/FreeBSD/Linux-compatible md5-hashed password field. + */ + + static public final String crypt(String password) { + StringBuffer salt = new StringBuffer(); + java.util.Random randgen = new java.util.Random(); + + /* -- */ + + while (salt.length() < 8) { + int index = (int) (randgen.nextFloat() * SALTCHARS.length()); + salt.append(SALTCHARS.substring(index, index + 1)); + } + + return MD5Crypt.crypt(password, salt.toString()); + } + + /** + *

    This method actually generates a OpenBSD/FreeBSD/Linux PAM compatible + * md5-encoded password hash from a plaintext password and a + * salt.

    + * + *

    The resulting string will be in the form '$1$<salt>$<hashed mess>

    + * + * @param password Plaintext password + * @param salt A short string to use to randomize md5. May start with $1$, which + * will be ignored. It is explicitly permitted to pass a pre-existing + * MD5Crypt'ed password entry as the salt. crypt() will strip the salt + * chars out properly. + * + * @return An OpenBSD/FreeBSD/Linux-compatible md5-hashed password field. + */ + + static public final String crypt(String password, String salt) { + return MD5Crypt.crypt(password, salt, "$1$"); + } + + /** + *

    This method generates an Apache MD5 compatible + * md5-encoded password hash from a plaintext password and a + * salt.

    + * + *

    The resulting string will be in the form '$apr1$<salt>$<hashed mess>

    + * + * @param password Plaintext password + * + * @return An Apache-compatible md5-hashed password string. + */ + + static public final String apacheCrypt(String password) { + StringBuffer salt = new StringBuffer(); + java.util.Random randgen = new java.util.Random(); + + /* -- */ + + while (salt.length() < 8) { + int index = (int) (randgen.nextFloat() * SALTCHARS.length()); + salt.append(SALTCHARS.substring(index, index + 1)); + } + + return MD5Crypt.apacheCrypt(password, salt.toString()); + } + + /** + *

    This method actually generates an Apache MD5 compatible + * md5-encoded password hash from a plaintext password and a + * salt.

    + * + *

    The resulting string will be in the form '$apr1$<salt>$<hashed mess>

    + * + * @param password Plaintext password + * @param salt A short string to use to randomize md5. May start with $apr1$, which + * will be ignored. It is explicitly permitted to pass a pre-existing + * MD5Crypt'ed password entry as the salt. crypt() will strip the salt + * chars out properly. + * + * @return An Apache-compatible md5-hashed password string. + */ + + static public final String apacheCrypt(String password, String salt) { + return MD5Crypt.crypt(password, salt, "$apr1$"); + } + + /** + *

    This method actually generates md5-encoded password hash from + * a plaintext password, a salt, and a magic string.

    + * + *

    There are two magic strings that make sense to use here.. '$1$' is the + * magic string used by the FreeBSD/Linux/OpenBSD MD5Crypt algorithm, and + * '$apr1$' is the magic string used by the Apache MD5Crypt algorithm.

    + * + *

    The resulting string will be in the form '<magic><salt>$<hashed mess>

    + * + * @param password Plaintext password @param salt A short string to + * use to randomize md5. May start with the magic string, which + * will be ignored. It is explicitly permitted to pass a + * pre-existing MD5Crypt'ed password entry as the salt. crypt() + * will strip the salt chars out properly. + * + * @return An md5-hashed password string. + */ + + static public final String crypt(String password, String salt, + String magic) { + /* This string is magic for this algorithm. Having it this way, + * we can get get better later on */ + + byte finalState[]; + MD5 ctx, ctx1; + long l; + + /* -- */ + + /* Refine the Salt first */ + + /* If it starts with the magic string, then skip that */ + + if (salt.startsWith(magic)) { + salt = salt.substring(magic.length()); + } + + /* It stops at the first '$', max 8 chars */ + + if (salt.indexOf('$') != -1) { + salt = salt.substring(0, salt.indexOf('$')); + } + + if (salt.length() > 8) { + salt = salt.substring(0, 8); + } + + ctx = new MD5(); + + ctx.Update(password); // The password first, since that is what is most unknown + ctx.Update(magic); // Then our magic string + ctx.Update(salt); // Then the raw salt + + /* Then just as many characters of the MD5(pw,salt,pw) */ + + ctx1 = new MD5(); + ctx1.Update(password); + ctx1.Update(salt); + ctx1.Update(password); + finalState = ctx1.Final(); + + for (int pl = password.length(); pl > 0; pl -= 16) { + ctx.Update(finalState, pl > 16 ? 16 : pl); + } + + /* the original code claimed that finalState was being cleared + to keep dangerous bits out of memory, but doing this is also + required in order to get the right output. */ + + clearbits(finalState); + + /* Then something really weird... */ + + for (int i = password.length(); i != 0; i >>>= 1) { + if ((i & 1) != 0) { + ctx.Update(finalState, 1); + } else { + ctx.Update(password.getBytes(), 1); + } + } + + finalState = ctx.Final(); + + /* + * and now, just to make sure things don't run too fast + * On a 60 Mhz Pentium this takes 34 msec, so you would + * need 30 seconds to build a 1000 entry dictionary... + * + * (The above timings from the C version) + */ + + for (int i = 0; i < 1000; i++) { + ctx1 = new MD5(); + + if ((i & 1) != 0) { + ctx1.Update(password); + } else { + ctx1.Update(finalState, 16); + } + + if ((i % 3) != 0) { + ctx1.Update(salt); + } + + if ((i % 7) != 0) { + ctx1.Update(password); + } + + if ((i & 1) != 0) { + ctx1.Update(finalState, 16); + } else { + ctx1.Update(password); + } + + finalState = ctx1.Final(); + } + + /* Now make the output string */ + + StringBuffer result = new StringBuffer(); + + result.append(magic); + result.append(salt); + result.append("$"); + + l = (bytes2u(finalState[0]) << 16) + | (bytes2u(finalState[6]) << 8) + | bytes2u(finalState[12]); + result.append(to64(l, 4)); + + l = (bytes2u(finalState[1]) << 16) + | (bytes2u(finalState[7]) << 8) + | bytes2u(finalState[13]); + result.append(to64(l, 4)); + + l = (bytes2u(finalState[2]) << 16) + | (bytes2u(finalState[8]) << 8) + | bytes2u(finalState[14]); + result.append(to64(l, 4)); + + l = (bytes2u(finalState[3]) << 16) + | (bytes2u(finalState[9]) << 8) + | bytes2u(finalState[15]); + result.append(to64(l, 4)); + + l = (bytes2u(finalState[4]) << 16) + | (bytes2u(finalState[10]) << 8) + | bytes2u(finalState[5]); + result.append(to64(l, 4)); + + l = bytes2u(finalState[11]); + result.append(to64(l, 2)); + + /* Don't leave anything around in vm they could use. */ + clearbits(finalState); + + return result.toString(); + } +} + diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/NumberUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/NumberUtil.java new file mode 100644 index 00000000..830526bb --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/NumberUtil.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import java.text.NumberFormat; + +public class NumberUtil { + public static final String formatNumber(double num) { + NumberFormat formatter = NumberFormat.getNumberInstance(); + formatter.setMinimumFractionDigits(2); + formatter.setMaximumFractionDigits(2); + return formatter.format(num); + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessResult.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessResult.java new file mode 100644 index 00000000..ccb7b1b8 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessResult.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents the result of a command execution in a separate process. Consists of the "exit status" of the process and + * output from the process. The output includes stdout as well as stderr streams + */ +@XmlRootElement +public class ProcessResult { + + public static final int SUCCESS = 0; + public static final int FAILURE = 1; + private int exitValue; + private String output; + + // Required for JAXB de-serialization + public ProcessResult() { + + } + + public ProcessResult(int exitValue, String output) { + this.exitValue = exitValue; + this.output = output; + } + + public int getExitValue() { + return exitValue; + } + + public void setExitValue(int exitValue) { + this.exitValue = exitValue; + } + + public String getOutput() { + return output; + } + + public void setOutput(String output) { + this.output = output; + } + + public boolean isSuccess() { + return exitValue == SUCCESS; + } + + @Override + public String toString() { + return "["+ getExitValue() + "][" + getOutput() + "]"; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessUtil.java new file mode 100644 index 00000000..f040d859 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ProcessUtil.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import static org.gluster.storage.management.core.constants.CoreConstants.NEWLINE; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; + + +/** + * Utility class for creating processes (foreground/background) with given + * command and checking the output/exit status + */ +public class ProcessUtil { + + public static ProcessResult executeCommand(List command) { + return executeCommand(true, command); + } + + /** + * Waits till all the threads in given list are dead + * @param threads Threads to watch + * @throws InterruptedException + */ + public static void waitForThreads(List threads) throws InterruptedException { + // Wait till all servers have been processed + for (int i = threads.size() - 1; i >= 0; i--) { + if (threads.get(i).isAlive()) { + // thread alive. sleep for half a second and check again. + Thread.sleep(500); + i++; // check the same thread in next iteration + } + } + } + + /** + * Executes given command in a separate process in FOREGROUND + * @param command + * @return {@link ProcessResult} object + */ + public static ProcessResult executeCommand(String... command) { + ArrayList commandList = new ArrayList(); + for (String part : command) { + commandList.add(part); + } + return executeCommand(commandList); + } + + /** + * Executes given command in foreground/background + * @param runInForeground Boolean flag indicating whether the command should + * be executed in foreground + * @param command + * @return {@link ProcessResult} object + */ + public static ProcessResult executeCommand(boolean runInForeground, List command) { + StringBuilder output = new StringBuilder(); + try { + Process process = new ProcessBuilder(command).redirectErrorStream(true).start(); + if (runInForeground) { + process.waitFor(); // Wait for process to finish + + InputStream is = process.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String line; + + while ((line = br.readLine()) != null) { + output.append(line); + output.append(NEWLINE); + } + br.close(); + isr.close(); + is.close(); + } else { + output.append("Command ["); + output.append(command); + output.append("] triggerred in background."); + } + + return new ProcessResult(process.exitValue(), output.toString()); + } catch (Throwable e) { + throw new GlusterRuntimeException("Exception while executing command [" + command + "] : [" + + e.getMessage() + "]", e); + } + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/StringUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/StringUtil.java new file mode 100644 index 00000000..b3b0a4b5 --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/StringUtil.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.core.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class StringUtil { + public static boolean filterString(String sourceString, String filterString, boolean caseSensitive) { + return caseSensitive ? sourceString.contains(filterString) : sourceString.toLowerCase().contains( + filterString.toLowerCase()); + } + + public static String removeSpaces(String str) { + return str.replaceAll("\\s+", ""); + } + + public static String collectionToString(Collection list, String delimiter) { + if (list.size() == 0) { + return ""; + } + StringBuilder output = new StringBuilder(); + for (Object element : list) { + output.append(element.toString()).append(delimiter); + } + String outputStr = output.toString(); + int endIndex = outputStr.length() - delimiter.length(); + return outputStr.substring(0, endIndex); + } + + public static > List enumToArray(T[] values) { + List enumAsArray = new ArrayList(); + for (T value : values) { + enumAsArray.add(value.toString()); + } + return enumAsArray; + } + + /** + * Extracts a list from a string by splitting it on given delimiter + * @param input the input string + * @return A {@link List} of extracted tokens + */ + public static List extractList(String input, String delim) { + String[] arr = input.split(delim); + List output = new ArrayList(); + for(String str : arr) { + String brick = str.trim(); + if(!brick.isEmpty()) { + output.add(brick); + } + } + return output; + } + + /** + * Extracts a map from a string by splitting it on the given primary and secondary delimiter. e.g. The input string + * k1=v1,k2=v2,k3=v3 will yield the following map:
    + * k1 -> v1
    + * k2 -> v2
    + * k3 -> v3
    + * where , is the primary delimiter and = is the secondary delimiter. + * + * @param input + * @param majorDelim + * @param minorDelim + * @return Map of key value pairs + */ + public static Map extractMap(String input, String majorDelim, String minorDelim) { + String[] arr = input.split(majorDelim); + Map output = new LinkedHashMap(); + for(String str : arr) { + String[] elements = str.split(minorDelim); + if(elements.length == 2) { + String key = elements[0].trim(); + String value = elements[1].trim(); + if(!key.isEmpty() && !value.isEmpty()) { + output.put(key, value); + } + } + } + return output; + } + + /** + * Extract value of given token from given line. It is assumed that the token, if present, will be of the following + * form: token: value + * + * @param line + * Line to be analyzed + * @param token + * Token whose value is to be extracted + * @return Value of the token, if present in the line + */ + public static String extractToken(String line, String token) { + if (line.contains(token)) { + return line.split(token)[1].trim(); + } + return null; + } +} diff --git a/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ValidationUtil.java b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ValidationUtil.java new file mode 100644 index 00000000..55659d3c --- /dev/null +++ b/src/org.gluster.storage.management.core/src/org/gluster/storage/management/core/utils/ValidationUtil.java @@ -0,0 +1,95 @@ +package org.gluster.storage.management.core.utils; + +import java.util.regex.Pattern; + +public class ValidationUtil { + + // Access control may contains IP with wild card(*), hostname and/or multiple ip/hostnames + public static boolean isValidAccessControl(String ac) { + String access[] = ac.split(","); + String ip; + boolean isValidAccessControl = true; + for (int i = 0; i < access.length && isValidAccessControl; i++) { + ip = access[i].trim(); + isValidAccessControl = (isValidIpWithWC(ip) || isValidHostName(ip)); + } + return isValidAccessControl; + } + + public static String getInvalidIpOrHostname(String ac) { + String access[] = ac.split(","); + String ip; + boolean isValidAccessControl = true; + for (int i = 0; i < access.length && isValidAccessControl; i++) { + ip = access[i].trim(); + if (!(isValidIpWithWC(ip) || isValidHostName(ip))) { + return access[i]; + } + } + return ""; + } + + public static boolean isValidIpWithWC(String ip) { + String ipAddress[] = ip.split("\\."); + boolean isValid = true; + + if (ip.equals("0.0.0.0") || ip.equals("255.255.255.255")) { // Invalidate the special ip's + isValid = false; + } + + int iterator=ipAddress.length-1; + + if (ipAddress.length <= 4 && ipAddress[ipAddress.length - 1].equals("*")) { + iterator = ipAddress.length - 2; + } else if (ipAddress.length < 4 || ipAddress.length > 4 ){ + isValid = false; + iterator = ipAddress.length - 1; + } + + for (int i = 0; i <= iterator && isValid; i++) { + if (ipAddress[i].equals("*")) { + isValid = (i == ipAddress.length - 1) ? isValid : false; + } else { + isValid = isValidIpQuad(ipAddress[i]); + } + } + return isValid; + } + + public static boolean isValidIp(String ip) { + String ipAddress[] = ip.split("\\."); + boolean isValid = true; + + if (ip.equals("0.0.0.0") || ip.equals("255.255.255.255")) { // Invalidate the special ip's + isValid = false; + } + if (ipAddress.length < 4) { + isValid = false; + } + for (int i = 0; i < ipAddress.length && isValid; i++) { + isValid = isValidIpQuad(ipAddress[i]); + } + return isValid; + } + + private static boolean isValidIpQuad(String ipQuad) { + Pattern pattern = Pattern.compile("([01]?\\d\\d?|2[0-4]\\d|25[0-5])"); + return pattern.matcher(ipQuad).matches(); + } + + public static boolean isValidHostName(String hostName) { + Pattern pattern = Pattern + .compile("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]*[A-Za-z0-9])$"); + return pattern.matcher(hostName).matches(); + } + + public static void main(String[] argv) { + String ip = "0.0.0.0"; + // System.out.println("Is valid ip (" + ip + ")? " + isValidIp(ip)); + String hostName = "myhost.q"; + // System.out.println(isValidHostName(hostName)); + // System.out.println(isValidHostName(hostName)); + System.out.println(isValidAccessControl(hostName)); + } + +} diff --git a/src/org.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch b/src/org.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch new file mode 100644 index 00000000..1cae618a --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/org.gluster.storage.management.gateway.scripts/.project b/src/org.gluster.storage.management.gateway.scripts/.project new file mode 100644 index 00000000..46369752 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/.project @@ -0,0 +1,22 @@ + + + org.gluster.storage.management.gateway.scripts + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch + + + + + + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py new file mode 100644 index 00000000..4d1b701a --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/DiskUtils.py @@ -0,0 +1,198 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import glob +import Globals +import Utils +import FsTabUtils + +def _stripDev(device): + if Utils.isString(device) and device.startswith("/dev/"): + return device[5:] + return device + + +def _addDev(deviceName): + if Utils.isString(deviceName) and not deviceName.startswith("/dev/"): + return "/dev/" + deviceName + return deviceName + + +def getDeviceName(device): + if type(device) == type([]): + nameList = [] + for d in device: + nameList.append(_stripDev(d)) + return nameList + return _stripDev(device) + + +def getDevice(deviceName): + if Utils.isString(deviceName): + return _addDev(deviceName) + if type(deviceName) == type([]): + nameList = [] + for d in deviceName: + nameList.append(_addDev(d)) + return nameList + return _addDev(deviceName) + + +def getDiskPartitionByUuid(uuid): + uuidFile = "/dev/disk/by-uuid/%s" % uuid + if os.path.exists(uuidFile): + return getDeviceName(os.path.realpath(uuidFile)) + return None + + +def getUuidByDiskPartition(device): + for uuidFile in glob.glob("/dev/disk/by-uuid/*"): + if os.path.realpath(uuidFile) == device: + return os.path.basename(uuidFile) + return None + + +def getDiskPartitionByLabel(label): + ## TODO: Finding needs to be enhanced + labelFile = "/dev/disk/by-label/%s" % label + if os.path.exists(labelFile): + if os.path.islink(labelFile): + return getDeviceName(os.path.realpath(labelFile)) + return None + + +def getDiskPartitionLabel(device): + rv = Utils.runCommand("e2label %s" % device, output=True, root=True) + if rv["Status"] == 0: + return rv["Stdout"].strip() + return False + + +def getDiskInfo(diskNameList=None): + procPartitionsDict = getProcPartitions() + diskDict = {} + for name, values in procPartitionsDict.iteritems(): + values["Description"] = None + values["Uuid"] = None + values["FsType"] = None + values["MountPoint"] = None + values["SpaceInUse"] = None + values["Member"] = None + ## extras ?!?! + values["Init"] = False + values["Status"] = None + values["Interface"] = None + values["DriveType"] = None + values["Type"] = None + values["FsVersion"] = None + values["ReadOnlyAccess"] = None + + device = getDevice(name) + values["Uuid"] = getUuidByDiskPartition(device) + rv = Utils.runCommand("blkid -c /dev/null -o value %s" % device, output=True, root=True) + if rv["Status"] == 0: + lines = rv["Stdout"].strip().split("\n") + values["FsType"] = lines[-1].strip() + values["MountPoint"] = getDeviceMountPoint(device) + if values["FsType"]: + values["Init"] = True + if values["MountPoint"]: + rv = Utils.runCommand(["df", values["MountPoint"]], output=True) + if rv["Status"] == 0: + try: + values["SpaceInUse"] = long(rv["Stdout"].split("\n")[1].split()[2]) + except IndexError, e: + pass + except ValueError, e: + pass + if os.path.isdir("/sys/block/%s" % name): + model = Utils.readFile("/sys/block/%s/device/model" % name) + vendor = Utils.readFile("/sys/block/%s/device/vendor" % name) + values["Description"] = "%s %s" % (model.strip(), vendor.strip()) + values["Partitions"] = {} + diskDict[name] = values + + for diskName in diskDict.keys(): + del procPartitionsDict[diskName] + for partName, values in procPartitionsDict.iteritems(): + if os.path.isdir("/sys/block/%s/%s" % (diskName, partName)): + diskDict[diskName]["Partitions"][partName] = values + + procMdstatDict = getProcMdstat() + for name, values in procMdstatDict.iteritems(): + try: + diskDict[name]["Description"] = "Software Raid Array - %s - %s" % (values["Type"], values["Status"]) + diskDict[name]["Member"] = values["Member"] + except KeyError, e: + pass + + diskNameList = getDeviceName(diskNameList) + if Utils.isString(diskNameList): + diskNameList = [diskNameList] + + if not diskNameList: + return diskDict + + outputDict = {} + for diskName in list(set(diskDict.keys()).intersection(set(diskNameList))): + outputDict[diskName] = diskDict[diskName] + return outputDict + + +def isDataDiskPartitionFormatted(device): + rv = Utils.runCommand("blkid -c /dev/null -o value %s" % device, output=True, root=True) + if rv["Status"] != 0: + return False + + uuid = getUuidByDiskPartition(device) + if not uuid: + return False + + for fsTabEntry in FsTabUtils.readFsTab(): + if fsTabEntry["Device"] == ("UUID=%s" % uuid) or fsTabEntry["Device"] == device: + return True + return False + + +def isDiskInFormatting(device): + DEVICE_FORMAT_LOCK_FILE = "/var/lock/%s.lock" % device + return os.path.exists(DEVICE_FORMAT_LOCK_FILE) + + +def getDeviceMountPoint(device): + lines = Utils.readFile("/proc/mounts", lines=True) + uuid = getUuidByDiskPartition(device) + for line in lines: + tokens = line.split() + if tokens[0] == device or (uuid and tokens[0].endswith(uuid)): + return tokens[1] + return None + +def getProcPartitions(): + procPartitionsDict = {} + s = Utils.readFile("/proc/partitions", lines=True) + for line in s[2:]: + tokens = line.strip().split() + procPartitionsDict[tokens[3]] = {"Size" : long(tokens[2])} + return procPartitionsDict + +def getProcMdstat(): + raidArrayDict = {} + lines = Utils.readFile("/proc/mdstat", lines=True) + for line in lines[1:]: + tokens = line.strip().split() + if not tokens: + continue + if tokens[0].startswith("md"): + raidArrayDict[tokens[0]] = {"Status" : tokens[2], "Type" : tokens[3], "Member" : [token.split('[')[0] for token in tokens[4:]]} + return raidArrayDict diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py new file mode 100644 index 00000000..653d0dda --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/FsTabUtils.py @@ -0,0 +1,83 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils +import Globals + +def readFsTab(fsTabFile=Globals.FSTAB_FILE): + lines = Utils.readFile(fsTabFile) + + fsTabEntryList = [] + for line in lines: + tokens = line.strip().split() + if not tokens or tokens[0].startswith('#'): + continue + fsTabEntry = {} + fsTabEntry["Device"] = None + fsTabEntry["MountPoint"] = None + fsTabEntry["FsType"] = None + fsTabEntry["Options"] = None + fsTabEntry["DumpOption"] = 0 + fsTabEntry["fsckOrder"] = 0 + try: + fsTabEntry["Device"] = tokens[0] + fsTabEntry["MountPoint"] = tokens[1] + fsTabEntry["FsType"] = tokens[2] + fsTabEntry["Options"] = tokens[3] + fsTabEntry["DumpOption"] = tokens[4] + fsTabEntry["fsckOrder"] = tokens[5] + except IndexError, e: + pass + if fsTabEntry["Device"] and fsTabEntry["MountPoint"] and fsTabEntry["FsType"] and fsTabEntry["Options"]: + fsTabEntryList.append(fsTabEntry) + return fsTabEntryList + +def writeFsTab(fsTabEntryList, fsTabFile=Globals.FSTAB_FILE): + try: + fsTabfp = open(fsTabFile, "w") + for fsTabEntry in fsTabEntryList: + fsTabfp.write("%s\t%s\t%s\t%s\t%s\t%s\n" % + (fsTabEntry["Device"], fsTabEntry["MountPoint"], + fsTabEntry["FsType"], fsTabEntry["Options"], + fsTabEntry["DumpOption"], fsTabEntry["fsckOrder"])) + fsTabfp.close() + except IOError, e: + log("writeFsTab(): " + str(e)) + return False + return True + +def addFsTabEntry(fsTabEntry, fsTabFile=Globals.FSTAB_FILE): + try: + fsTabfp = open(fsTabFile, "a") + fsTabfp.write("%s\t%s\t%s\t%s\t%s\t%s\n" % + (fsTabEntry["Device"], fsTabEntry["MountPoint"], + fsTabEntry["FsType"], fsTabEntry["Options"], + fsTabEntry["DumpOption"], fsTabEntry["fsckOrder"])) + fsTabfp.close() + except IOError, e: + log("addFsTabEntry(): " + str(e)) + return False + return True + +def removeFsTabEntry(fsTabEntry, fsTabFile=Globals.FSTAB_FILE): + fsTabEntryList = readFsTab(fsTabFile) + if not fsTabEntryList: + return False + + try: + fsTabEntryList.remove(fsTabEntry) + except ValueError, e: + return False + + return writeFsTab(fsTabEntryList, fsTabFile) + diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py new file mode 100755 index 00000000..ff73af6f --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/NetworkUtils.py @@ -0,0 +1,152 @@ +# Copyright (c) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + +def readResolvConfFile(fileName=None): + nameServerList = [] + domain = None + searchDomain = None + if not fileName: + fileName = Globals.RESOLV_CONF_FILE + lines = Utils.readFile(fileName, lines=True) + for line in lines: + tokens = line.split("#")[0].strip().split() + if len(tokens) < 2: + continue + if tokens[0].upper() == "NAMESERVER": + nameServerList.append(tokens[1]) + continue + if tokens[0].upper() == "DOMAIN": + domain = tokens[1:] + continue + if tokens[0].upper() == "SEARCH": + searchDomain = tokens[1:] + continue + return nameServerList, domain, searchDomain + + +def readIfcfgConfFile(deviceName, root=""): + conf = {} + fileName = "%s%s/ifcfg-%s" % (root, Globals.SYSCONFIG_NETWORK_DIR, deviceName) + lines = Utils.readFile(fileName, lines=True) + for line in lines: + tokens = line.split("#")[0].split("=") + if len(tokens) != 2: + continue + conf[tokens[0].strip().lower()] = tokens[1].strip() + return conf + + +def getBondMode(deviceName, fileName=None): + if not fileName: + fileName = Globals.MODPROBE_CONF_FILE + lines = Utils.readFile(fileName, lines=True) + for line in lines: + tokens = line.split("#")[0].split() + if len(tokens) < 4: + continue + if tokens[0].upper() == "OPTIONS" and tokens[1] == deviceName: + if tokens[2].startswith("mode="): + return tokens[2].split("=")[1] + if tokens[3].startswith("mode="): + return tokens[3].split("=")[1] + if tokens[4].startswith("mode="): + return tokens[4].split("=")[1] + if tokens[5].startswith("mode="): + return tokens[5].split("=")[1] + return None + + +def getNetDeviceList(root=""): + netDeviceList = {} + for deviceName in os.listdir("/sys/class/net/"): + netDevice = {} + netDevice["description"] = None + netDevice["hwaddr"] = None + netDevice["type"] = None + netDevice["onboot"] = None + netDevice["bootproto"] = None + netDevice["gateway"] = None + netDevice["peerdns"] = None + netDevice["autodns"] = None + netDevice["dns1"] = None + netDevice["dns2"] = None + netDevice["dns3"] = None + netDevice["master"] = None + netDevice["slave"] = None + netDevice["nmcontrolled"] = None + netDevice["link"] = None + netDevice["mode"] = None + netDevice["speed"] = None + netDevice["device"] = deviceName + netDevice["description"] = deviceName + netDevice["ipaddr"] = None + netDevice["netmask"] = None + netDevice["hwaddr"] = Utils.readFile("/sys/class/net/%s/address" % deviceName).strip() + + rv = Utils.runCommand("ifconfig %s" % deviceName, output=True) + if rv["Status"] == 0: + for line in rv["Stdout"].split("\n"): + if line.find("Link encap:") != -1: + netDevice["type"] = line.split("Link encap:")[1].split()[0] + continue + if line.find("inet addr:") != -1: + tokens = line.split("inet addr:")[1].split() + netDevice["ipaddr"] = tokens[0] + if line.find("Mask:") != -1: + netDevice["netmask"] = line.split("Mask:")[1].split()[0] + #print tokens[1].split(":")[1] + + rv = Utils.runCommand("ethtool %s" % deviceName, output=True, root=True) + if rv["Status"] == 0: + for line in rv["Stdout"].split("\n"): + if line.find("Speed: ") != -1: + netDevice["speed"] = line.split("Speed: ")[1].upper().split("MB")[0] + elif line.find("Link detected: ") != -1: + netDevice["link"] = line.split("Link detected: ")[1] + + rv = Utils.runCommand("route -n", output=True, root=True) + if rv["Status"] == 0: + for line in rv["Stdout"].split("\n"): + tokens = line.split() + if len(tokens) == 8 and tokens[-1] == deviceName and tokens[3] == "UG": + netDevice["gateway"] = tokens[1] + + netDevice["mode"] = getBondMode(deviceName, root + Globals.MODPROBE_CONF_FILE) + + netDeviceList[deviceName] = netDevice + + conf = readIfcfgConfFile(deviceName, root) + if not conf: + continue + try: + if not netDevice["ipaddr"]: + netDevice["ipaddr"] = conf["ipaddr"] + if not netDevice["netmask"]: + netDevice["netmask"] = conf["netmask"] + if not netDevice["gateway"]: + netDevice["gateway"] = conf["gateway"] + netDevice["onboot"] = conf["onboot"] + netDevice["bootproto"] = conf["bootproto"] + netDevice["peerdns"] = conf["peerdns"] + netDevice["autodns"] = conf["autodns"] + netDevice["dns1"] = conf["dns1"] + netDevice["dns2"] = conf["dns2"] + netDevice["dns3"] = conf["dns3"] + netDevice["master"] = conf["master"] + netDevice["slave"] = conf["slave"] + netDevice["nmcontrolled"] = conf["nmcontrolled"] + except KeyError, e: + pass + return netDeviceList diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py new file mode 100644 index 00000000..5476e090 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/VolumeUtils.py @@ -0,0 +1,95 @@ +# Copyright (c) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def readVolumeSmbConfFile(fileName=Globals.VOLUME_SMBCONF_FILE): + entryList = [] + lines = Utils.readFile(fileName, lines=True) + for line in lines: + tokens = line.split("#")[0].strip().split(";")[0].strip().split("=") + if len(tokens) != 2: + continue + if tokens[0].strip().upper() == "INCLUDE": + entryList.append(tokens[1].strip()) + return entryList + + +def writeVolumeSmbConfFile(entryList, fileName=Globals.VOLUME_SMBCONF_FILE): + try: + fp = open(fileName, "w") + for entry in entryList: + fp.write("include = %s\n" % entry) + fp.close() + return True + except IOError, e: + Utils.log("Failed to write file %s: %s" % (fileName, str(e))) + return False + + +def includeVolume(volumeName, fileName=Globals.VOLUME_SMBCONF_FILE): + volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) + if not os.path.exists(volumeFile): + return False + entryList = readVolumeSmbConfFile(fileName) + if volumeFile in entryList: + return True + entryList.append(volumeFile) + return writeVolumeSmbConfFile(entryList, fileName) + + +def excludeVolume(volumeName, fileName=Globals.VOLUME_SMBCONF_FILE): + volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) + if not os.path.exists(volumeFile): + return False + entryList = readVolumeSmbConfFile(fileName) + if volumeFile not in entryList: + return True + entryList.remove(volumeFile) + Utils.log("entryList = %s" % entryList) + return writeVolumeSmbConfFile(entryList, fileName) + + +def writeVolumeCifsConfiguration(volumeName, userList, adminUser=None): + volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) + try: + fp = open(volumeFile, "w") + fp.write("[%s]\n" % volumeName) + fp.write(" comment = %s volume served by Gluster\n" % volumeName) + fp.write(" path = %s/%s\n" % (Globals.CIFS_EXPORT_DIR, volumeName)) + fp.write(" guest ok = yes\n") + fp.write(" public = yes\n") + fp.write(" writable = yes\n") + if adminUser: + fp.write(" admin users = %s, %s\n" % (adminUser, ", ".join(userList))) + fp.write(" valid users = %s, %s\n" % (adminUser, ", ".join(userList))) + else: + fp.write(" admin users = %s\n" % (", ".join(userList))) + fp.write(" valid users = %s\n" % (", ".join(userList))) + fp.close() + return True + except IOError, e: + Utils.log("Failed to write file %s: %s" % (volumeFile, str(e))) + return False + + +def removeVolumeCifsConfiguration(volumeName): + volumeFile = "%s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) + try: + os.remove(volumeFile) + return True + except OSError, e: + Utils.log("Failed to remove file %s: %s" % (volumeFile, str(e))) + return False + diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py new file mode 100755 index 00000000..2e1a1574 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/add_user_cifs.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import grp +import pwd +import Globals +import Utils + +def main(): + if len(sys.argv) < 4: + sys.stderr.write("usage: %s UID USERNAME PASSWORD\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + try: + uid = int(sys.argv[1]) + except ValueError, e: + sys.stderr.write("invalid uid %s\n" % sys.argv[1]) + sys.exit(-2) + userName = sys.argv[2] + password = sys.argv[3] + + try: + groupInfo = grp.getgrnam(userName) + if uid != groupInfo.gr_gid: + Utils.log("group %s exists with different gid %s\n" % (userName, groupInfo.gr_gid)) + sys.stderr.write("Group %s exists with different gid %s\n" % (userName, groupInfo.gr_gid)) + sys.exit(1) + except KeyError, e: + if Utils.runCommand("groupadd -g %s %s" % (uid, userName)) != 0: + Utils.log("failed to add group %s gid %s\n" % (userName, uid)) + sys.stderr.write("Failed to add group %s gid %s\n" % (userName, uid)) + sys.exit(2) + try: + userInfo = pwd.getpwnam(userName) + if uid != userInfo.pw_uid: + Utils.log("user %s exists with different uid %s\n" % (userName, userInfo.pw_uid)) + sys.stderr.write("User %s exists with different uid %s\n" % (userName, userInfo.pw_uid)) + sys.exit(3) + except KeyError, e: + command = ["useradd", "-c", Globals.VOLUME_USER_DESCRIPTION, "-M", "-d", "/", "-s", "/sbin/nologin", "-u", str(uid), "-g", str(uid), userName] + if Utils.runCommand(command) != 0: + Utils.log("failed to add user %s uid %s\n" % (userName, uid)) + sys.stderr.write("Failed to add user %s uid %s\n" % (userName, uid)) + sys.exit(4) + + if Utils.runCommand("smbpasswd -s -a %s" % userName, + input="%s\n%s\n" % (password, password)) != 0: + Utils.log("failed to set smbpassword of user %s\n" % userName) + sys.stderr.write("Failed to set smbpassword of user %s\n" % userName) + sys.exit(5) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py new file mode 100755 index 00000000..374a7e9c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/clear_volume_directory.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import time +import Utils +from optparse import OptionParser + +def main(): + parser = OptionParser() + parser.add_option("-d", "--delete", dest="todelete", action="store_true", default=False, help="force delete") + (options, args) = parser.parse_args() + + if len(args) != 1: + sys.stderr.write("usage: %s [-d | --delete] VOLUME_PATH\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeDirectory = args[0] + if not os.path.exists(volumeDirectory): + sys.stderr.write("Given volume directory path:%s does not exists\n" % volumeDirectory) + sys.exit(1) + + if '/' == volumeDirectory[-1]: + volumeDirectory = volumeDirectory[:-1] + + newVolumeDirectoryName = "%s_%s" % (volumeDirectory, time.time()) + if Utils.runCommand("mv -f %s %s" % (volumeDirectory, newVolumeDirectoryName), root=True) != 0: + sys.stderr.write("Failed to rename volume directory\n") + sys.exit(2) + + if options.todelete: + process = Utils.runCommandBG("rm -fr %s" % newVolumeDirectoryName, root=True) + if not process: + sys.exit(3) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py new file mode 100755 index 00000000..5a27ab87 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/create_volume_cifs.py @@ -0,0 +1,47 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import VolumeUtils + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + userList = sys.argv[2:] + + volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) + try: + if not os.path.exists(volumeMountDirName): + os.mkdir(volumeMountDirName) + except OSError, e: + Utils.log("failed creating %s: %s\n" % (volumeMountDirName, str(e))) + sys.stderr.write("Failed creating %s: %s\n" % (volumeMountDirName, str(e))) + sys.exit(1) + + if not VolumeUtils.writeVolumeCifsConfiguration(volumeName, userList): + sys.stderr.write("Failed to write volume cifs configuration\n") + sys.exit(2) + + if Utils.runCommand("service smb reload") != 0: + Utils.log("Failed to reload smb service") + sys.stderr.write("Failed to reload smb service\n") + sys.exit(3) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py new file mode 100755 index 00000000..aeda989f --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/delete_user_cifs.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +def main(): + if len(sys.argv) < 2: + sys.stderr.write("usage: %s USERNAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + userName = sys.argv[1] + + if Utils.runCommand("userdel %s" % userName) != 0: + Utils.log("failed to remove user name:%s\n" % userName) + sys.stderr.write("Failed to remove user name:%s\n" % userName) + sys.exit(1) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py new file mode 100755 index 00000000..572d819c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/delete_volume_cifs.py @@ -0,0 +1,40 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import VolumeUtils + +def main(): + if len(sys.argv) != 2: + sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + + volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) + try: + os.rmdir(volumeMountDirName) + except OSError, e: + Utils.log("failed deleting %s: %s\n" % (volumeMountDirName, str(e))) + sys.stderr.write("Failed deleting %s: %s\n" % (volumeMountDirName, str(e))) + sys.exit(1) + + if VolumeUtils.removeVolumeCifsConfiguration(volumeName): + sys.exit(0) + sys.stderr.write("Unable to remove volume cifs configuration\n") + sys.exit(2) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/format_device.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/format_device.py new file mode 100755 index 00000000..8630635c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/format_device.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +import stat +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import DiskUtils + +SIZE_TB_16 = 17179869184L + +def main(): + if Utils.runCommand("wget -t 1 -T 1 -q -O /dev/null %s" % Globals.AWS_WEB_SERVICE_URL) == 0: + sys.stderr.write("format device unsupported\n") + sys.exit(1) + + if len(sys.argv) != 4: + sys.stderr.write("usage: %s FSTYPE MOUNT_POINT DEVICE_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + fsType = sys.argv[1] + mountPoint = sys.argv[2] + device = DiskUtils.getDevice(sys.argv[3]) + deviceName = DiskUtils.getDeviceName(sys.argv[3]) + + if not os.path.exists(device): + sys.stderr.write("device %s not found\n" % sys.argv[3]) + sys.exit(2) + + try: + if not stat.S_ISBLK(os.stat(device).st_mode): + sys.stderr.write("%s is not a block device\n" % sys.argv[3]) + sys.exit(3) + except OSError, e: + Utils.log("unable to get device %s mode: %s" % (device, str(e))) + sys.stderr.write("unable to get device %s mode\n" % sys.argv[3]) + sys.exit(-2) + + if fsType in ['ext3', 'ext4', 'ext4dev']: + deviceSize = DiskUtils.getProcPartitions()[deviceName]['Size'] + if deviceSize >= SIZE_TB_16: + Utils.log("device %s, size %s is greater than %s size for fstype %s" % (device, deviceSize, SIZE_TB_16, fsType)) + sys.stderr.write("size of device %s is unsupported for fstype %s\n" % (sys.argv[3], fsType)) + sys.exit(4) + + if DiskUtils.isDataDiskPartitionFormatted(device): + sys.stderr.write("device %s already formatted\n" % sys.argv[3]) + sys.exit(5) + + if os.path.exists(mountPoint): + if not os.path.isdir(mountPoint): + sys.stderr.write("mount point %s exists but not a directory" % mountPoint) + sys.exit(6) + procMounts = Utils.readFile("/proc/mounts") + if procMounts.find(" %s " % mountPoint) != -1: + sys.stderr.write("mount point %s already has a mount\n" % mountPoint) + sys.exit(7) + if procMounts.find(" %s/" % mountPoint) != -1: + sys.stderr.write("mount point %s has a submount\n" % mountPoint) + sys.exit(8) + else: + status = Utils.runCommand("mkdir -p %s" % mountPoint, output=True, root=True) + if status["Status"] != 0: + sys.stderr.write("failed to create mount point %s\n" % mountPoint) + sys.exit(9) + + if fsType not in Utils.getFileSystemType(): + sys.stderr.write("unsupported file system type %s\n" % fsType) + sys.exit(10) + + deviceFormatLockFile = Utils.getDeviceFormatLockFile(device) + deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) + deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) + + if os.path.exists(deviceFormatStatusFile): + Utils.log("format status file %s exists" % deviceFormatStatusFile) + line = Utils.readFile(deviceFormatStatusFile) + if not line: + sys.stderr.write("failed to read format status file %s\n" % deviceFormatStatusFile) + sys.exit(-3) + if line.strip().upper() == "COMPLETED": + sys.stderr.write("Device %s already formatted\n" % sys.argv[3]) + sys.exit(11) + else: + sys.stderr.write("Formatting device %s already running\n" % sys.argv[3]) + sys.exit(12) + + if os.path.exists(deviceFormatLockFile): + Utils.log("lock file %s exists" % deviceFormatLockFile) + sys.stderr.write("Formatting device %s already running\n" % sys.argv[3]) + sys.exit(13) + + command = ["%s/format_device_background.py" % p1, fsType, mountPoint, sys.argv[3]] + Utils.runCommandBG(command) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py new file mode 100755 index 00000000..a804a59c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/format_device_background.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils +import FsTabUtils +import DiskUtils + +def writeStatus(deviceFormatStatusFile, message): + try: + fp = open(deviceFormatStatusFile, "w") + fp.write(message) + fp.close() + except IOError, e: + Utils.log("Failed to update log file %s: %s" % (deviceFormatStatusFile, str(e))) + return False + return True + +def main(): + if len(sys.argv) != 4: + sys.stderr.write("usage: %s FSTYPE MOUNT_POINT DEVICE_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + fsType = sys.argv[1] + mountPoint = sys.argv[2] + device = DiskUtils.getDevice(sys.argv[3]) + + deviceFormatLockFile = Utils.getDeviceFormatLockFile(device) + deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) + deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) + + if os.path.exists(deviceFormatStatusFile): + Utils.log("device format status file %s exists" % deviceFormatStatusFile) + sys.exit(1) + + if os.path.exists(deviceFormatLockFile): + Utils.log("device format lock file %s exists" % deviceFormatLockFile) + sys.exit(2) + + try: + fp = open(deviceFormatLockFile, "w") + fp.close() + except OSError, e: + Utils.log("failed to create lock file %s: %s" % (deviceFormatLockFile, str(e))) + writeStatus(deviceFormatStatusFile, "Lock file creation failed\n") + sys.exit(-2) + + try: + fptr = open(deviceFormatOutputFile, 'w') + except IOError, e: + Utils.log("failed to create output file %s" % deviceFormatOutputFile) + writeStatus(deviceFormatStatusFile, "Output file creation failed\n") + Utils.removeFile(deviceFormatLockFile) + sys.exit(-3) + + if fsType in ['ext3', 'ext4', 'ext4dev']: + command = "/sbin/mkfs.%s -F -I 512 %s" % (fsType, device) + elif fsType == "xfs": + command = "/sbin/mkfs.%s -f -i size=512 %s" % (fsType, device) + else: + command = "/sbin/mkfs.%s %s" % (fsType, device) + + status = Utils.runCommand(command, output=True, root=True) + if status["Status"] != 0: + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatLockFile) + writeStatus(deviceFormatStatusFile, "Device format failed\n") + sys.exit(3) + + if Utils.runCommand("udevadm trigger") != 0: + Utils.log("failed running udevadm trigger") + + if Utils.runCommand("/usr/bin/lshal") != 0: + Utils.log("failed running /usr/bin/lshal") + + deviceUuid = DiskUtils.getUuidByDiskPartition(device) + if not deviceUuid: + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatLockFile) + Utils.log("UUID not found after device %s formatted" % device) + writeStatus(deviceFormatStatusFile, "UUID not found after device %s formatted\n" % sys.argv[3]) + sys.exit(4) + + if DiskUtils.isDataDiskPartitionFormatted(device): + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatLockFile) + Utils.log("UUID device %s already has an entry in fstab" % device) + writeStatus(deviceFormatStatusFile, "UUID device %s already has an entry in fstab\n" % sys.argv[3]) + sys.exit(5) + + newFsTabEntry = {"Device" : "UUID=%s" % deviceUuid, + "MountPoint" : mountPoint, + "FsType" : fsType, + "Options" : "defaults", + "DumpOption" : "0", + "fsckOrder" : "2"} + if fsType in ['ext3', 'ext4', 'ext4dev']: + newFsTabEntry["Options"] = "defaults,user_xattr" + if not FsTabUtils.addFsTabEntry(newFsTabEntry): + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatLockFile) + writeStatus(deviceFormatStatusFile, "failed to update fstab") + sys.exit(6) + + status = Utils.runCommand("mount %s" % mountPoint, output=True, root=True) + if status["Status"] != 0: + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatLockFile) + Utils.log("Mounting device %s on %s failed" % (device, mountPoint)) + writeStatus(deviceFormatStatusFile, "Mounting device %s on %s failed\n" % (sys.argv[3], mountPoint)) + sys.exit(7) + + writeStatus(deviceFormatStatusFile, "Completed\n") + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatLockFile) + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py new file mode 100755 index 00000000..b72321d7 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_brick_status.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Console. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +def main(): + if len(sys.argv) != 3: + sys.stderr.write("usage: %s VOLUME_NAME BRICK_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + brickName = sys.argv[2] + pidFile = "/etc/glusterd/vols/%s/run/%s.pid" % (volumeName, brickName.replace(":", "").replace("/", "-")) + + if not os.path.exists(pidFile): + print "OFFLINE" + sys.exit(0) + + lines = Utils.readFile(pidFile) + if not lines: + print "UNKNOWN" + sys.exit(0) + try: + pidString = lines[0] + os.getpgid(int(pidString)) + print "ONLINE" + except ValueError, e: + Utils.log("invalid pid %s in file %s: %s" % (pidString, pidFile, str(e))) + print "UNKNOWN" + except OSError, e: + #Utils.log("failed to get process detail of pid %s: %s" % (pidString, str(e))) + print "OFFLINE" + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py new file mode 100755 index 00000000..de4b4bb0 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_filesystem_type.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +SUPPORTED_FSTYPE = ['ext3', 'ext4', 'ext4dev', 'xfs'] + +def main(): + print "\n".join(list(set(Utils.getFileSystemType()).intersection(set(SUPPORTED_FSTYPE)))) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py new file mode 100755 index 00000000..532f1585 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_format_device_status.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import time +import Utils +import DiskUtils +from XmlHandler import ResponseXml + +def main(): + if len(sys.argv) != 2: + sys.stderr.write("usage: %s DEVICE_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + device = DiskUtils.getDevice(sys.argv[1]) + + deviceFormatLockFile = Utils.getDeviceFormatLockFile(device) + deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) + deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) + + time.sleep(1) + if not os.path.exists(deviceFormatLockFile): + if not os.path.exists(deviceFormatStatusFile): + sys.stderr.write("Device format not initiated\n") + sys.exit(1) + + if os.path.exists(deviceFormatStatusFile): + line = Utils.readFile(deviceFormatStatusFile) + line = line.strip() + + Utils.removeFile(deviceFormatOutputFile) + Utils.removeFile(deviceFormatStatusFile) + + responseDom = ResponseXml() + responseDom.appendTagRoute("device", sys.argv[1]) + responseDom.appendTagRoute("completedBlocks", "0") + responseDom.appendTagRoute("totalBlocks", "0") + responseDom.appendTagRoute("message", line) + if line.upper() == "COMPLETED": + responseDom.appendTagRoute("formatStatus", "COMPLETED") + else: + responseDom.appendTagRoute("formatStatus", "NOT_RUNNING") + print responseDom.toxml() + sys.exit(0) + + content = Utils.readFile(deviceFormatOutputFile, lines=True) + if not content: + responseDom = ResponseXml() + responseDom.appendTagRoute("device", sys.argv[1]) + responseDom.appendTagRoute("completedBlocks", "0") + responseDom.appendTagRoute("totalBlocks", "0") + responseDom.appendTagRoute("message", None) + responseDom.appendTagRoute("formatStatus", "IN_PROGRESS") + print responseDom.toxml() + sys.exit(0) + + lines = [line for line in content + if "Writing inode tables" in line] + if not lines: + responseDom = ResponseXml() + responseDom.appendTagRoute("device", sys.argv[1]) + responseDom.appendTagRoute("completedBlocks", "0") + responseDom.appendTagRoute("totalBlocks", "0") + responseDom.appendTagRoute("message", content[-1]) + responseDom.appendTagRoute("formatStatus", "IN_PROGRESS") + print responseDom.toxml() + sys.exit(0) + + tokens = [token for token in lines[-1].split("\x08") if token] + if "done" in tokens[-1]: + values = tokens[-2].split(':')[-1].strip().split('/') + else: + values = tokens[-1].split(':')[-1].strip().split('/') + + responseDom.appendTagRoute("device", sys.argv[1]) + responseDom.appendTagRoute("completedBlocks", values[0]) + responseDom.appendTagRoute("totalBlocks", values[1]) + responseDom.appendTagRoute("message", lines[-1]) + responseDom.appendTagRoute("formatStatus", "IN_PROGRESS") + print responseDom.toxml() + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py new file mode 100755 index 00000000..da08fde1 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_cpu_details.py @@ -0,0 +1,47 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +CPU_RRD_FILE = "/var/lib/rrd/cpu.rrd" + +def main(): + if len(sys.argv) != 2: + sys.stderr.write("usage: %s DURATION\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + period = sys.argv[1] + + command = "rrdtool xport --start -%s \ + DEF:cpuuser=%s:user:AVERAGE \ + DEF:cpusystem=%s:system:AVERAGE \ + DEF:cpuidle=%s:idle:AVERAGE \ + CDEF:total=cpuuser,cpusystem,cpuidle,+,+ \ + CDEF:userpct=100,cpuuser,total,/,* \ + CDEF:systempct=100,cpusystem,total,/,* \ + CDEF:idlepct=100,cpuidle,total,/,* \ + CDEF:totalpct=userpct,systempct,+ \ + XPORT:userpct:userpct \ + XPORT:systempct:systempct \ + XPORT:totalpct:totalpct" % (period, CPU_RRD_FILE, CPU_RRD_FILE, CPU_RRD_FILE) + + rv = Utils.runCommand(command, output=True, root=True) + if rv["Status"] != 0: + sys.stderr.write("Failed to get RRD data of CPU\n") + sys.exit(rv["Status"]) + + print rv["Stdout"] + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py new file mode 100755 index 00000000..07a9d7d0 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_memory_details.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +MEMORY_RRD_FILE = "/var/lib/rrd/mem.rrd" + +def main(): + if len(sys.argv) != 2: + sys.stderr.write("usage: %s DURATION\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + period = sys.argv[1] + + command = "rrdtool xport --start -%s \ + DEF:free=%s:memfree:AVERAGE \ + DEF:used=%s:memused:AVERAGE \ + DEF:cache=%s:memcache:AVERAGE \ + DEF:buffer=%s:membuffer:AVERAGE \ + CDEF:total1=used,free,+ \ + CDEF:used1=used,buffer,cache,-,- \ + CDEF:total=total1,used1,+ \ + XPORT:used:memoryUsed \ + XPORT:free:memoryFree \ + XPORT:cache:memoryCache \ + XPORT:buffer:memoryBuffer \ + XPORT:total:totalMemory" % (period, MEMORY_RRD_FILE, MEMORY_RRD_FILE, MEMORY_RRD_FILE, MEMORY_RRD_FILE) + + rv = Utils.runCommand(command, output=True, root=True) + if rv["Status"] != 0: + sys.stderr.write("Failed to get RRD data of memory usage\n") + sys.exit(rv["Status"]) + + print rv["Stdout"] + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py new file mode 100755 index 00000000..ee28ca13 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_rrd_net_details.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +def main(): + if len(sys.argv) != 3: + sys.stderr.write("usage: %s DEVICE DURATION\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + device = sys.argv[1] + period = sys.argv[2] + + command = "rrdtool xport --start -%s \ + DEF:received=/var/lib/rrd/network-%s.rrd:received:AVERAGE \ + DEF:transmitted=/var/lib/rrd/network-%s.rrd:transmitted:AVERAGE \ + CDEF:total=received,transmitted,+ \ + XPORT:received:received \ + XPORT:transmitted:transmitted \ + XPORT:total:total" % (period, device, device) + + rv = Utils.runCommand(command, output=True, root=True) + if rv["Status"] != 0: + sys.stderr.write("Failed to get RRD information of device %s\n" % device) + sys.exit(rv["Status"]) + + print rv["Stdout"] + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py new file mode 100755 index 00000000..26b9059a --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_details.py @@ -0,0 +1,267 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import socket +import re +import Utils +import DiskUtils +import NetworkUtils +import XmlHandler +from optparse import OptionParser + + +def getDiskDom(): + diskInfo = DiskUtils.getDiskInfo() + if not diskInfo: + return None + procMdstat = DiskUtils.getProcMdstat() + diskDom = XmlHandler.XDOM() + disksTag = diskDom.createTag("disks", None) + diskTagDict = {} + raidDisksTag = diskDom.createTag("raidDisks", None) # raid members tag + for raidDiskName, raidDisk in procMdstat.iteritems(): + raidDiskTag = diskDom.createTag("disk", None) + raidDiskTag.appendChild(diskDom.createTag("name", raidDiskName)) + raidDiskTag.appendChild(diskDom.createTag("description", diskInfo[raidDiskName]['Description'])) + raidDiskTag.appendChild(diskDom.createTag("uuid", diskInfo[raidDiskName]['Uuid'])) + raidDiskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + raidDiskTag.appendChild(diskDom.createTag("mountPoint", diskInfo[raidDiskName]['MountPoint'])) + raidDiskTag.appendChild(diskDom.createTag("fsType", diskInfo[raidDiskName]['FsType'])) + if diskInfo[raidDiskName]['FsType']: + raidDiskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + else: + raidDiskTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + raidDiskTag.appendChild(diskDom.createTag("interface")) + raidDiskTag.appendChild(diskDom.createTag("fsVersion")) + raidDiskTag.appendChild(diskDom.createTag("size", diskInfo[raidDiskName]['Size'] / 1024.0)) + if not diskInfo[raidDiskName]['SpaceInUse']: + raidDiskTag.appendChild(diskDom.createTag("spaceInUse", None)) + else: + raidDiskTag.appendChild(diskDom.createTag("spaceInUse", diskInfo[raidDiskName]['SpaceInUse'] / 1024.0)) + raidDiskTag.appendChild(raidDisksTag) + disksTag.appendChild(raidDiskTag) + for raidMember in raidDisk['Member']: + # Case1: Raid array member is a disk. The following code will add the disk details under a disk tag + if diskInfo.has_key(raidMember): + diskTag = diskDom.createTag("disk", None) + diskTag.appendChild(diskDom.createTag("name", raidMember)) + diskTag.appendChild(diskDom.createTag("description", diskInfo[raidMember]["Description"])) + diskTag.appendChild(diskDom.createTag("uuid", diskInfo[raidMember]["Uuid"])) + if DiskUtils.isDiskInFormatting(raidMember): + diskTag.appendChild(diskDom.createTag("status", "INITIALIZING")) + else: + if diskInfo[raidMember]["FsType"]: + diskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + else: + diskTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + diskTag.appendChild(diskDom.createTag("interface", diskInfo[raidMember]["Interface"])) + diskTag.appendChild(diskDom.createTag("mountPoint", diskInfo[raidMember]["MountPoint"])) + if diskInfo[raidMember]["FsType"]: + diskTag.appendChild(diskDom.createTag("type", "DATA")) + else: + diskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + diskTag.appendChild(diskDom.createTag("fsType", diskInfo[raidMember]["FsType"])) + diskTag.appendChild(diskDom.createTag("fsVersion", diskInfo[raidMember]["FsVersion"])) + diskTag.appendChild(diskDom.createTag("size", diskInfo[raidMember]["Size"] / 1024.0)) + if not diskInfo[raidMember]["SpaceInUse"]: + diskTag.appendChild(diskDom.createTag("spaceInUse", None)) + else: + diskTag.appendChild(diskDom.createTag("spaceInUse", diskInfo[raidMember]["SpaceInUse"] / 1024.0)) + raidDisksTag.appendChild(diskTag) + del diskInfo[raidMember] + continue + # Case2: Raid array member is a partition. The following code will add the partition and its corresponding disk its belong to. + for disk, item in diskInfo.iteritems(): + if not item['Partitions'].has_key(raidMember): + continue + if not diskTagDict.has_key(disk): + diskTag = diskDom.createTag("disk", None) + diskTag.appendChild(diskDom.createTag("name", disk)) + diskTag.appendChild(diskDom.createTag("description", item["Description"])) + diskTag.appendChild(diskDom.createTag("uuid", item["Uuid"])) + diskTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + diskTag.appendChild(diskDom.createTag("interface", item["Interface"])) + diskTag.appendChild(diskDom.createTag("mountPoint")) + diskTag.appendChild(diskDom.createTag("type", "DATA")) + diskTag.appendChild(diskDom.createTag("fsType", item["FsType"])) + diskTag.appendChild(diskDom.createTag("fsVersion", item["FsVersion"])) + diskTag.appendChild(diskDom.createTag("size", item["Size"] / 1024.0)) + if not item["SpaceInUse"]: + diskTag.appendChild(diskDom.createTag("spaceInUse", None)) + else: + diskTag.appendChild(diskDom.createTag("spaceInUse", item["SpaceInUse"] / 1024.0)) + partitionsTag = diskDom.createTag("partitions", None) + diskTag.appendChild(partitionsTag) + raidDisksTag.appendChild(diskTag) + # Constructed disk tag will be added to the dictonary. + # This will be used to keep add all the corresponding partitions tags of the disk to the disk tag. + diskTagDict[disk] = {'diskTag': diskTag, 'partitionsTag': partitionsTag} + # adding partition details under this disk tag + partitionTag = diskDom.createTag("partition", None) + partitionTag.appendChild(diskDom.createTag("name", raidMember)) + partitionTag.appendChild(diskDom.createTag("uuid", item['Partitions'][raidMember]["Uuid"])) + partitionTag.appendChild(diskDom.createTag("fsType", item['Partitions'][raidMember]["FsType"])) + if item['Partitions'][raidMember]["FsType"]: + partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "DATA")) + else: + partitionTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + partitionTag.appendChild(diskDom.createTag("mountPoint", item['Partitions'][raidMember]['MountPoint'])) + partitionTag.appendChild(diskDom.createTag("size", item['Partitions'][raidMember]["Size"] / 1024.0)) + if not item['Partitions'][raidMember]["SpaceInUse"]: + partitionTag.appendChild(diskDom.createTag("spaceInUse", None)) + else: + partitionTag.appendChild(diskDom.createTag("spaceInUse", item['Partitions'][raidMember]["SpaceInUse"] / 1024.0)) + diskTagDict[disk]['partitionsTag'].appendChild(partitionTag) + # deleting partition entry of a raid member from diskInfo (item['Partitions']) + del item['Partitions'][raidMember] + del diskInfo[raidDiskName] + disksTag.appendChild(raidDisksTag) + for diskName, value in diskInfo.iteritems(): + diskTag = diskDom.createTag("disk", None) + diskTag.appendChild(diskDom.createTag("name", diskName)) + diskTag.appendChild(diskDom.createTag("description", value["Description"])) + diskTag.appendChild(diskDom.createTag("uuid", value["Uuid"])) + if DiskUtils.isDiskInFormatting(diskName): + status = "INITIALIZING" + else: + if value["FsType"]: + status = "INITIALIZED" + else: + status = "UNINITIALIZED" + diskTag.appendChild(diskDom.createTag("status", status)) + diskTag.appendChild(diskDom.createTag("interface", value["Interface"])) + if value["MountPoint"] and value["MountPoint"] in ["/", "/boot"]: + diskTag.appendChild(diskDom.createTag("type", "BOOT")) + elif "UNINITIALIZED" == status: + diskTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + else: + diskTag.appendChild(diskDom.createTag("type", "DATA")) + diskTag.appendChild(diskDom.createTag("fsType", value["FsType"])) + diskTag.appendChild(diskDom.createTag("fsVersion", value["FsVersion"])) + diskTag.appendChild(diskDom.createTag("mountPoint", value["MountPoint"])) + diskTag.appendChild(diskDom.createTag("size", value["Size"] / 1024.0)) + if not value["SpaceInUse"]: + diskTag.appendChild(diskDom.createTag("spaceInUse", None)) + else: + diskTag.appendChild(diskDom.createTag("spaceInUse", value["SpaceInUse"] / 1024.0)) + partitionsTag = diskDom.createTag("partitions", None) + diskTag.appendChild(partitionsTag) + for partName, partValues in value['Partitions'].iteritems(): + partitionTag = diskDom.createTag("partition", None) + partitionTag.appendChild(diskDom.createTag("name", partName)) + partitionTag.appendChild(diskDom.createTag("uuid", partValues["Uuid"])) + partitionTag.appendChild(diskDom.createTag("fsType", partValues["FsType"])) + if partValues["MountPoint"] and partValues["MountPoint"] in ["/", "/boot"]: + partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "BOOT")) + elif partValues["FsType"]: + partitionTag.appendChild(diskDom.createTag("status", "INITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "DATA")) + else: + partitionTag.appendChild(diskDom.createTag("status", "UNINITIALIZED")) + partitionTag.appendChild(diskDom.createTag("type", "UNKNOWN")) + partitionTag.appendChild(diskDom.createTag("mountPoint", partValues['MountPoint'])) + partitionTag.appendChild(diskDom.createTag("size", partValues["Size"] / 1024.0)) + if not partValues["SpaceInUse"]: + partitionTag.appendChild(diskDom.createTag("spaceInUse", None)) + else: + partitionTag.appendChild(diskDom.createTag("spaceInUse", partValues["SpaceInUse"] / 1024.0)) + partitionsTag.appendChild(partitionTag) + continue + disksTag.appendChild(diskTag) + diskDom.addTag(disksTag) + return diskDom + + +def getServerDetails(listall): + serverName = socket.getfqdn() + meminfo = Utils.getMeminfo() + cpu = Utils.getCpuUsageAvg() + nameServerList, domain, searchDomain = NetworkUtils.readResolvConfFile() + if not domain: + domain = [None] + + responseDom = XmlHandler.ResponseXml() + serverTag = responseDom.appendTagRoute("server") + serverTag.appendChild(responseDom.createTag("name", serverName)) + serverTag.appendChild(responseDom.createTag("domainname", domain[0])) + if Utils.runCommand("pidof glusterd") == 0: + serverTag.appendChild(responseDom.createTag("status", "ONLINE")) + else: + serverTag.appendChild(responseDom.createTag("status", "OFFLINE")) + serverTag.appendChild(responseDom.createTag("glusterFsVersion", Utils.getGlusterVersion())) + serverTag.appendChild(responseDom.createTag("cpuUsage", str(cpu))) + serverTag.appendChild(responseDom.createTag("totalMemory", str(Utils.convertKbToMb(meminfo['MemTotal'])))) + serverTag.appendChild(responseDom.createTag("memoryInUse", str(Utils.convertKbToMb(meminfo['MemUsed'])))) + serverTag.appendChild(responseDom.createTag("uuid", None)) + + for dns in nameServerList: + serverTag.appendChild(responseDom.createTag("dns%s" % str(nameServerList.index(dns) +1) , dns)) + + #TODO: probe and retrieve timezone, ntp-server details and update the tags + + interfaces = responseDom.createTag("networkInterfaces", None) + for deviceName, values in NetworkUtils.getNetDeviceList().iteritems(): + if values["type"].upper() in ['LOCAL', 'IPV6-IN-IPV4']: + continue + interfaceTag = responseDom.createTag("networkInterface", None) + interfaceTag.appendChild(responseDom.createTag("name", deviceName)) + interfaceTag.appendChild(responseDom.createTag("hwAddr", values["hwaddr"])) + interfaceTag.appendChild(responseDom.createTag("speed", values["speed"])) + interfaceTag.appendChild(responseDom.createTag("model", values["type"])) + if values["onboot"]: + interfaceTag.appendChild(responseDom.createTag("onBoot", "yes")) + else: + interfaceTag.appendChild(responseDom.createTag("onBoot", "no")) + interfaceTag.appendChild(responseDom.createTag("bootProto", values["bootproto"])) + interfaceTag.appendChild(responseDom.createTag("ipAddress", values["ipaddr"])) + interfaceTag.appendChild(responseDom.createTag("netMask", values["netmask"])) + interfaceTag.appendChild(responseDom.createTag("defaultGateway", values["gateway"])) + if values["mode"]: + interfaceTag.appendChild(responseDom.createTag("mode", values["mode"])) + if values["master"]: + interfaceTag.appendChild(responseDom.createTag("bonding", "yes")) + spliter = re.compile(r'[\D]') + interfaceTag.appendChild(responseDom.createTag("bondid", spliter.split(values["master"])[-1])) + interfaces.appendChild(interfaceTag) + serverTag.appendChild(interfaces) + + responseDom.appendTag(serverTag) + serverTag.appendChild(responseDom.createTag("numOfCPUs", int(os.sysconf('SC_NPROCESSORS_ONLN')))) + + diskDom = getDiskDom() + if not diskDom: + sys.stderr.write("No disk found!") + Utils.log("Failed to get disk details") + sys.exit(2) + + serverTag.appendChild(diskDom.getElementsByTagRoute("disks")[0]) + return serverTag + +def main(): + parser = OptionParser() + parser.add_option("-N", "--only-data-disks", + action="store_false", dest="listall", default=True, + help="List only data disks") + + (options, args) = parser.parse_args() + responseXml = getServerDetails(options.listall) + if responseXml: + print responseXml.toxml() + + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py new file mode 100755 index 00000000..2814f10f --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_server_status.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Console. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + +def main(): + if len(sys.argv) != 1: + sys.stderr.write("usage: %s\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + if Utils.runCommand("pidof glusterd") == 0: + print "ONLINE" + else: + print "OFFLINE" + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py new file mode 100755 index 00000000..026c3c00 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/get_volume_brick_log.py @@ -0,0 +1,97 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +import re +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +from XmlHandler import XDOM +import Utils + +def enumLogType(logCode): + if "M" == logCode.upper(): + return "EMERGENCY" + elif "A" == logCode.upper(): + return "ALERT" + elif "C" == logCode.upper(): + return "CRITICAL" + elif "E" == logCode.upper(): + return "ERROR" + elif "W" == logCode.upper(): + return "WARNING" + elif "N" == logCode.upper(): + return "NOTICE" + elif "I" == logCode.upper(): + return "INFO" + elif "D" == logCode.upper(): + return "DEBUG" + elif "T" == logCode.upper(): + return "TRACE" + else: + return "UNKNOWN" +##--end of enumLogType() + +def addLog(responseDom, logMessagesTag, loginfo): + logMessageTag = responseDom.createTag("logMessage") + logMessageTag.appendChild(responseDom.createTag("timestamp", loginfo[0] + " " + loginfo[1])) + logMessageTag.appendChild(responseDom.createTag("severity", enumLogType(loginfo[2]))) + logMessageTag.appendChild(responseDom.createTag("message", loginfo[3])) + logMessagesTag.appendChild(logMessageTag); + return True +##--end of addLog() + +def logSplit(log): + loginfo = log.strip().split(None, 3) + loginfo[0] = loginfo[0][1:] #-- Remove '[' + loginfo[1] = loginfo[1][0:-1] #-- Remove ']' + return loginfo +##--end of logSplit() + +def getVolumeLog(logFilePath, tailCount): + rs = XDOM() + if not logFilePath: + sys.stderr.write("No log file path given\n") + sys.exit(-1) + + if not tailCount: + sys.stderr.write("No tail count given\n") + sys.exit(-1) + + pattern = '\[\d{4}-\d{2}-\d{2}\s{1}\d{2}:\d{2}:\d{2}.\d+\]\s{1}([MACEWNIDT]){1}\s+' + + content = Utils.readFile(logFilePath, lines=True) + if not content: + sys.stderr.write("volume log not found in file %s\n" % logFilePath) + sys.exit(-1) + + lines = [line for line in content if re.match(pattern, line)] + i = len(lines) - int(tailCount) + if i < 0: + i = 0 + logMessagesTag = rs.createTag("logMessages") + rs.addTag(logMessagesTag) + for log in lines[i:]: + loginfo = logSplit(log) + addLog(rs, logMessagesTag, loginfo) + return rs.toxml() +##--end of getVolumeLog() + +def main(): + if len(sys.argv) != 3: + sys.stderr.write("usage: %s LOG-FILE LINE-COUNT\n" % sys.argv[0]) + sys.exit(-1) + + logFilePath = sys.argv[1] + tailCount = sys.argv[2] + print getVolumeLog(logFilePath, tailCount) + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block b/src/org.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block new file mode 100755 index 00000000..0385b82c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/gluster-provision-block @@ -0,0 +1,171 @@ +#!/bin/bash + +ME=$(basename $0); + +set -o pipefail; + +function show_help() +{ + usage_banner; + cat <> /etc/fstab || fail "Failed to update fstab"; + ;; + *) + echo "UUID=$uuid $mnt $fstype defaults 0 2" >> /etc/fstab || fail "Failed to update fstab"; + ;; + esac + + mount -v $mnt || fail "mounting $devblk on $mnt failed"; + +cat <&2 + exit 1 + fi + /usr/sbin/gluster_cifs_volume_startup + ;; +esac diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py new file mode 100644 index 00000000..9ea7e021 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/gluster_cifs_volume_startup.py @@ -0,0 +1,114 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +import glob +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import VolumeUtils + +def getGlusterVolumeInfo(volumeName=None): + volumeNameList = None + if Utils.isString(volumeName): + volumeNameList = [volumeName] + if type(volumeName) == type([]): + volumeNameList = volumeName + + status = Utils.runCommand("gluster volume info", output=True, root=True) + if status["Status"] != 0: + Utils.log("Failed to execute 'gluster volume info' command") + return None + + volumeInfoDict = {} + volumeInfo = {} + volumeName = None + brickList = [] + for line in status['Stdout'].split("\n"): + if not line: + if volumeName and volumeInfo: + volumeInfo["Bricks"] = brickList + volumeInfoDict[volumeName] = volumeInfo + volumeInfo = {} + volumeName = None + brickList = [] + continue + + tokens = line.split(":") + if tokens[0].strip().upper() == "BRICKS": + continue + elif tokens[0].strip().upper() == "VOLUME NAME": + volumeName = tokens[1].strip() + volumeInfo["VolumeName"] = volumeName + elif tokens[0].strip().upper() == "TYPE": + volumeInfo["VolumeType"] = tokens[1].strip() + elif tokens[0].strip().upper() == "STATUS": + volumeInfo["VolumeStatus"] = tokens[1].strip() + elif tokens[0].strip().upper() == "TRANSPORT-TYPE": + volumeInfo["TransportType"] = tokens[1].strip() + elif tokens[0].strip().upper().startswith("BRICK"): + brickList.append(":".join(tokens[1:]).strip()) + + if volumeName and volumeInfo: + volumeInfoDict[volumeName] = volumeInfo + + if not volumeNameList: + return volumeInfoDict + + # remove unwanted volume info + for volumeName in list(set(volumeInfoDict.keys()) - set(volumeNameList)): + del volumeInfoDict[volumeName] + + return volumeInfoDict + + +def main(): + volumeInfo = getGlusterVolumeInfo() + if not volumeInfo: + print "No volume present. Removing CIFS volume configuration if any" + Utils.runCommand("rm -fr %s/*" % Globals.VOLUME_CONF_DIR, root=True, shell=True) + Utils.runCommand("rm -fr %s/*" % Globals.REEXPORT_DIR, root=True, shell=True) + Utils.runCommand("rm -fr %s/*" % Globals.CIFS_EXPORT_DIR, root=True, shell=True) + sys.exit(0) + + lines = Utils.readFile(Globals.VOLUME_SMBCONF_FILE) + volumeSmbConfList = [line.strip() for line in lines] + for volumeName in volumeInfo.keys(): + if not "include = %s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName) in volumeSmbConfList: + continue + if 'STOPPED' == volumeInfo[volumeName]['VolumeStatus'].upper(): + Utils.runCommand("rmdir %s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName), root=True) + if not VolumeUtils.excludeVolume(volumeName): + Utils.log("Failed to exclude %s volume for CIFS reexport" % volumeName) + continue + if 'STARTED' == volumeInfo[volumeName]['VolumeStatus'].upper(): + volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) + if Utils.runCommand("mount -t glusterfs 127.0.0.1:%s %s" % (volumeName, volumeMountDirName)) != 0: + Utils.log("Failed to mount volume %s" % (volumeName)) + + smbConfFileList = glob.glob("%s/*.smbconf" % Globals.VOLUME_CONF_DIR) + volumeList = [smbConfFileName.split(".smbconf")[0].split("/")[-1] for smbConfFileName in smbConfFileList] + danglingVolumeList = list(set(volumeList).difference(set(volumeInfo.keys()))) + if not danglingVolumeList: + sys.exit(0) + + print "Cleaning up dangling volume(s):", danglingVolumeList + for volumeName in danglingVolumeList: + Utils.runCommand("rmdir %s/%s" % (Globals.REEXPORT_DIR, volumeName), root=True) + Utils.runCommand("rm -f %s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName), root=True) + if not VolumeUtils.excludeVolume(volumeName): + Utils.log("Failed to exclude volume %s for CIFS reexport" % volumeName) + Utils.runCommand("rm -f %s/%s.smbconf" % (Globals.VOLUME_CONF_DIR, volumeName), root=True) + + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py new file mode 100755 index 00000000..d56b1f59 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/modify_volume_cifs.py @@ -0,0 +1,36 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils +import VolumeUtils + +def main(): + if len(sys.argv) <= 2: + sys.stderr.write("usage: %s VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + userList = sys.argv[2:] + + if not VolumeUtils.writeVolumeCifsConfiguration(volumeName, userList): + sys.stderr.write("Unable to write cifs configuration\n") + sys.exit(1) + if Utils.runCommand("service smb reload") != 0: + Utils.log("Failed to reload smb service") + sys.stderr.write("Failed to reload smb service\n") + sys.exit(2) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d b/src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d new file mode 100755 index 00000000..7cfbe44a --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.init.d @@ -0,0 +1,48 @@ +#!/bin/bash +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# +# chkconfig: - 85 15 +# description: multicast discovery service +# processname: multicast-discoverd +# pidfile: /var/run/multicast-discoverd.pid + +# Source function library. + +. /etc/init.d/functions + +case "$1" in + start) + echo -n "Starting multicast-discoverd:" + daemon multicast-discoverd + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/multicast-discoverd + ;; + stop) + echo -n "Shutting down multicast-discoverd:" + killproc multicast-discoverd + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/multicast-discoverd + ;; + restart) + $0 stop + $0 start + RETVAL=$? + ;; + status) + status multicast-discoverd + RETVAL=$? + ;; + reload) + killproc multicast-discoverd -HUP + RETVAL=$? + echo + ;; + *) + echo $"Usage: $0 {start|stop|restart|status|reload}" + exit 1 +esac + +exit $RETVAL diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py new file mode 100755 index 00000000..cb5de70c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/multicast-discoverd.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import socket +import struct +import signal +import time +import Utils +import Globals + +PID_FILE = "/var/run/multicast-discoverd.pid" +GLUSTERD_UUID = "NA" + +def exitHandler(signum, frame): + try: + if os.path.exists(PID_FILE): + os.unlink(PID_FILE) + except OSError, e: + Utils.log("Failed to remove PID file %s: %s" % (PID_FILE, str(e))) + sys.exit(0) + + +def updateGlusterdUuid(signum, frame): + lines = Utils.readFile("/etc/glusterd/glusterd.info", lines=True) + for line in lines: + if line.strip().startswith("UUID="): + GLUSTERD_UUID = line.strip().split("=")[1] + return + GLUSTERD_UUID = "NA" + + +def isInPeer(): + status = Utils.runCommand("gluster peer status", output=True) + if status["Status"] == 0: + if status["Stdout"].strip().upper() != "NO PEERS PRESENT": + return True + return False + + +def main(): + if os.path.exists(PID_FILE): + sys.stderr.write("fatal: PID file %s exists\n" % PID_FILE) + sys.exit(-1) + if not Utils.daemonize(): + sys.stderr.write("fatal: unable to run as daemon\n") + sys.exit(-1) + try: + fp = open(PID_FILE, "w") + fp.write("%s\n" % os.getpid()) + fp.close() + except IOError, e: + Utils.log("failed to create PID file %s: %s" % (PID_FILE, str(e))) + sys.exit(1) + + updateGlusterdUuid(None, None) + + signal.signal(signal.SIGINT, exitHandler) + signal.signal(signal.SIGTERM, exitHandler) + signal.signal(signal.SIGHUP, exitHandler) + + multicastSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) + multicastSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + multicastSocket.bind(('', Globals.MULTICAST_PORT)) + multicastSocket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, + struct.pack("4sl", socket.inet_aton(Globals.MULTICAST_GROUP), + socket.INADDR_ANY)) + + while True: + request = multicastSocket.recvfrom(Globals.DEFAULT_BUFSIZE) + if not request: + continue + #print "received [%s] from %s" % (request[0], request[1]) + tokens = request[0].strip().split(",") + if len(tokens) != 3: + continue + if tokens[0] != Globals.GLUSTER_PROBE_STRING: + continue + if isInPeer(): + continue + + time.sleep(0.2) + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((request[1][0], Globals.SERVER_PORT)) + sock.send("%s,%s,%s,%s,%s,%s\n" % (tokens[0], tokens[1], tokens[2], socket.gethostname(), socket.getfqdn(), GLUSTERD_UUID)) + sock.close() + except socket.error, e: + Utils.log("failed to send reply to [%s:%s]: %s" % (request[1][0], Globals.SERVER_PORT, str(e))) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl b/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl new file mode 100755 index 00000000..30a66342 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_cpu.pl @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +use RRDs; + +my $rrdlog = '/var/lib/rrd'; +my $graphs = '/var/lib/rrd'; + +updatecpudata(); +#updatecpugraph('day'); +#updatecpugraph('week'); +#updatecpugraph('month'); +#updatecpugraph('year'); + +sub updatecpugraph { + my $period = $_[0]; + + RRDs::graph ("$graphs/cpu-$period.png", + "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 300", "-h 50", "-l 0", "-u 100", "-r", + "--color", "SHADEA#FFFFFF", + "--color", "SHADEB#FFFFFF", + "--color", "BACK#FFFFFF", + "-t cpu usage per $period", + "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE", + "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE", + "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE", + + "CDEF:total=user,system,idle,+,+", + "CDEF:userpct=100,user,total,/,*", + "CDEF:systempct=100,system,total,/,*", + "CDEF:idlepct=100,idle,total,/,*", + + "AREA:userpct#0000FF:User cpu usage\\j", + "STACK:systempct#FF0000:system cpu usage\\j", + "STACK:idlepct#00FF00:idle cpu usage\\j"); + + # "GPRINT:userpct:MAX:maximal user cpu\\:%3.2lf%%", + # "GPRINT:userpct:AVERAGE:average user cpu\\:%3.2lf%%", + # "GPRINT:userpct:LAST:current user cpu\\:%3.2lf%%\\j", + # "GPRINT:systempct:MAX:maximal system cpu\\:%3.2lf%%", + # "GPRINT:systempct:AVERAGE:average system cpu\\:%3.2lf%%", + # "GPRINT:systempct:LAST:current system cpu\\:%3.2lf%%\\j", + # "GPRINT:idlepct:MAX:maximal idle cpu\\:%3.2lf%%", + # "GPRINT:idlepct:AVERAGE:average idle cpu\\:%3.2lf%%", + # "GPRINT:idlepct:LAST:current idle cpu\\:%3.2lf%%\\j"); + $ERROR = RRDs::error; + print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; +} + +sub updatecpudata { + if ( ! -e "$rrdlog/cpu.rrd") { + RRDs::create ("$rrdlog/cpu.rrd", "--step=300", + "DS:user:COUNTER:600:0:U", + "DS:system:COUNTER:600:0:U", + "DS:idle:COUNTER:600:0:U", + + "RRA:AVERAGE:0.5:1:576", + "RRA:AVERAGE:0.5:6:672", + "RRA:AVERAGE:0.5:24:732", + "RRA:AVERAGE:0.5:144:1460"); + $ERROR = RRDs::error; + print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; + } + + my ($cpu, $user, $nice, $system,$idle); + + open STAT, "/proc/stat"; + while() { + chomp; + /^cpu\s/ or next; + ($cpu, $user, $nice, $system, $idle) = split /\s+/; + last; + } + close STAT; + $user += $nice; + + RRDs::update ("$rrdlog/cpu.rrd", + "-t", "user:system:idle", + "N:$user:$system:$idle"); + $ERROR = RRDs::error; + print "Error in RRD::update for cpu: $ERROR\n" if $ERROR; + + #print "N:$user:$system:$idle\n"; +} diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl b/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl new file mode 100755 index 00000000..5c47cd81 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_mem.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl + +use RRDs; + +my $rrdlog = '/var/lib/rrd'; +my $graphs = '/var/lib/rrd'; + +updatememdata (); +#updatememgraph ('day'); +#updatememgraph ('week'); +#updatememgraph ('month'); +#updatememgraph ('year'); + +sub updatememgraph { + my $period = $_[0]; + + RRDs::graph ("$graphs/memory-$period.png", + "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 300", "-h 50", "-l 0", "-u 100", "-r", + "--color", "SHADEA#FFFFFF", + "--color", "SHADEB#FFFFFF", + "--color", "BACK#FFFFFF", + "-t memory usage per $period", + "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE", + "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE", + "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE", + "CDEF:total=used,free,+", + "CDEF:used1=used,buffer,cache,-,-", + "CDEF:usedpct=100,used1,total,/,*", + "CDEF:free1=total,used1,-", + "CDEF:cachepct=100,cache,total,/,*", + "CDEF:freepct=100,free1,total,/,*", + "AREA:usedpct#0000FF:used memory\\j", + "STACK:cachepct#FFFF00:cached memory\\j", + "STACK:freepct#00FF00:free memory\\j"); + $ERROR = RRDs::error; + print "Error in RRD::graph for mem: $ERROR\n" if $ERROR; + + RRDs::graph ("$graphs/swap-$period.png", + "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 300", "-h 50", "-l 0", "-u 100", "-r", + "--color", "SHADEA#FFFFFF", + "--color", "SHADEB#FFFFFF", + "--color", "BACK#FFFFFF", + "-t swap usage per $period", + "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE", + "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE", + "CDEF:total=used,free,+", + "CDEF:usedpct=100,used,total,/,*", + "CDEF:freepct=100,free,total,/,*", + "AREA:usedpct#0000FF:used swap\\j", + "STACK:freepct#00FF00:free swap\\j"); + $ERROR = RRDs::error; + print "Error in RRD::graph for swap: $ERROR\n" if $ERROR; +} + +sub updatememdata { + my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree); + if ( ! -e "$rrdlog/mem.rrd") { + RRDs::create ("$rrdlog/mem.rrd", "--step=300", + "DS:memused:ABSOLUTE:600:0:U", + "DS:memfree:ABSOLUTE:600:0:U", + "DS:memcache:ABSOLUTE:600:0:U", + "DS:membuffer:ABSOLUTE:600:0:U", + "DS:swapused:ABSOLUTE:600:0:U", + "DS:swapfree:ABSOLUTE:600:0:U", + "RRA:AVERAGE:0.5:1:576", + "RRA:AVERAGE:0.5:6:672", + "RRA:AVERAGE:0.5:24:732", + "RRA:AVERAGE:0.5:144:1460"); + $ERROR = RRDs::error; + print "Error in RRD::create for mem: $ERROR\n" if $ERROR; + } + + my @memdata = `free -b -o`; + + my $temp = $memdata[1]; + + chomp( $temp ); + my @tempa = split (/\s+/, $temp); + $memused = $tempa [2]; + $memfree = $tempa [3]; + $memshared = $tempa [4]; + $membuffers = $tempa [5]; + $memcache = $tempa [6]; + + $temp = $memdata[2]; + chomp( $temp ); + @tempa = split (/\s+/, $temp); + $swapused = $tempa [2]; + $swapfree = $tempa [3]; + + + RRDs::update ("$rrdlog/mem.rrd", + "-t", "memused:memfree:memcache:membuffer:swapused:swapfree", + "N:$memused:$memfree:$memcache:$membuffers:$swapused:$swapfree"); + + $ERROR = RRDs::error; + print "Error in RRD::update for mem: $ERROR\n" if $ERROR; +} diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl b/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl new file mode 100755 index 00000000..6ae128fd --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/rrd_net.pl @@ -0,0 +1,75 @@ +#!/usr/bin/perl + +use RRDs; + +my $rrdlog = '/var/lib/rrd'; +my $graphs = '/var/lib/rrd'; + +updatenetdata(); +#updatenetgraph('hour'); +#updatenetgraph('day'); +#updatenetgraph('week'); +#updatenetgraph('month'); +#updatenetgraph('year'); + +sub updatenetgraph { + my $period = $_[0]; + + foreach $rrdfile (<$rrdlog/network-*.rrd>) { + RRDs::graph ("$graphs/network-$device-$period.png", + "--start", "-1$period", "-aPNG", "-i", "-z", + "--alt-y-grid", "-w 800", "-h 400", "-l 0", "-u 10000000", "-r", + "--color", "SHADEA#FFFFFF", + "--color", "SHADEB#FFFFFF", + "--color", "BACK#FFFFFF", + "-t $device load per $period", + "DEF:received=$rrdfile:received:AVERAGE", + "DEF:transmitted=$rrdfile:transmitted:AVERAGE", + + "LINE2:received#FF0000:received load\\j", + "LINE1:transmitted#0000FF:transmitted load\\j"); + + $ERROR = RRDs::error; + print "Error in RRD::graph for network $device: $ERROR\n" if $ERROR; + } +} + +sub updatenetdata { + open NETDEV, "/proc/net/dev"; + while () { + chomp; + s/^\s+//; # remove left side whitespaces + /:.+/ or next; # if input line contains ':' else continue + next if /^lo:/; # continue if input line starts with 'lo:' + + @tokens1 = split /:/; # split with ':' + $tokens1[1]=~s/^\s+//; # remove left side whitespaces + @tokens2 = split(/\s+/, $tokens1[1]); # split with space + + $device = $tokens1[0]; + $received = $tokens2[0]; + $transmitted = $tokens2[8]; + + #print "$device, $received, $transmitted \n"; + + if ( ! -e "$rrdlog/network-$device.rrd") { + RRDs::create ("$rrdlog/network-$device.rrd", "--step=300", + "DS:received:COUNTER:600:0:U", + "DS:transmitted:COUNTER:600:0:U", + + "RRA:AVERAGE:0.5:1:576", + "RRA:AVERAGE:0.5:6:672", + "RRA:AVERAGE:0.5:24:732", + "RRA:AVERAGE:0.5:144:1460"); + $ERROR = RRDs::error; + print "Error in RRD::create for device $device: $ERROR\n" if $ERROR; + } + + RRDs::update ("$rrdlog/network-$device.rrd", + "-t", "received:transmitted", + "N:$received:$transmitted"); + $ERROR = RRDs::error; + print "Error in RRD::update for net: $ERROR\n" if $ERROR; + } + close NETDEV +} diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py new file mode 100755 index 00000000..5d5187f4 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/setup_cifs_config.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import time +import Globals +import Utils + +def main(): + try: + if not os.path.exists(Globals.GLUSTER_BASE_DIR): + os.mkdir(Globals.GLUSTER_BASE_DIR) + if not os.path.exists(Globals.VOLUME_CONF_DIR): + os.mkdir(Globals.VOLUME_CONF_DIR) + if not os.path.exists(Globals.CIFS_EXPORT_DIR): + os.mkdir(Globals.CIFS_EXPORT_DIR) + if not os.path.exists(Globals.REEXPORT_DIR): + os.mkdir(Globals.REEXPORT_DIR) + except OSError, e: + Utils.log("failed to create directory: %s" % str(e)) + sys.stderr.write("Failed to create directory: %s\n" % str(e)) + sys.exit(1) + try: + if not os.path.exists(Globals.VOLUME_SMBCONF_FILE): + fp = open(Globals.VOLUME_SMBCONF_FILE, "w") + fp.close() + except IOError, e: + Utils.log("Failed to create file %s: %s" % (Globals.VOLUME_SMBCONF_FILE, str(e))) + sys.stderr.write("Failed to create file %s: %s\n" % (Globals.VOLUME_SMBCONF_FILE, str(e))) + sys.exit(2) + try: + backupFile = "%s.%s" % (Globals.SAMBA_CONF_FILE, time.time()) + os.rename(Globals.SAMBA_CONF_FILE, backupFile) + except IOError, e: + Utils.log("Ignoring rename %s to %s: %s" % (Globals.SAMBA_CONF_FILE, backupFile)) + sys.stderr.write("Ignoring rename %s to %s: %s\n" % (Globals.SAMBA_CONF_FILE, backupFile)) + try: + fp = open(Globals.SAMBA_CONF_FILE, "w") + fp.write("##\n") + fp.write("## THIS FILE SHOULD NOT BE MODIFIED. IF YOU WANT TO MODIFY SAMBA\n") + fp.write("## CONFIGURATIONS, USE /etc/samba/real.smb.conf FILE\n") + fp.write("##\n") + fp.write("include = %s\n\n" % Globals.REAL_SAMBA_CONF_FILE) + fp.write("## CAUTION: DO NOT REMOVE BELOW LINE. REMOVAL OF THE LINE DISABLES\n") + fp.write("## CIFS REEXPORT OF GLUSTER VOLUMES\n") + fp.write("include = %s\n" % Globals.VOLUME_SMBCONF_FILE) + fp.close() + except IOError, e: + Utils.log("Failed to create samba configuration file %s: %s" % (Globals.SAMBA_CONF_FILE, str(e))) + sys.stderr.write("Failed to create samba configuration file %s: %s\n" % (Globals.SAMBA_CONF_FILE, str(e))) + sys.exit(3) + try: + if not os.path.exists(Globals.REAL_SAMBA_CONF_FILE): + fp = open(Globals.REAL_SAMBA_CONF_FILE, "w") + fp.write("[global]\n") + fp.write("## CAUTION: DO NOT REMOVE BELOW INCLUDE LINE. REMOVAL OF THE LINE\n") + fp.write("## DISABLES SERVER/CIFS HIGH AVAILABILITY\n") + #fp.write("include = %s\n" % Globals.CTDB_SAMBA_CONF_FILE) + fp.write("##\n") + fp.write("socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=131072 SO_RCVBUF=131072\n") + fp.write("read raw = yes\n") + fp.write("server string = %h\n") + fp.write("write raw = yes\n") + fp.write("oplocks = yes\n") + fp.write("max xmit = 131072\n") + fp.write("dead time = 15\n") + fp.write("getwd cache = yes\n") + fp.write("#read size = 131072\n") + fp.write("use sendfile=yes\n") + fp.write("block size = 131072\n") + fp.write("printcap name = /etc/printcap\n") + fp.write("load printers = no\n") + fp.close() + except IOError, e: + Utils.log("Failed to create samba configuration file %s: %s" % (Globals.REAL_SAMBA_CONF_FILE, str(e))) + sys.stderr.write("Failed to create samba configuration file %s: %s\n" % (Globals.REAL_SAMBA_CONF_FILE, str(e))) + sys.exit(4) + + if Utils.runCommand("/usr/sbin/selinuxenabled") == 0: + if Utils.runCommand("setsebool -P samba_share_fusefs on") != 0: + Utils.log("failed to set SELinux samba_share_fusefs") + sys.stderr.write("failed to set SELinux samba_share_fusefs\n") + sys.exit(5) + + if Utils.runCommand("service smb status") != 0: + if Utils.runCommand("service smb start") != 0: + Utils.log("failed to start smb service") + sys.stderr.write("Failed to start smb service\n") + sys.exit(6) + + if Utils.runCommand("service smb reload") != 0: + Utils.log("failed to reload smb configuration") + sys.stderr.write("Failed to reload smb configuration\n") + sys.exit(7) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py new file mode 100755 index 00000000..e16c87c2 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/start_volume_cifs.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import VolumeUtils + +def main(): + if len(sys.argv) != 2: + sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + + volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) + cifsDirName = "%s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName) + + if Utils.runCommand("mount -t glusterfs 127.0.0.1:%s %s" % (volumeName, volumeMountDirName)) != 0: + Utils.log("Failed to mount volume %s" % (volumeName)) + sys.stderr.write("Failed to mount volume %s\n" % (volumeName)) + sys.exit(1) + if Utils.runCommand("ln -fTs %s %s" % (volumeMountDirName, cifsDirName)) != 0: + Utils.log("Failed to create reexport link %s" % cifsDirName) + sys.stderr.write("Failed to create reexport link %s\n" % cifsDirName) + sys.exit(2) + if Utils.runCommand("/usr/sbin/selinuxenabled") == 0: + if Utils.runCommand("chcon -t samba_share_t %s -h" % cifsDirName) != 0: + Utils.log("Failed to change security context for the link %s" % cifsDirName) + sys.stderr.write("Failed to change security context for the link %s\n" % cifsDirName) + sys.exit(2) + if not VolumeUtils.includeVolume(volumeName): + Utils.log("Failed to include volume for CIFS reexport") + sys.stderr.write("Failed to include volume for CIFS reexport\n") + sys.exit(3) + if Utils.runCommand("service smb reload") != 0: + Utils.log("Failed to reload smb service") + sys.stderr.write("Failed to reload smb service\n") + sys.exit(4) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py new file mode 100755 index 00000000..d67d9061 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/stop_volume_cifs.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import VolumeUtils + +def main(): + if len(sys.argv) != 2: + sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + + volumeMountDirName = "%s/%s" % (Globals.REEXPORT_DIR, volumeName) + cifsDirName = "%s/%s" % (Globals.CIFS_EXPORT_DIR, volumeName) + + if not Utils.removeFile(cifsDirName): + Utils.log("Failed to remove reexport link %s" % cifsDirName) + sys.stderr.write("Failed to remove reexport link %s\n" % cifsDirName) + sys.exit(1) + if not VolumeUtils.excludeVolume(volumeName): + Utils.log("Failed to exclude volume for CIFS reexport") + sys.stderr.write("Failed to exclude volume for CIFS reexport\n") + sys.exit(2) + if Utils.runCommand("service smb reload") != 0: + Utils.log("Failed to reload smb service") + sys.stderr.write("Failed to reload smb service\n") + sys.exit(3) + if Utils.runCommand("umount %s" % (volumeMountDirName)) != 0: + Utils.log("Failed to unmount volume %s" % (volumeName)) + sys.stderr.write("Failed to unmount volume %s\n" % (volumeName)) + sys.exit(4) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh b/src/org.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh new file mode 100755 index 00000000..b081d6db --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/update-rrd.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +/usr/bin/rrd_cpu.pl & +/usr/bin/rrd_mem.pl & +/usr/bin/rrd_net.pl & +wait diff --git a/src/org.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py new file mode 100755 index 00000000..64297a87 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/backend/update_volume_cifs.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils +import VolumeUtils + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + userList = sys.argv[2:] + + if not VolumeUtils.writeVolumeCifsConfiguration(volumeName, userList): + sys.stderr.write("Failed to update volume cifs configuration\n") + sys.exit(1) + if Utils.runCommand("service smb reload") != 0: + Utils.log("Failed to reload smb service") + sys.stderr.write("Failed to reload smb service\n") + sys.exit(2) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/common/Globals.py b/src/org.gluster.storage.management.gateway.scripts/src/common/Globals.py new file mode 100644 index 00000000..49a12b69 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/common/Globals.py @@ -0,0 +1,35 @@ +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# + +MULTICAST_GROUP = '224.224.1.1' +MULTICAST_PORT = 24729 +GLUSTER_PROBE_STRING = "GLUSTERPROBE" +GLUSTER_PROBE_VERSION = "1.0.0" +DEFAULT_BUFSIZE = 1024 +SERVER_PORT = 24731 +DEFAULT_BACKLOG = 5 +DEFAULT_TIMEOUT = 3 +DEFAULT_ID_LENGTH = 16 +GLUSTER_PLATFORM_VERSION = "3.2" + +## System configuration constants +SYSCONFIG_NETWORK_DIR = "/etc/sysconfig/network-scripts" +FSTAB_FILE = "/etc/fstab" +SAMBA_CONF_FILE = "/etc/samba/smb.conf" +REAL_SAMBA_CONF_FILE = "/etc/samba/real.smb.conf" +MODPROBE_CONF_FILE = "/etc/modprobe.d/bonding.conf" +RESOLV_CONF_FILE = "/etc/resolv.conf" +VOLUME_USER_DESCRIPTION = "Gluster Volume User" +GLUSTER_BASE_DIR = "/etc/glustermg" +REEXPORT_DIR = "/reexport" +CIFS_EXPORT_DIR = "/cifs" + +## Derived constants +VOLUME_CONF_DIR = GLUSTER_BASE_DIR + "/volumes" +VOLUME_SMBCONF_FILE = VOLUME_CONF_DIR + "/volumes.smbconf.list" + +AWS_WEB_SERVICE_URL = "http://169.254.169.254/latest" +DEFAULT_UID = 1024000 +CIFS_USER_FILE = "/opt/glustermg/etc/users.cifs" +CIFS_VOLUME_FILE = "/opt/glustermg/etc/volumes.cifs" diff --git a/src/org.gluster.storage.management.gateway.scripts/src/common/Utils.py b/src/org.gluster.storage.management.gateway.scripts/src/common/Utils.py new file mode 100644 index 00000000..3c90c533 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/common/Utils.py @@ -0,0 +1,329 @@ +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import re +import syslog +import subprocess +import time +import tempfile +import glob + +import Globals + +RUN_COMMAND_ERROR = -1024 +LOG_SYSLOG = 1 +SYSLOG_REQUIRED = False +LOG_FILE_NAME = None +LOG_FILE_OBJ = None +logOpened = False +sshCommandPrefix = "ssh -l root -q -i /opt/glustermg/keys/gluster.pem -o BatchMode=yes -o GSSAPIAuthentication=no -o PasswordAuthentication=no -o StrictHostKeyChecking=no".split() +try: + commandPath = "/opt/glustermg/%s/backend" % os.environ['GMG_VERSION'] +except KeyError, e: + commandPath = "/opt/glustermg/1.0.0/backend" + +def log(priority, message=None): + global logOpened + if not logOpened: + syslog.openlog(os.path.basename(sys.argv[0])) + logOpened = True + + if type(priority) == type(""): + logPriority = syslog.LOG_INFO + logMessage = priority + else: + logPriority = priority + logMessage = message + if not logMessage: + return + #if Globals.DEBUG: + # sys.stderr.write(logMessage) + else: + syslog.syslog(logPriority, logMessage) + return + + +def isString(value): + return (type(value) == type("") or type(value) == type(u"")) + + +def getTempFileName(): + filedesc, filename = tempfile.mkstemp(prefix="GSP_") + os.close(filedesc) + return filename + + +def readFile(fileName, lines=False): + content = None + try: + fp = open(fileName) + if lines: + content = fp.readlines() + else: + content = fp.read() + fp.close() + return content + except IOError, e: + log("failed to read file %s: %s" % (fileName, str(e))) + if lines: + return [] + else: + return "" + + +def writeFile(fileName, content): + try: + fp = open(fileName, "w") + if isString(content): + fp.write(content) + elif type(content) == type([]): + fp.writelines(content) + fp.close() + return True + except IOError, e: + log("failed to write file %s: %s" % (fileName, str(e))) + return False + + +def removeFile(fileName, root=False): + if root: + if runCommand("rm %s" % fileName, root=True) == 0: + return True + return False + try: + os.remove(fileName) + return True + except OSError, e: + log("Failed to remove file %s: %s" % (fileName, str(e))) + return False + + +def runCommandBG(command, stdinFileObj=None, stdoutFileObj=None, stderrFileObj=None, + shell=False, root=None): + if shell: + if not isString(command): + return None + else: + if isString(command): + command = command.split() + + if root == True: + if shell: + command = "sudo " + command + else: + command = ['sudo'] + command + elif isString(root): + if shell: + command = "sudo -u " + root + " " + command + else: + command = ['sudo', '-u', root] + command + + if not stdinFileObj: + stdinFileObj=subprocess.PIPE + if not stdoutFileObj: + stdoutFileObj=subprocess.PIPE + if not stderrFileObj: + stderrFileObj=subprocess.PIPE + + try: + process = subprocess.Popen(command, + bufsize=-1, + stdin=stdinFileObj, + stdout=stdoutFileObj, + stderr=stderrFileObj, + shell=shell) + return process + except OSError, e: + log("runCommandBG(): Failed to run command [%s]: %s" % (command, e)) + return None + + +def runCommand(command, + input='', output=False, + shell=False, root=None): + rv = {} + rv["Status"] = RUN_COMMAND_ERROR + rv["Stdout"] = None + rv["Stderr"] = None + + try: + stdinFileName = getTempFileName() + stdinFileObj = open(stdinFileName, "w") + stdinFileObj.write(input) + stdinFileObj.close() + stdinFileObj = open(stdinFileName, "r") + + stdoutFileName = getTempFileName() + stdoutFileObj = open(stdoutFileName, "w") + + stderrFileName = getTempFileName() + stderrFileObj = open(stderrFileName, "w") + except IOError, e: + log("Failed to create temporary file for executing command [%s]: %s" % (command, e)) + if output: + return rv + return rv["Status"] + + stdoutContent = None + stderrContent = None + + process = runCommandBG(command, + stdinFileObj=stdinFileObj, + stdoutFileObj=stdoutFileObj, + stderrFileObj=stderrFileObj, + shell=shell, root=root) + if process: + rv['Status'] = process.wait() + rv['Stdout'] = readFile(stdoutFileName) + rv['Stderr'] = readFile(stderrFileName) + + os.remove(stdinFileName) + os.remove(stdoutFileName) + os.remove(stderrFileName) + + if output: + return rv + return rv["Status"] + + +def daemonize(): + try: + pid = os.fork() + if pid > 0: + # exit first parent + sys.exit(0) + except OSError, e: + #sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror)) + return False + + # decouple from parent environment + os.chdir("/") + os.setsid() + os.umask(0) + + # do second fork + try: + pid = os.fork() + if pid > 0: + # exit from second parent + sys.exit(0) + except OSError, e: + #sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror)) + return False + + # redirect standard file descriptors + sys.stdout.flush() + sys.stderr.flush() + si = file("/dev/null", 'r') + so = file("/dev/null", 'a+') + se = file("/dev/null", 'a+', 0) + os.dup2(si.fileno(), sys.stdin.fileno()) + os.dup2(so.fileno(), sys.stdout.fileno()) + os.dup2(se.fileno(), sys.stderr.fileno()) + return True + + +def getMeminfo(): + lines = readFile("/proc/meminfo", lines=True) + re_parser = re.compile(r'^(?P\S*):\s*(?P\d*)\s*kB' ) + result = {} + for line in lines: + match = re_parser.match(line) + if not match: + continue # skip lines that don't parse + key, value = match.groups(['key', 'value']) + result[key] = int(value) + result['MemUsed'] = (result['MemTotal'] - result['MemFree'] - result['Buffers'] - result['Cached']) + return result + + +def _getCpuStatList(): + lines = readFile("/proc/stat", lines=True) + if not lines: + return None + return map(float, lines[0].split()[1:5]) + + +def getCpuUsageAvg(): + st1 = _getCpuStatList() + #time1 = time.time() + time.sleep(1) + st2 = _getCpuStatList() + #time2 = time.time() + if not (st1 and st2): + return None + usageTime = (st2[0] - st1[0]) + (st2[1] - st1[1]) + (st2[2] - st1[2]) + try: + return (100.0 * usageTime) / (usageTime + (st2[3] - st1[3])) + except ZeroDivisionError, e: + return 0 + + +def convertKbToMb(kb): + return kb / 1024.0 + + +def getDeviceFormatStatusFile(device): + return "/var/tmp/format_%s.status" % device.replace('/', '_') + + +def getDeviceFormatLockFile(device): + return "/var/lock/format_%s.lock" % device.replace('/', '_') + + +def getDeviceFormatOutputFile(device): + return "/var/tmp/format_%s.out" % device.replace('/', '_') + + +def getGlusterVersion(): + rv = runCommand("/usr/sbin/gluster --version", output=True) + if rv["Stderr"]: + return None + if rv["Status"] != 0: + return None + if not rv["Stdout"]: + return None + return rv["Stdout"].strip().split()[1] + + +def getCifsUserUid(userName): + lines = readFile(Globals.CIFS_USER_FILE, lines=True) + for line in lines: + if not line.strip(): + continue + tokens = line.strip().split(":") + if tokens[1] == userName: + return int(tokens[0]) + return None + +def grun(serverFile, command, argumentList=[]): + commandList = ["%s/%s" % (commandPath, command)] + argumentList + serverNameList = readFile(serverFile, lines=True) + if not serverNameList: + return 1 + status = True + for serverName in serverNameList: + rv = runCommand(sshCommandPrefix + [serverName.strip()] + commandList, output=True) + if rv["Status"] != 0: + sys.stderr.write("%s: %s\n" % (serverName.strip(), rv["Status"])) + sys.stderr.write("Stdout:\n%s\n" % rv["Stdout"]) + sys.stderr.write("Stderr:\n%s\n" % rv["Stderr"]) + sys.stderr.write("---\n") + status = False + + if status: + return 0 + else: + return 2 + +def getFileSystemType(): + return [os.path.basename(i).split('.')[1] for i in glob.glob("/sbin/mkfs.*")] diff --git a/src/org.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py b/src/org.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py new file mode 100644 index 00000000..d55ef07a --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py @@ -0,0 +1,332 @@ +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import xml +import xml.parsers.expat +import xml.dom.minidom as MDOM +import os +import Globals +import Utils + +XML_STRING = 0 +XML_FILE = 1 + +class XDOM: + _domObj = None + + def __init__(self): + self._domObj = MDOM.Document() + return + + @classmethod + def getText(self, nodeList): + rc = "" + for node in nodeList: + if node.nodeType == node.TEXT_NODE: + rc = rc + node.data + return rc + + def parseString(self, requestString): + try: + self._domObj = MDOM.parseString(requestString) + except xml.parsers.expat.ExpatError, e: + Utils.log("XML string parse error: %s" % str(e)) + return False + return True + + def parseFile(self, fileName): + try: + self._domObj = MDOM.parse(fileName) + except IOError, e: + Utils.log("error reading file: %s" % str(e)) + return False + except xml.parsers.expat.ExpatError, e: + Utils.log("XML file %s parse error: %s" % (fileName, str(e))) + return False + return True + + def setDomObj(self, dom): + if dom and type(dom) != type([]): + self._domObj = dom + return True + return False + + def createTag(self, tag, text=None): + if not self._domObj: + return None + if tag == None: + return None + + tagE = self._domObj.createElement(str(tag)) + if text: + tagEText = self._domObj.createTextNode(str(text)) + tagE.appendChild(tagEText) + return tagE + + def addTag(self, tag): + if not self._domObj: + return False + if not tag: + return False + + self._domObj.appendChild(tag) + return True + + def createTagRoute(self, tagRoute, text=None): + if not tagRoute: + return False + + tagList = tagRoute.split(".") + tag = None + previousTag = None + for tagName in tagList[:-1]: + newTag = self.createTag(tagName, None) + if not tag: + tag = newTag + previousTag = newTag + continue + previousTag.appendChild(newTag) + previousTag = newTag + + if previousTag: + previousTag.appendChild(self.createTag(tagList[-1], text)) + else: + tag = self.createTag(tagList[-1], text) + return tag + + def appendTagRoute(self, tagRoute, value=None): + if not self._domObj: + return False + if not tagRoute: + return False + + parentTagE = self._domObj + + tagNameList = tagRoute.split(".") + newTagRoute = tagNameList.pop(-1) + + for i in range(len(tagNameList), 0, -1): + tagE = self.getElementsByTagRoute(".".join(tagNameList[:i])) + if tagE: + parentTagE = tagE[0] + break + newTagRoute = tagNameList[i-1] + "." + newTagRoute + + newTagE = self.createTagRoute(newTagRoute, value) + if not newTagE: + return False + try: + parentTagE.appendChild(newTagE) + except xml.dom.HierarchyRequestErr, e: + Utils.log("error occured. %s" + str(e)) + return False + return True + + def setTextByTagRoute(self, tagRoute, tagValue): + if not self._domObj: + return None + + if not tagRoute: + return None + + tagE = self.getElementsByTagRoute(tagRoute) + if not tagE: + return False + + parentTagE = self.getElementsByTagRoute(".".join(tagRoute.split(".")[:-1])) + if not parentTagE: + return False + + parentTagE[0].childNodes.remove(tagE[0]) + parentTagE[0].appendChild(self.createTag(tagRoute.split(".")[-1], tagValue)) + return True + + def getElementsByTagRoute(self, tagRoute): + if not self._domObj: + return None + + if not tagRoute: + return None + + x = None + for tag in tagRoute.split("."): + if x is None: + x = self._domObj.getElementsByTagName(tag) + continue + if x == []: + break + x = x[0].getElementsByTagName(tag) + return x + + def getTextByTagRoute(self, tagRoute): + if not self._domObj: + return None + + x = self.getElementsByTagRoute(tagRoute) + if x: + return self.getText(x[0].childNodes) + return None + + def getElementsByTagName(self, name): + if not self._domObj: + return None + return self._domObj.getElementsByTagName(name) + + def writexml(self, fileName, indent="", addindent="", newl=""): + if not self._domObj: + return None + try: + fp = open(fileName, "w") + self._domObj.writexml(fp, indent, addindent, newl) + fp.close() + return True + except IOError, e: + return False + + def toString(self, indent=" ", newl="\n", encoding = None): + if not self._domObj: + return None + return self._domObj.toprettyxml(indent, newl, encoding) + + def toxml(self, encoding = None): + if not self._domObj: + return None + return self._domObj.toxml(encoding) + + def toprettyxml(self, indent=" ", newl="\n", encoding = None): + return self.toString(indent, newl, encoding) + + def createResponseTag(self): + responseTag = self._domObj.createElement("response") + return responseTag +##--end of XDOM + +class RequestXml(XDOM): + def __init__(self, requestString, type=None): + if None == requestString: + XDOM.__init__(self) + return + try: + if None == type: + if os.path.isfile(requestString): + self._domObj = MDOM.parse(requestString) + else: + self._domObj = MDOM.parseString(requestString) + elif XML_FILE == type: + self._domObj = MDOM.parse(requestString) + elif XML_STRING == type: + self._domObj = MDOM.parseString(requestString) + except IOError, e: + XDOM.__init__(self) + except xml.parsers.expat.ExpatError, e: + XDOM.__init__(self) + +##--end of RequestXML + + +class ResponseXml(XDOM): + _responseTag = None + def __init__(self): + XDOM.__init__(self) + self._responseTag = self.createResponseTag() + self._domObj.appendChild(self._responseTag) + + @classmethod + def errorResponse(self, message): + if not self.responseTag: + return False + self.appendTagRoute("status.code", "-1"); + self.appendTagRoute("status.message", message) + + def append(self, tagName, tagValue=None): + if not self._responseTag: + return False + tag = self.createTag(tagName, tagValue) + if tag: + self._responseTag.appendChild(tag) + return True + return False + + def appendTag(self, tag): + if not tag: + return False + if not self._responseTag: + return False + self._responseTag.appendChild(tag) + return True + + def appendTagRoute(self, tagRoute, value=None): + if not self._responseTag: + return None + if not tagRoute: + return None + + parentTagE = self._responseTag + + tagNameList = tagRoute.split(".") + newTagRoute = tagNameList.pop(-1) + + for i in range(len(tagNameList), 0, -1): + tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) + if tagE: + parentTagE = tagE[0] + break + newTagRoute = tagNameList[i-1] + "." + newTagRoute + + newTagE = self.createTagRoute(newTagRoute, value) + if not newTagE: + return None + try: + parentTagE.appendChild(newTagE) + except xml.dom.HierarchyRequestErr, e: + Utils.log("error occured. %s" + str(e)) + return None + return newTagE + + def appendTagRouteOld(self, tagRoute, value=None): + if not self._responseTag: + return False + if not tagRoute: + return False + + parentTagE = self._responseTag + + tagNameList = tagRoute.split(".") + newTagRoute = tagNameList.pop(-1) + + for i in range(len(tagNameList), 0, -1): + tagE = self.getElementsByTagRoute(".".join(["response"] + tagNameList[:i])) + if tagE: + parentTagE = tagE[0] + break + newTagRoute = tagNameList[i-1] + "." + newTagRoute + + newTagE = self.createTagRoute(newTagRoute, value) + if not newTagE: + return False + try: + parentTagE.appendChild(newTagE) + except xml.dom.HierarchyRequestErr, e: + Utils.log("error occured. %s" + str(e)) + return False + return True +##--end of ResponseXml + +def test(): + rs = ResponseXml() + rs.appendTagRoute("status.code", "0"); + rs.appendTagRoute("status.message", "SUCCESS") + serverTag = rs.appendTagRoute("server.name", "Server1") + networkInterfaces = rs.appendTagRoute("server.networkInterfaces", None) + networkTag = rs.createTag("networkInterface", None) + networkTag.appendChild(rs.createTag("name", "interface1")) + networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.40")) + networkInterfaces.appendChild(networkTag) + networkTag = rs.createTag("networkInterface", None) + networkTag.appendChild(rs.createTag("name", "interface2")) + networkTag.appendChild(rs.createTag("ipaddress", "192.168.1.41")) + networkInterfaces.appendChild(networkTag) + print rs.toprettyxml() + +#test() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py new file mode 100755 index 00000000..adfd031c --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py @@ -0,0 +1,78 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def getUid(userName): + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) + for line in lines: + tokens = line.strip().split(":") + if tokens[1] == userName: + return int(tokens[0]) + return None + + +def getLastUid(): + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) + if not lines: + return Globals.DEFAULT_UID + return int([line.strip().split(':')[0] for line in lines if line.strip()][-1]) + + +def setUid(uid, userName): + try: + fp = open(Globals.CIFS_USER_FILE, "a") + fp.write("%s:%s\n" % (uid, userName)) + fp.close() + return True + except IOError, e: + Utils.log("failed to write file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) + return False + + +def main(): + if len(sys.argv) < 4: + sys.stderr.write("usage: %s SERVER_FILE USERNAME PASSWORD\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverFile = sys.argv[1] + userName = sys.argv[2] + password = sys.argv[3] + + existingUser = False + uid = getUid(userName) + if not uid: + uid = getLastUid() + if not uid: + sys.stderr.write("Unable to read file %s\n" % Globals.CIFS_USER_FILE) + sys.exit(10) + uid += 1 + else: + existingUser = True + + print (serverFile, uid, userName, password) + rv = Utils.grun(serverFile, "add_user_cifs.py", [uid, userName, password]) + if existingUser: + sys.exit(rv) + + if rv == 0: + if not setUid(uid, userName): + sys.stderr.write("Failed to add the user\n") + sys.exit(11) + sys.exit(rv) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py new file mode 100755 index 00000000..8a43e7dc --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py @@ -0,0 +1,62 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def addVolumeCifsConf(volumeName, userList): + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) + try: + fp = open(Globals.CIFS_VOLUME_FILE, "w") + for line in lines: + if not line.strip(): + continue + if line.strip().split(":")[0] != volumeName: + fp.write("%s\n" % line) + fp.write("%s:%s\n" % (volumeName, ":".join(userList))) + fp.close() + except IOError, e: + Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) + return False + return True + + +def main(): + if len(sys.argv) < 4: + sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverFile = sys.argv[1] + volumeName = sys.argv[2] + userList = sys.argv[3:] + + missingUserList = [] + for userName in userList: + if not Utils.getCifsUserUid(userName): + missingUserList.append(userName) + + if missingUserList: + sys.stderr.write("User %s does not exists\n" % missingUserList) + sys.exit(1) + + rv = Utils.grun(serverFile, "create_volume_cifs.py", [volumeName] + userList) + if rv == 0: + if not addVolumeCifsConf(volumeName, userList): + sys.stderr.write("Failed to add volume %s and user-list %s in cifs volume configuration\n" % (volumeName, userList)) + sys.exit(11) + sys.exit(rv) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py new file mode 100755 index 00000000..a86e7264 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py @@ -0,0 +1,52 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def removeUser(userName): + lines = Utils.readFile(Globals.CIFS_USER_FILE, lines=True) + try: + fp = open(Globals.CIFS_USER_FILE, "w") + for line in lines: + if not line.strip(): + continue + if line.split(":")[1] == userName: + continue + fp.write("%s\n" % line) + fp.close() + except IOError, e: + Utils.log("failed to write file %s: %s" % (Globals.CIFS_USER_FILE, str(e))) + return False + return True + + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s SERVER_FILE USERNAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverFile = sys.argv[1] + userName = sys.argv[2] + + rv = Utils.grun(serverFile, "delete_user_cifs.py", [userName]) + if rv == 0: + if not removeUser(userName): + Utils.log("Failed to remove the user:%s on gateway server\n" % userName) + sys.exit(0) + sys.exit(rv) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py new file mode 100755 index 00000000..925a3548 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def removeVolumeCifsConf(volumeName): + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) + try: + fp = open(Globals.CIFS_VOLUME_FILE, "w") + for line in lines: + if not line.strip(): + continue + if line.strip().split(":")[0] != volumeName: + fp.write("%s\n" % line) + fp.close() + except IOError, e: + Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) + return False + return True + + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverFile = sys.argv[1] + volumeName = sys.argv[2] + + rv = Utils.grun(serverFile, "delete_volume_cifs.py", [volumeName]) + if rv == 0: + if not removeVolumeCifsConf(volumeName): + sys.stderr.write("Failed to remove volume %s and user-list in cifs volume configuration\n" % volumeName) + sys.exit(11) + sys.exit(rv) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py new file mode 100755 index 00000000..c072a556 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def main(): + if len(sys.argv) < 2: + sys.stderr.write("usage: %s VOLUME_NAME\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + volumeName = sys.argv[1] + + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) + for line in lines: + if not line.strip(): + continue + tokens = line.strip().split(":") + if tokens[0] == volumeName: + print "\n".join(tokens[1:]) + sys.exit(0) + # given volume is not configured for cifs export + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh b/src/org.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh new file mode 100755 index 00000000..b39fe6b5 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh @@ -0,0 +1,26 @@ +#----------------------------------------------------------------------------------- +# gmg-reset-password.sh - script to reset password of given user to default password +#----------------------------------------------------------------------------------- + +USAGE_ERR=1 + +if [ $# -ne 1 ]; then + echo "Usage: ${0} " + echo + exit ${USAGE_ERR} +fi + +CURR_DIR=${PWD} +SCRIPT_PATH=`readlink -f ${0}` +GLUSTERMG_DIR=`dirname ${SCRIPT_PATH}` + +# Main action body +cd ${GLUSTERMG_DIR} +cd .. +for FILE in WEB-INF/lib/*.jar +do + export CLASSPATH=${CLASSPATH}:${PWD}/${FILE} +done +export CLASSPATH=${PWD}/WEB-INF/classes:${CLASSPATH} +cd ${CURR_DIR} +java org.gluster.storage.management.gateway.utils.PasswordManager reset ${1} diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/grun.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/grun.py new file mode 100755 index 00000000..6519d726 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/grun.py @@ -0,0 +1,21 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + + +if len(sys.argv) < 3: + sys.stderr.write("usage: %s SERVER_FILE COMMAND [ARGUMENTS]\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + +sys.exit(Utils.grun(sys.argv[1], sys.argv[2], sys.argv[3:])) diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py new file mode 100755 index 00000000..ded207c0 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py @@ -0,0 +1,112 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import socket +import select +import signal +import random +import string +import Utils +import Globals + +running = True + + +def exitHandler(signum, frame): + running = False + + +def sendMulticastRequest(idString): + multicastSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) + multicastSocket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) + multicastSocket.sendto("%s,%s,%s\n" % (Globals.GLUSTER_PROBE_STRING, Globals.GLUSTER_PROBE_VERSION, idString), + (Globals.MULTICAST_GROUP, Globals.MULTICAST_PORT)) + return multicastSocket + + +def openServerSocket(): + try: + server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server.setblocking(0) + server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server.bind(('', Globals.SERVER_PORT)) + server.listen(Globals.DEFAULT_BACKLOG) + return server + except socket.error, e: + Utils.log("failed to open server socket on port %s: %s" % (Globals.SERVER_PORT, str(e))) + sys.stderr.write("failed to open server socket on port %s: %s\n" % (Globals.SERVER_PORT, str(e))) + sys.exit(1) + + +def main(): + signal.signal(signal.SIGINT, exitHandler) + signal.signal(signal.SIGTERM, exitHandler) + signal.signal(signal.SIGALRM, exitHandler) + + idString = ''.join(random.choice(string.ascii_lowercase + + string.ascii_uppercase + + string.digits) for x in range(Globals.DEFAULT_ID_LENGTH)) + + multicastSocket = sendMulticastRequest(idString) + + serverInfoDict = {} + serverSocket = openServerSocket() + rlist = [serverSocket] + signal.alarm(Globals.DEFAULT_TIMEOUT) + while running: + try: + ilist,olist,elist = select.select(rlist, [], [], 0.1) + except select.error, e: + Utils.log("failed to read from connections: %s" % str(e)) + break + for sock in ilist: + # handle new connection + if sock == serverSocket: + clientSocket, address = serverSocket.accept() + clientSocket.setblocking(0) + #print "connection from %s on %s" % (address, clientSocket) + rlist.append(clientSocket) + continue + + # handle all other sockets + data = sock.recv(Globals.DEFAULT_BUFSIZE) + if not data: + #print "closing socket %s" % sock + sock.close() + rlist.remove(sock) + tokens = data.strip().split(",") + if len(tokens) != 6: + continue + if not (tokens[0] == Globals.GLUSTER_PROBE_STRING and \ + tokens[1] == Globals.GLUSTER_PROBE_VERSION and \ + tokens[2] == idString): + continue + serverInfoDict[tokens[3]] = [tokens[4], tokens[5]] + #print "closing socket %s" % sock + sock.close() + rlist.remove(sock) + + for sock in rlist: + sock.close() + + for k, v in serverInfoDict.iteritems(): + if v[0]: + print v[0] + else: + print k + + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py new file mode 100755 index 00000000..27fb9b92 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py @@ -0,0 +1,68 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def main(): + if len(sys.argv) < 3: + sys.stderr.write("usage: %s SERVER_NAME VOLUME_FILE\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverName = sys.argv[1] + volumeFile = sys.argv[2] + + lines = Utils.readFile(volumeFile, lines=True) + volumeNameList = [line.strip() for line in lines] + if not volumeNameList: + sys.exit(0) + + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) + cifsVolumeList = [line.strip().split(":")[0] for line in lines if line.strip()] + runningCifsVolumeList = set(cifsVolumeList).intersection(set(volumeNameList)) + + if not runningCifsVolumeList: + sys.exit(0) + + tempFileName = Utils.getTempFileName() + try: + fp = open(tempFileName, "w") + fp.write("%s\n" % serverName) + fp.close() + except IOError, e: + Utils.log("Failed to write server name to file %s: %s" % (tempFileName, str(e))) + sys.stderr.write("Failed to write server name to file %s: %s\n" % (tempFileName, str(e))) + sys.exit(3) + + status = True + for volumeName in runningCifsVolumeList: + if Utils.grun(tempFileName, "stop_volume_cifs.py", [volumeName.strip()]) != 0: + status = False + if Utils.grun(tempFileName, "delete_volume_cifs.py", [volumeName.strip()]) != 0: + status = False + + try: + os.remove(tempFileName) + except OSError, e: + Utils.log("Failed to remove temporary file %s: %s" % (tempFileName, str(e))) + sys.stderr.write("Failed to remove temporary file %s: %s\n" % (tempFileName, str(e))) + pass + + if status: + sys.exit(0) + else: + sys.exit(2) + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py new file mode 100755 index 00000000..e7e0a4a0 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Utils + + +def main(): + if len(sys.argv) < 2: + sys.stderr.write("usage: %s SERVER_FILE\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverFile = sys.argv[1] + + rv = Utils.grun(serverFile, "setup_cifs_config.py") + sys.exit(rv) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py b/src/org.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py new file mode 100755 index 00000000..e5576c45 --- /dev/null +++ b/src/org.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# Copyright (C) 2011 Gluster, Inc. +# This file is part of Gluster Management Gateway. +# + +import os +import sys +p1 = os.path.abspath(os.path.dirname(sys.argv[0])) +p2 = "%s/common" % os.path.dirname(p1) +if not p1 in sys.path: + sys.path.append(p1) +if not p2 in sys.path: + sys.path.append(p2) +import Globals +import Utils + + +def updateVolumeCifsConf(volumeName, userList): + lines = Utils.readFile(Globals.CIFS_VOLUME_FILE, lines=True) + try: + fp = open(Globals.CIFS_VOLUME_FILE, "w") + for line in lines: + if not line.strip(): + continue + if line.strip().split(":")[0] == volumeName: + fp.write("%s:%s\n" % (volumeName, ":".join(userList))) + else: + fp.write("%s\n" % line.strip()) + fp.close() + except IOError, e: + Utils.log("failed to write file %s: %s" % (Globals.CIFS_VOLUME_FILE, str(e))) + return False + return True + + +def main(): + if len(sys.argv) < 4: + sys.stderr.write("usage: %s SERVER_FILE VOLUME_NAME USER1 USER2 ...\n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + serverFile = sys.argv[1] + volumeName = sys.argv[2] + userList = sys.argv[3:] + + missingUserList = [] + for userName in userList: + if not Utils.getCifsUserUid(userName): + missingUserList.append(userName) + + if missingUserList: + sys.stderr.write("User %s does not exists\n" % missingUserList) + sys.exit(1) + + rv = Utils.grun(serverFile, "update_volume_cifs.py", [volumeName] + userList) + if rv == 0: + if not updateVolumeCifsConf(volumeName, userList): + sys.stderr.write("Failed to update volume %s and user-list %s in cifs volume configuration\n" % (volumeName, userList)) + sys.exit(11) + sys.exit(rv) + + +if __name__ == "__main__": + main() diff --git a/src/org.gluster.storage.management.gateway/.classpath b/src/org.gluster.storage.management.gateway/.classpath new file mode 100644 index 00000000..894a6c4d --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.classpath @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/.project b/src/org.gluster.storage.management.gateway/.project new file mode 100644 index 00000000..c0861c4e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.project @@ -0,0 +1,36 @@ + + + org.gluster.storage.management.gateway + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/src/org.gluster.storage.management.gateway/.settings/.jsdtscope b/src/org.gluster.storage.management.gateway/.settings/.jsdtscope new file mode 100644 index 00000000..3a28de0c --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..d159aeca --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Tue Sep 20 14:10:09 IST 2011 +eclipse.preferences.version=1 +encoding//src/rebel.xml=UTF-8 diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..476db350 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Dec 29 14:57:23 IST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 00000000..5d9c71b6 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,3 @@ +#Mon Jan 31 15:29:36 IST 2011 +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component new file mode 100644 index 00000000..5d8e9376 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.component @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..8f960f27 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 00000000..3bd5d0a4 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 00000000..05bd71b6 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs new file mode 100644 index 00000000..e5ca6272 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/.settings/org.eclipse.wst.ws.service.policy.prefs @@ -0,0 +1,3 @@ +#Mon Jan 31 15:29:36 IST 2011 +eclipse.preferences.version=1 +org.eclipse.wst.ws.service.policy.projectEnabled=false diff --git a/src/org.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF b/src/org.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt new file mode 100644 index 00000000..d24fbfdb --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-LICENSE.txt @@ -0,0 +1,135 @@ +The GNU General Public License (GPL) Version 2, June 1991 + + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + + Copyright (C) + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. + + +"CLASSPATH" EXCEPTION TO THE GPL VERSION 2 + +Certain source files distributed by Oracle are subject to the following clarification and special exception to the GPL Version 2, but only where Oracle has expressly included in the particular source file's header the words "Oracle designates this particular file as subject to the "Classpath" exception as provided by Oracle in the License file that accompanied this code." + +Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination. + +As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt new file mode 100644 index 00000000..b3acf520 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/Jersey-third-party-license-readme.txt @@ -0,0 +1,188 @@ + +DO NOT TRANSLATE OR LOCALIZE. + +%% The following software may be included in this product: ASM + Use of any of this software is governed by the terms of the license below: + +Copyright (c) 2000-2005 INRIA, France Telecom +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +%% The following software may be included in this product: Jettison + Use of any of this software is governed by the terms of the license below: + + +Copyright 2006 Envoi Solutions LLC + +Licensed 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. + +-------------------------------------------------------------------------- + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. +Copyright [yyyy] [name of copyright owner] Licensed 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. + + + +%% The following software may be included in this product: Jackson + Use of any of this software is governed by the terms of the license below: + + +Jackson is dual-licensed under two alternative popular Open Source licenses: Apache (AL 2.0) and Gnu Lesser GPL (LGPL 2.1). You choose one or the other, as necessary (if you want to redistribute the code ¿ for use, you do not need license), and abide by the license rules as defined by the respective license agreement (and only that one). + +-------------------------------------------------------------------------- + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. +Copyright [yyyy] [name of copyright owner] Licensed 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. + + diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar new file mode 100644 index 00000000..3702b645 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/antlr-2.7.6.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar new file mode 100644 index 00000000..578b1a0c Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/aopalliance-1.0.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar new file mode 100644 index 00000000..8217cae0 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/asm-3.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar new file mode 100644 index 00000000..41e230fe Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-collections-3.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar new file mode 100644 index 00000000..8758a96b Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar new file mode 100644 index 00000000..dc8ae8df Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derby.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar new file mode 100644 index 00000000..ca367aae Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/derbytools.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar new file mode 100644 index 00000000..c8c4dbb9 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/dom4j-1.6.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt new file mode 100644 index 00000000..3eddd42f --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250-LICENSE.txt @@ -0,0 +1,87 @@ +Copyright (c) 2006 - 2010 Christian Plattner. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +a.) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +b.) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +c.) Neither the name of Christian Plattner nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +This software includes work that was released under the following license: + +Copyright (c) 2005 - 2006 Swiss Federal Institute of Technology (ETH Zurich), + Department of Computer Science (http://www.inf.ethz.ch), + Christian Plattner. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +a.) Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +b.) Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +c.) Neither the name of ETH Zurich nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +The Java implementations of the AES, Blowfish and 3DES ciphers have been +taken (and slightly modified) from the cryptography package released by +"The Legion Of The Bouncy Castle". + +Their license states the following: + +Copyright (c) 2000 - 2004 The Legion Of The Bouncy Castle +(http://www.bouncycastle.org) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar new file mode 100644 index 00000000..c0a9ac7b Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/ganymed-ssh2-build250.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar new file mode 100644 index 00000000..4c9ac4e9 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar new file mode 100644 index 00000000..c1c81141 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/hibernate3.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar new file mode 100644 index 00000000..a3248188 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-core-asl-1.5.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar new file mode 100644 index 00000000..faf12cf6 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-jaxrs-1.5.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar new file mode 100644 index 00000000..ca612580 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-mapper-asl-1.5.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar new file mode 100644 index 00000000..57c2c670 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jackson-xc-1.5.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar new file mode 100644 index 00000000..8f692f4f Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/javassist-3.12.0.GA.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar new file mode 100644 index 00000000..62f790fa Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-client-1.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar new file mode 100644 index 00000000..92b38466 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-core-1.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar new file mode 100644 index 00000000..01d8c83b Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-json-1.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar new file mode 100644 index 00000000..1c134f05 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-multipart-1.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar new file mode 100644 index 00000000..a29d7409 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-server-1.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar new file mode 100644 index 00000000..c79b4490 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jersey-spring-1.5.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar new file mode 100644 index 00000000..e4e9c8c3 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jettison-1.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar new file mode 100644 index 00000000..23782c02 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jnlp-servlet.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar new file mode 100644 index 00000000..ec8bc818 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jsr311-api-1.1.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar new file mode 100644 index 00000000..6d225b76 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/jta-1.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar new file mode 100644 index 00000000..3f9d8476 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/log4j-1.2.16.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar new file mode 100644 index 00000000..48cc9295 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/mimepull-1.3.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar new file mode 100644 index 00000000..a5d37aa1 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.eclipse.equinox.common_3.6.0.v20100503.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar new file mode 100644 index 00000000..db6f529f Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aop-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar new file mode 100644 index 00000000..7cd3a626 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.asm-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar new file mode 100644 index 00000000..11fc11b9 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.aspects-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar new file mode 100644 index 00000000..f2e2e927 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.beans-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar new file mode 100644 index 00000000..bd1367d8 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar new file mode 100644 index 00000000..e46f9eb8 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.context.support-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar new file mode 100644 index 00000000..ea9500d6 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.core-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar new file mode 100644 index 00000000..6ef99d8d Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.expression-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar new file mode 100644 index 00000000..e149290e Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar new file mode 100644 index 00000000..dcd1e4d9 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.instrument.tomcat-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar new file mode 100644 index 00000000..f7a3b837 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jdbc-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar new file mode 100644 index 00000000..9cea2aef Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.jms-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar new file mode 100644 index 00000000..d0550ccd Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.orm-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar new file mode 100644 index 00000000..1688cf74 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.oxm-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd new file mode 100644 index 00000000..b3aa6af8 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.spring-library-3.0.5.RELEASE.libd @@ -0,0 +1,21 @@ +Library-SymbolicName: org.springframework.spring +Library-Version: 3.0.5.RELEASE +Library-Name: Spring Framework +Import-Bundle: + org.springframework.aop;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.asm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.aspects;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.beans;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.context;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.context.support;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.core;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.expression;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.jdbc;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.jms;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.orm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.oxm;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.transaction;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.web;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.web.servlet;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + org.springframework.web.portlet;version="[3.0.5.RELEASE, 3.0.5.RELEASE]", + com.springsource.org.aopalliance;version="[1.0.0, 1.0.0]" diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar new file mode 100644 index 00000000..237995c5 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.test-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar new file mode 100644 index 00000000..2f52122b Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.transaction-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar new file mode 100644 index 00000000..5a2381a0 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar new file mode 100644 index 00000000..6ec9d681 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.portlet-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar new file mode 100644 index 00000000..6d13bd40 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.servlet-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar new file mode 100644 index 00000000..e351ae7b Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/org.springframework.web.struts-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar new file mode 100644 index 00000000..e5bc672b Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/servlet-api.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar new file mode 100644 index 00000000..f1f4fdd2 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/slf4j-api-1.6.1.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-framework-3.0.5.RELEASE-LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-3.0.5.RELEASE-LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar new file mode 100644 index 00000000..78818fc5 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-config-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar new file mode 100644 index 00000000..a8077d5d Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-core-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar new file mode 100644 index 00000000..26611b55 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/lib/spring-security-web-3.0.5.RELEASE.jar differ diff --git a/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml new file mode 100644 index 00000000..4903f01d --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/WEB-INF/web.xml @@ -0,0 +1,76 @@ + + + glustermg + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + + contextConfigLocation + + classpath:spring/gluster-server-security.xml + classpath:spring/gluster-server-base.xml + + + + org.springframework.web.context.ContextLoaderListener + + + org.springframework.web.context.request.RequestContextListener + + + org.gluster.storage.management.gateway.listeners.ShutdownListener + + + gluster-resources-1.0 + com.sun.jersey.spi.spring.container.servlet.SpringServlet + + com.sun.jersey.config.property.packages + org.gluster.storage.management.gateway.resources.v1_0 + + + com.sun.jersey.spi.container.ResourceFilters + org.gluster.storage.management.gateway.filters.GlusterResourceFilterFactory + + 1 + + + gluster-resources-1.0 + /1.0.0/* + + + JnlpDownloadServlet + jnlp.sample.servlet.JnlpDownloadServlet + + + JnlpDownloadServlet + *.jnlp + + + JnlpDownloadServlet + *.jar + + + springSecurityFilterChain + + org.springframework.web.filter.DelegatingFilterProxy + + + + springSecurityFilterChain + /* + + + + Gluster Management Gateway + /* + + + CONFIDENTIAL + + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql new file mode 100644 index 00000000..4c3d81d1 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/0-version.sql @@ -0,0 +1,2 @@ +create table version (version varchar(16) not null primary key); +insert into version(version) values('1.0.0'); \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql new file mode 100644 index 00000000..4f61fc9d --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/1-security-schema.sql @@ -0,0 +1,26 @@ +create table users( + username varchar(32) not null primary key, + password varchar(124) not null, + enabled smallint not null + ); + + create table authorities ( + username varchar(32) not null, + authority varchar(50) not null, + constraint fk_authorities_users foreign key(username) references users(username)); + create unique index ix_auth_username on authorities (username,authority); + +create table groups ( + id bigint generated by default as identity(start with 0) primary key, + group_name varchar(50) not null); + +create table group_authorities ( + group_id bigint not null, + authority varchar(50) not null, + constraint fk_group_authorities_group foreign key(group_id) references groups(id)); + +create table group_members ( + id bigint generated by default as identity(start with 0) primary key, + username varchar(32) not null, + group_id bigint not null, + constraint fk_group_members_group foreign key(group_id) references groups(id)); diff --git a/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql new file mode 100644 index 00000000..5bd73813 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/2-users-authorities-groups.sql @@ -0,0 +1,18 @@ +-- Create users +insert into users(username, password, enabled) values ('gluster','syst3m',1); + +-- Assign authorities to users (to be removed after implementing user group functionality) +insert into authorities(username,authority) values ('gluster','ROLE_USER'); +insert into authorities(username,authority) values ('gluster','ROLE_ADMIN'); + +-- Create user groups +insert into groups(group_name) values ('Users'); +insert into groups(group_name) values ('Administrators'); + +-- Add authorities to groups (functionality not yet implemented in code) +insert into group_authorities(group_id, authority) select id,'ROLE_USER' from groups where group_name='Users'; +insert into group_authorities(group_id, authority) select id,'ROLE_USER' from groups where group_name='Administrators'; +insert into group_authorities(group_id, authority) select id,'ROLE_ADMIN' from groups where group_name='Administrators'; + +-- Assign group members +insert into group_members(group_id, username) select id,'gluster' from groups where group_name='Administrators'; \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql new file mode 100644 index 00000000..17ca62d2 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/data/scripts/1.0.0/3-cluster-servers.sql @@ -0,0 +1,16 @@ +create table cluster_info ( + id bigint generated by default as identity, + name varchar(255), + primary key (id)); + +create unique index ix_cluster_name on cluster_info (name); + +create table server_info ( + id bigint generated by default as identity, + name varchar(255), + cluster_id bigint, + primary key (id)); + +create unique index ix_cluster_server on server_info (name, cluster_id); + +alter table server_info add constraint FK_CLUSTER_ID foreign key (cluster_id) references cluster_info(id); \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/index.html b/src/org.gluster.storage.management.gateway/WebContent/index.html new file mode 100644 index 00000000..5947cf11 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/index.html @@ -0,0 +1,158 @@ + + + Gluster Management Console + + + + + +

    Gluster Management Console

    +
    + Identifying your Operating System and CPU architecture... +
    + + +
    + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/Globals.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/Globals.py new file mode 120000 index 00000000..7d230498 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/Globals.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/common/Globals.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/Protocol.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/Protocol.py new file mode 120000 index 00000000..7ecad84d --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/Protocol.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/common/Protocol.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/Utils.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/Utils.py new file mode 120000 index 00000000..df26ff44 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/Utils.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/common/Utils.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py new file mode 120000 index 00000000..880349a1 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/XmlHandler.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/common/XmlHandler.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py new file mode 120000 index 00000000..fec57917 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/add_user_cifs_all.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/add_user_cifs_all.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py new file mode 120000 index 00000000..03752d57 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/create_volume_cifs_all.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/create_volume_cifs_all.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py new file mode 120000 index 00000000..d517e46c --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/delete_user_cifs_all.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/delete_user_cifs_all.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py new file mode 120000 index 00000000..be9e627c --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/delete_volume_cifs_all.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/delete_volume_cifs_all.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py new file mode 120000 index 00000000..3eff03fd --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/get_volume_user_cifs.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/get_volume_user_cifs.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh b/src/org.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh new file mode 120000 index 00000000..13b9a40b --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/gmg-reset-password.sh @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/gmg-reset-password.sh \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/grun.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/grun.py new file mode 120000 index 00000000..5e56bfbb --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/grun.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/grun.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py new file mode 120000 index 00000000..6288f182 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/multicast-discover-servers.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/multicast-discover-servers.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py new file mode 120000 index 00000000..32d1dec4 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/remove_server_volume_cifs_config.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/remove_server_volume_cifs_config.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py new file mode 120000 index 00000000..e3f44800 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/setup_cifs_config_all.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/setup_cifs_config_all.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py b/src/org.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py new file mode 120000 index 00000000..8496fae4 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/WebContent/scripts/update_volume_cifs_all.py @@ -0,0 +1 @@ +../../../com.gluster.storage.management.gateway.scripts/src/gateway/update_volume_cifs_all.py \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore b/src/org.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore new file mode 100644 index 00000000..2efe19b0 Binary files /dev/null and b/src/org.gluster.storage.management.gateway/WebContent/ssl/gmg-ssl.keystore differ diff --git a/src/org.gluster.storage.management.gateway/buckminster.cspex b/src/org.gluster.storage.management.gateway/buckminster.cspex new file mode 100644 index 00000000..31eb9d67 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/buckminster.cspex @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/build/glusterserver.ant b/src/org.gluster.storage.management.gateway/build/glusterserver.ant new file mode 100644 index 00000000..9ba36f55 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/build/glusterserver.ant @@ -0,0 +1,70 @@ + + + + + + + + + + + -------------------------------------------------- + compile - Compile + archive - Generate WAR file + -------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/src/META-INF/persistence.xml b/src/org.gluster.storage.management.gateway/src/META-INF/persistence.xml new file mode 100644 index 00000000..36b252ea --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/META-INF/persistence.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/src/log4j.properties b/src/org.gluster.storage.management.gateway/src/log4j.properties new file mode 100644 index 00000000..3ffa6b9e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/log4j.properties @@ -0,0 +1,20 @@ +log4j.rootLogger=INFO, R + +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.immediateFlush=true +log4j.appender.CONSOLE.target=System.out +log4j.appender.CONSOLE.threshold=DEBUG +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{dd MMM, yyyy HH:mm:ss} %p: %c %t - %m%n + +log4j.appender.R=org.apache.log4j.RollingFileAppender +log4j.appender.R.File=/var/log/glustermg/glustermg.log +log4j.appender.R.MaxFileSize=10MB +log4j.appender.R.MaxBackupIndex=10 +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%d{dd MMM, yyyy HH:mm:ss} %p: %c %t - %m%n +#log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n + +log4j.logger.org=ERROR +log4j.logger.com=ERROR +log4j.logger.org.gluster=DEBUG \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ClusterInfo.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ClusterInfo.java new file mode 100644 index 00000000..ba197b92 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ClusterInfo.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.data; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.tool.hbm2ddl.SchemaExport; + +@Entity(name="cluster_info") +public class ClusterInfo { + @Id + @GeneratedValue + private Integer id; + + private String name; + + @OneToMany(mappedBy="cluster") + private List servers = new ArrayList(); + + public void setId(Integer id) { + this.id = id; + } + + public Integer getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setServers(List servers) { + this.servers = servers; + } + + public List getServers() { + return servers; + } + + public void addServer(ServerInfo server) { + servers.add(server); + } + + public static void main(String args[]) { + AnnotationConfiguration config = new AnnotationConfiguration(); + config.addAnnotatedClass(ClusterInfo.class); + config.addAnnotatedClass(ServerInfo.class); + config.configure(); + new SchemaExport(config).create(true, true); + } + +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/GlusterDataSource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/GlusterDataSource.java new file mode 100644 index 00000000..f0b0311e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/GlusterDataSource.java @@ -0,0 +1,48 @@ +/** + * GlusterDataSource.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.data; + +import javax.servlet.ServletContext; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.stereotype.Component; + +@Component +public class GlusterDataSource extends DriverManagerDataSource { + @Autowired + ServletContext servletContext; + + public GlusterDataSource() { + setDriverClassName(org.apache.derby.jdbc.EmbeddedDriver.class.getName()); + + setUsername("gluster"); + // TODO: change to a stronger (encrypted) password + setPassword("gluster"); + } + + public DriverManagerDataSource getDataSource() { + // Database directory = work/data relative to context root + setUrl("jdbc:derby:" + servletContext.getRealPath("data") + ";create=true"); + + return this; + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/PersistenceDao.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/PersistenceDao.java new file mode 100644 index 00000000..49348084 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/PersistenceDao.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.data; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.EntityTransaction; +import javax.persistence.PersistenceUnit; +import javax.persistence.Query; + +/** + * + */ +public class PersistenceDao { + private Class type; + + private EntityManager entityManager; + + @PersistenceUnit + private EntityManagerFactory entityManagerFactory; + + public PersistenceDao(Class type) { + this.type = type; + } + + public EntityTransaction startTransaction() { + EntityTransaction txn = getEntityManager().getTransaction(); + txn.begin(); + return txn; + } + + private synchronized EntityManager getEntityManager() { + if (entityManager == null) { + entityManager = entityManagerFactory.createEntityManager(); + } + return entityManager; + } + + public Object getSingleResult(String query) { + return getEntityManager().createQuery(query).getSingleResult(); + } + + public Object getSingleResult(String queryString, String... params) { + return createQuery(queryString, params).getSingleResult(); + } + + private Query createQuery(String queryString, String... params) { + Query query = getEntityManager().createQuery(queryString); + for (int i = 0; i < params.length; i++) { + query.setParameter(i + 1, params[i]); + } + return query; + } + + public Object getSingleResultFromSQL(String sqlQuery) { + return getEntityManager().createNativeQuery(sqlQuery).getSingleResult(); + } + + @SuppressWarnings("rawtypes") + public List findBySQL(String sqlQuery) { + return getEntityManager().createNativeQuery(sqlQuery).getResultList(); + } + + public T findById(int id) { + return getEntityManager().find(type, id); + } + + @SuppressWarnings("unchecked") + public List findAll() { + return getEntityManager().createQuery("select t from " + type.getName() + " t").getResultList(); + } + + @SuppressWarnings("unchecked") + public List findBy(String whereClause) { + return getEntityManager().createQuery("select t from " + type.getName() + " t where " + whereClause) + .getResultList(); + } + + @SuppressWarnings("unchecked") + public List findBy(String whereClause, String... params) { + return createQuery("select t from " + type.getName() + " t where " + whereClause, params).getResultList(); + } + + public void save(Object obj) { + getEntityManager().persist(obj); + } + + public T update(T obj) { + return getEntityManager().merge(obj); + } + + public void delete(Object obj) { + getEntityManager().remove(obj); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ServerInfo.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ServerInfo.java new file mode 100644 index 00000000..84df2f1a --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/data/ServerInfo.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +/** + * + */ +@Entity(name="server_info") +public class ServerInfo { + @Id + @GeneratedValue + private Integer id; + + private String name; + + @ManyToOne + @JoinColumn(name="cluster_id") + private ClusterInfo cluster; + + public ServerInfo() { + } + + public ServerInfo(String name) { + setName(name); + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setCluster(ClusterInfo cluster) { + this.cluster = cluster; + } + + public ClusterInfo getCluster() { + return cluster; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuditFilter.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuditFilter.java new file mode 100644 index 00000000..76b329ee --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuditFilter.java @@ -0,0 +1,48 @@ +/** + * + */ +package org.gluster.storage.management.gateway.filters; + +import java.security.Principal; + +import org.apache.log4j.Logger; + +import com.sun.jersey.spi.container.ContainerRequest; +import com.sun.jersey.spi.container.ContainerRequestFilter; +import com.sun.jersey.spi.container.ContainerResponse; +import com.sun.jersey.spi.container.ContainerResponseFilter; +import com.sun.jersey.spi.container.ResourceFilter; + +/** + * Resource filter for maintaining audit trail of resource access + */ +public class AuditFilter implements ResourceFilter, ContainerRequestFilter, ContainerResponseFilter { + private static final Logger logger = Logger.getLogger(AuditFilter.class); + + @Override + public ContainerRequestFilter getRequestFilter() { + return this; + } + + @Override + public ContainerResponseFilter getResponseFilter() { + return this; + } + + @Override + public ContainerRequest filter(ContainerRequest req) { + Principal principal = req.getUserPrincipal(); + if(principal != null) { + logger.info("REQUEST from [" + principal.getName() + "] : [" + req.getMethod() + "][" + req.getPath() + "]"); + } else { + logger.info("REQUEST [" + req.getMethod() + "][" + req.getPath() + "]"); + } + return req; + } + + @Override + public ContainerResponse filter(ContainerRequest req, ContainerResponse response) { + logger.info("RESPONSE: [" + req.getMethod() + "][" + req.getPath() + "]"); + return response; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java new file mode 100644 index 00000000..4bb7f37c --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/AuthenticationFailureFilter.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.filters; + +import java.io.CharArrayWriter; +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; +import javax.ws.rs.core.Response; + +/** + * @author root + * + */ +public class AuthenticationFailureFilter implements Filter { + + /* + * (non-Javadoc) + * + * @see javax.servlet.Filter#destroy() + */ + @Override + public void destroy() { + // TODO Auto-generated method stub + + } + + public class CharResponseWrapper extends HttpServletResponseWrapper { + private CharArrayWriter output; + + public String toString() { + return output.toString(); + } + + public CharResponseWrapper(HttpServletResponse response) { + super(response); + output = new CharArrayWriter(); + } + + public PrintWriter getWriter() { + return new PrintWriter(output); + } + } + + /* + * (non-Javadoc) + * + * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, + * javax.servlet.FilterChain) + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, + ServletException { + HttpServletRequest request = (HttpServletRequest) req; + if (request.getRequestURI().contains("download")) { + chain.doFilter(req, res); + return; + } + + CharResponseWrapper wrapper = new CharResponseWrapper((HttpServletResponse) res); + chain.doFilter(req, wrapper); + + if(wrapper.getStatus() == Response.Status.UNAUTHORIZED.ordinal()) { + PrintWriter out = res.getWriter(); + out.println("1Authentication Failed!"); + } + } + + /* + * (non-Javadoc) + * + * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) + */ + @Override + public void init(FilterConfig arg0) throws ServletException { + // TODO Auto-generated method stub + + } + +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java new file mode 100644 index 00000000..8772cdcd --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/filters/GlusterResourceFilterFactory.java @@ -0,0 +1,31 @@ +/** + * + */ +package org.gluster.storage.management.gateway.filters; + +import java.util.ArrayList; +import java.util.List; + +import com.sun.jersey.api.model.AbstractMethod; +import com.sun.jersey.spi.container.ResourceFilter; +import com.sun.jersey.spi.container.ResourceFilterFactory; + +/** + * Gluster resource filter factory. As of now, this creates only one filter - the audit filter {@code AuditFilter} + */ +public class GlusterResourceFilterFactory implements ResourceFilterFactory { + + public GlusterResourceFilterFactory() { + } + + /* (non-Javadoc) + * @see com.sun.jersey.spi.container.ResourceFilterFactory#create(com.sun.jersey.api.model.AbstractMethod) + */ + @Override + public List create(AbstractMethod arg0) { + List filters = new ArrayList(); + filters.add(new AuditFilter()); + + return filters; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/listeners/ShutdownListener.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/listeners/ShutdownListener.java new file mode 100644 index 00000000..8c6bb42b --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/listeners/ShutdownListener.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.listeners; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.gluster.storage.management.gateway.utils.DBUtil; + + +/** + * Shuts down the Derby database when gateway is being stopped. + */ +public class ShutdownListener implements ServletContextListener { + + /* (non-Javadoc) + * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) + */ + @Override + public void contextDestroyed(ServletContextEvent arg0) { + // Embedded derby must be shut down when the gateway stops. + DBUtil.shutdownDerby(); + System.gc(); + } + + /* (non-Javadoc) + * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) + */ + @Override + public void contextInitialized(ServletContextEvent arg0) { + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java new file mode 100644 index 00000000..8e26c838 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/AbstractResource.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.resources.v1_0; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; + +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.StreamingOutput; +import javax.ws.rs.core.UriInfo; + +/** + * + */ +public class AbstractResource { + @Context + protected UriInfo uriInfo; + + /** + * Creates a response with HTTP status code of 201 (created) and sets the "location" header to the URI created using + * the given path relative to current path. + * + * @param relativePath + * relative path of the created resource - will be set in the "location" header of response. + * @return the {@link Response} object + */ + protected Response createdResponse(String relativePath) { + return Response.created(createRelatriveURI(relativePath)).build(); + } + + /** + * Creates a response with HTTP status code of 204 (no content) + * @return the {@link Response} object + */ + protected Response noContentResponse() { + return Response.noContent().build(); + } + + /** + * Creates a response with HTTP status code of 202 (accepted), also setting the location header to given location. + * This is typically done while triggering long running tasks + * + * @param locationURI + * URI to be appended to the base URI + * @return the {@link Response} object + */ + protected Response acceptedResponse(String locationURI) { + return Response.status(Status.ACCEPTED).location(createAbsoluteURI(locationURI)).build(); + } + + /** + * Creates a response with HTTP status code of 404 (not found), also setting the given message in the response body + * + * @param message + * Message to be set in the response body + * @return the {@link Response} object + */ + protected Response notFoundResponse(String message) { + return Response.status(Status.NOT_FOUND).type(MediaType.TEXT_HTML).entity(message).build(); + } + + /** + * Creates a new URI that is relative to the base URI of the application + * @param uriString URI String to be appended to the base URI + * @return newly created URI + */ + private URI createAbsoluteURI(String uriString) { + return uriInfo.getBaseUriBuilder().path(uriString).build(); + } + + /** + * Creates a response with HTTP status code of 204 (no content), also setting the location header to given location + * @param location path of the location to be set relative to current path + * @return the {@link Response} object + */ + protected Response noContentResponse(String location) { + return Response.noContent().location(createRelatriveURI(location)).build(); + } + + /** + * Creates a URI relative to current URI + * @param location path relative to current URI + * @return newly created URI + */ + protected URI createRelatriveURI(String location) { + return uriInfo.getAbsolutePathBuilder().path(location).build(); + } + + /** + * Creates a response with HTTP status code of 500 (internal server error) and sets the error message in the + * response body + * + * @param errMessage + * Error message to be set in the response body + * @return the {@link Response} object + */ + protected Response errorResponse(String errMessage) { + return Response.serverError().type(MediaType.TEXT_HTML).entity(errMessage).build(); + } + + /** + * Creates a response with HTTP status code of 400 (bad request) and sets the error message in the + * response body + * + * @param errMessage + * Error message to be set in the response body + * @return the {@link Response} object + */ + protected Response badRequestResponse(String errMessage) { + return Response.status(Status.BAD_REQUEST).type(MediaType.TEXT_HTML).entity(errMessage).build(); + } + + /** + * Creates a response with HTTP status code of 401 (unauthorized) + * + * @return the {@link Response} object + */ + protected Response unauthorizedResponse() { + return Response.status(Status.UNAUTHORIZED).build(); + } + + /** + * Creates an OK response and sets the entity in the response body. + * + * @param entity + * Entity to be set in the response body + * @param mediaType + * Media type to be set on the response + * @return the {@link Response} object + */ + protected Response okResponse(Object entity, String mediaType) { + return Response.ok(entity).type(mediaType).build(); + } + + /** + * Creates a streaming output response and sets the given streaming output in the response. Typically used for + * "download" requests + * + * @param entity + * Entity to be set in the response body + * @param mediaType + * Media type to be set on the response + * @return the {@link Response} object + */ + protected Response streamingOutputResponse(StreamingOutput output) { + return Response.ok(output).type(MediaType.APPLICATION_OCTET_STREAM).build(); + } + + protected StreamingOutput createStreamingOutput(final byte[] data) { + return new StreamingOutput() { + @Override + public void write(OutputStream output) throws IOException { + output.write(data); + } + }; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java new file mode 100644 index 00000000..3c9b3bd2 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/ClustersResource.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CLUSTER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.DELETE; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.response.ClusterNameListResponse; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.springframework.stereotype.Component; + +import com.sun.jersey.api.core.InjectParam; +import com.sun.jersey.spi.resource.Singleton; + +/** + * + */ +@Component +@Singleton +@Path(RESOURCE_PATH_CLUSTERS) +public class ClustersResource extends AbstractResource { + @InjectParam + private ClusterService clusterService; + private static final Logger logger = Logger.getLogger(ClustersResource.class); + + @GET + @Produces(MediaType.APPLICATION_XML) + public ClusterNameListResponse getClusters() { + List clusters = clusterService.getAllClusters(); + List clusterList = new ArrayList(); + for (ClusterInfo cluster : clusters) { + clusterList.add(cluster.getName()); + } + return new ClusterNameListResponse(clusterList); + } + + @POST + public Response createCluster(@FormParam(FORM_PARAM_CLUSTER_NAME) String clusterName) { + if(clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!"); + } + + if(clusterService.getCluster(clusterName) != null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] already exists!"); + } + + clusterService.createCluster(clusterName); + return createdResponse(clusterName); + } + + @PUT + public Response registerCluster(@FormParam(FORM_PARAM_CLUSTER_NAME) String clusterName, + @FormParam(FORM_PARAM_SERVER_NAME) String knownServer) { + if(clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!"); + } + + if(knownServer == null || knownServer.isEmpty()) { + throw new GlusterValidationException("Parameter [" + FORM_PARAM_SERVER_NAME + "] is missing in request!"); + } + + if(clusterService.getCluster(clusterName) != null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] already exists!"); + } + + ClusterInfo mappedCluster = clusterService.getClusterForServer(knownServer); + if(mappedCluster != null) { + throw new GlusterValidationException("Server [" + knownServer + "] is already present in cluster [" + + mappedCluster.getName() + "]!"); + } + + clusterService.registerCluster(clusterName, knownServer); + return noContentResponse(clusterName); + } + + @Path("{" + PATH_PARAM_CLUSTER_NAME + "}") + @DELETE + public Response unregisterCluster(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { + if(clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Parameter [" + FORM_PARAM_CLUSTER_NAME + "] is missing in request!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if(cluster == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] does not exist!"); + } + + clusterService.unregisterCluster(cluster); + return noContentResponse(); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java new file mode 100644 index 00000000..12358f56 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/DiscoveredServersResource.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_SERVER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_DISCOVERED_SERVERS; + +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.response.ServerListResponse; +import org.gluster.storage.management.core.response.ServerNameListResponse; +import org.gluster.storage.management.gateway.services.DiscoveredServerService; +import org.springframework.stereotype.Component; + +import com.sun.jersey.api.core.InjectParam; +import com.sun.jersey.spi.resource.Singleton; + +@Component +@Singleton +@Path(RESOURCE_PATH_DISCOVERED_SERVERS) +public class DiscoveredServersResource extends AbstractResource { + @InjectParam + private DiscoveredServerService discoveredServerService; + + @GET + @Produces(MediaType.APPLICATION_XML) + public Response getDiscoveredServersXML(@QueryParam(QUERY_PARAM_DETAILS) Boolean details) { + return getDiscoveredServersResponse(details, MediaType.APPLICATION_XML); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getDiscoveredServersJSON(@QueryParam(QUERY_PARAM_DETAILS) Boolean details) { + return getDiscoveredServersResponse(details, MediaType.APPLICATION_JSON); + } + + private Response getDiscoveredServersResponse(Boolean details, String mediaType) { + if(details != null && details == true) { + try { + List discoveredServers = discoveredServerService.getDiscoveredServerDetails(); + return okResponse(new ServerListResponse(discoveredServers), mediaType); + } catch(Exception e) { + return errorResponse(e.getMessage()); + } + } else { + return okResponse(new ServerNameListResponse(discoveredServerService.getDiscoveredServerNames()), mediaType); + } + } + + @Path("{" + PATH_PARAM_SERVER_NAME + "}") + @GET + @Produces(MediaType.APPLICATION_XML) + public Response getDiscoveredServerXML(@PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + return getDiscoveredServerResponse(serverName, MediaType.APPLICATION_XML); + } + + @Path("{" + PATH_PARAM_SERVER_NAME + "}") + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getDiscoveredServerJSON(@PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + return getDiscoveredServerResponse(serverName, MediaType.APPLICATION_JSON); + } + + private Response getDiscoveredServerResponse(String serverName, String mediaType) { + if(serverName == null || serverName.isEmpty()) { + return badRequestResponse("Server name must not be empty!"); + } + try { + return okResponse(discoveredServerService.getDiscoveredServer(serverName), mediaType); + } catch (Exception e) { + // TODO: Log the exception + return errorResponse(e.getMessage()); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java new file mode 100644 index 00000000..dfe4c85c --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GenericExceptionMapper.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.resources.v1_0; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.ResponseBuilder; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; + + +@Provider +public class GenericExceptionMapper implements ExceptionMapper { + private static final Logger logger = Logger.getLogger(GenericExceptionMapper.class); + + /* (non-Javadoc) + * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable) + */ + @Override + public Response toResponse(Exception exception) { + ResponseBuilder builder; + if (exception instanceof GlusterValidationException) { + builder = Response.status(Response.Status.BAD_REQUEST); + } else { + builder = Response.status(Response.Status.INTERNAL_SERVER_ERROR); + } + + String errMsg = exception.getMessage(); + if(errMsg == null) { + errMsg = "Following exception occurred : " + exception.getClass().getName(); + StackTraceElement[] stackTrace = exception.getStackTrace(); + if(stackTrace.length > 0) { + errMsg += " at [" + stackTrace[0].getClassName() + "][" + stackTrace[0].getLineNumber() + "]"; + } + } + + logger.error(errMsg, exception); + + return builder.entity(errMsg).type(MediaType.TEXT_PLAIN).build(); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java new file mode 100644 index 00000000..1b9a3b71 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java @@ -0,0 +1,343 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FSTYPE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_MOUNTPOINT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_DISK_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_SERVER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DETAILS; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_INTERFACE; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_MAX_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_NEXT_TO; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_PERIOD; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TYPE; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DISKS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_FSTYPES; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_SERVERS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_STATISTICS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS; +import static org.gluster.storage.management.core.constants.RESTConstants.STATISTICS_TYPE_CPU; +import static org.gluster.storage.management.core.constants.RESTConstants.STATISTICS_TYPE_MEMORY; +import static org.gluster.storage.management.core.constants.RESTConstants.STATISTICS_TYPE_NETWORK; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.DELETE; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.response.FsTypeListResponse; +import org.gluster.storage.management.core.response.GlusterServerListResponse; +import org.gluster.storage.management.core.response.ServerNameListResponse; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.gluster.storage.management.gateway.services.GlusterServerService; +import org.gluster.storage.management.gateway.tasks.InitializeDiskTask; +import org.gluster.storage.management.gateway.utils.CpuStatsFactory; +import org.gluster.storage.management.gateway.utils.MemoryStatsFactory; +import org.gluster.storage.management.gateway.utils.NetworkStatsFactory; +import org.gluster.storage.management.gateway.utils.StatsFactory; +import org.springframework.stereotype.Component; + +import com.sun.jersey.api.core.InjectParam; +import com.sun.jersey.spi.resource.Singleton; + +@Component +@Singleton +@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_SERVERS) +public class GlusterServersResource extends AbstractResource { + + public static final String HOSTNAMETAG = "hostname:"; + + @InjectParam + private TasksResource taskResource; + + @InjectParam + private ClusterService clusterService; + + @InjectParam + private CpuStatsFactory cpuStatsFactory; + + @InjectParam + private MemoryStatsFactory memoryStatsFactory; + + @InjectParam + private NetworkStatsFactory networkStatsFactory; + + @InjectParam + private GlusterServerService glusterServerService; + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getGlusterServersJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @QueryParam(QUERY_PARAM_DETAILS) Boolean details, @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, + @QueryParam(QUERY_PARAM_NEXT_TO) String previousServerName) { + return getGlusterServers(clusterName, MediaType.APPLICATION_JSON, details, maxCount, previousServerName); + } + + @GET + @Produces(MediaType.APPLICATION_XML) + public Response getGlusterServersXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @QueryParam(QUERY_PARAM_DETAILS) Boolean details, @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, + @QueryParam(QUERY_PARAM_NEXT_TO) String previousServerName) { + return getGlusterServers(clusterName, MediaType.APPLICATION_XML, details, maxCount, previousServerName); + } + + private Response getGlusterServers(String clusterName, String mediaType, Boolean fetchDetails, Integer maxCount, + String previousServerName) { + if(fetchDetails == null) { + // by default, fetch the server list + fetchDetails = false; + } + + List glusterServers = new ArrayList(); + + if (clusterName == null || clusterName.isEmpty()) { + return badRequestResponse("Cluster name must not be empty!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + return notFoundResponse("Cluster [" + clusterName + "] not found!"); + } + + if (cluster.getServers().size() == 0) { + return okResponse(new GlusterServerListResponse(glusterServers), mediaType); + } + + try { + glusterServers = glusterServerService.getGlusterServers(clusterName, fetchDetails, maxCount, previousServerName); + } catch (Exception e) { + return errorResponse(e.getMessage()); + } + + if(fetchDetails) { + return okResponse(new GlusterServerListResponse(glusterServers), mediaType); + } else { + // no details to be fetched. Return list of server names. + return okResponse(new ServerNameListResponse(getServerNames(glusterServers)), mediaType); + } + } + + private List getServerNames(List glusterServers) { + List serverNames = new ArrayList(); + for(GlusterServer server : glusterServers) { + serverNames.add(server.getName()); + } + return serverNames; + } + + @GET + @Path("{" + PATH_PARAM_SERVER_NAME + "}") + @Produces(MediaType.APPLICATION_XML) + public Response getGlusterServerXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + return getGlusterServerResponse(clusterName, serverName, MediaType.APPLICATION_XML); + } + + @GET + @Path("{" + PATH_PARAM_SERVER_NAME + "}") + @Produces(MediaType.APPLICATION_JSON) + public Response getGlusterServerJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + return getGlusterServerResponse(clusterName, serverName, MediaType.APPLICATION_JSON); + } + + private Response getGlusterServerResponse(String clusterName, String serverName, String mediaType) { + try { + return okResponse(glusterServerService.getGlusterServer(clusterName, serverName, true), mediaType); + } catch (Exception e) { + return errorResponse(e.getMessage()); + } + } + + @POST + public Response addServer(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @FormParam(FORM_PARAM_SERVER_NAME) String serverName) { + return createdResponse(glusterServerService.addServerToCluster(clusterName, serverName)); + } + + @DELETE + @Path("{" + PATH_PARAM_SERVER_NAME + "}") + public Response removeServer(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + glusterServerService.removeServerFromCluster(clusterName, serverName); + return noContentResponse(); + } + + @GET + @Produces(MediaType.APPLICATION_XML) + @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_FSTYPES) + public FsTypeListResponse getFsTypes(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName) { + List fsTypes = glusterServerService.getFsTypes(clusterName, serverName); + return new FsTypeListResponse(fsTypes); + } + + @PUT + @Produces(MediaType.APPLICATION_XML) + @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_DISKS + "/{" + PATH_PARAM_DISK_NAME + "}") + public Response initializeDisk(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_SERVER_NAME) String serverName, @PathParam(PATH_PARAM_DISK_NAME) String diskName, + @FormParam(FORM_PARAM_FSTYPE) String fsType, @FormParam(FORM_PARAM_MOUNTPOINT) String mountPoint) { + + if (clusterName == null || clusterName.isEmpty()) { + return badRequestResponse("Cluster name must not be empty!"); + } + + if (serverName == null || serverName.isEmpty()) { + return badRequestResponse("Server name must not be empty!"); + } + + if (diskName == null || diskName.isEmpty()) { + return badRequestResponse("Disk name must not be empty!"); + } + + if (fsType == null || fsType.isEmpty()) { + fsType = GlusterConstants.FSTYPE_DEFAULT; + // return badRequestResponse("Parameter [" + FORM_PARAM_FSTYPE + "] is missing in request!"); + } + + InitializeDiskTask initializeTask = new InitializeDiskTask(clusterService, clusterName, serverName, diskName, fsType, mountPoint); + try { + initializeTask.start(); + // Check the initialize disk status + TaskStatus taskStatus = initializeTask.checkStatus(); + initializeTask.getTaskInfo().setStatus(taskStatus); + taskResource.addTask(clusterName, initializeTask); + + return acceptedResponse(RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_TASKS + "/" + + initializeTask.getId()); + } catch (Exception e) { + return errorResponse(e.getMessage()); + } + } + + @GET + @Produces(MediaType.APPLICATION_XML) + @Path(RESOURCE_STATISTICS) + public Response getAggregatedPerformanceDataXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period) { + return getAggregaredPerformanceData(clusterName, type, period, MediaType.APPLICATION_XML); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path(RESOURCE_STATISTICS) + public Response getAggregaredPerformanceDataJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period) { + return getAggregaredPerformanceData(clusterName, type, period, MediaType.APPLICATION_JSON); + } + + @GET + @Produces(MediaType.APPLICATION_XML) + @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_STATISTICS) + public Response getPerformanceDataXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName, + @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period, + @QueryParam(QUERY_PARAM_INTERFACE) String networkInterface) { + return getPerformanceData(clusterName, serverName, type, period, networkInterface, MediaType.APPLICATION_XML); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("{" + PATH_PARAM_SERVER_NAME + "}/" + RESOURCE_STATISTICS) + public Response getPerformanceDataJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, @PathParam(PATH_PARAM_SERVER_NAME) String serverName, + @QueryParam(QUERY_PARAM_TYPE) String type, @QueryParam(QUERY_PARAM_PERIOD) String period, + @QueryParam(QUERY_PARAM_INTERFACE) String networkInterface) { + return getPerformanceData(clusterName, serverName, type, period, networkInterface, MediaType.APPLICATION_JSON); + } + + private Response getAggregaredPerformanceData(String clusterName, String type, String period, String mediaType) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (type == null || type.isEmpty()) { + throw new GlusterValidationException("Statistics type name must not be empty!"); + } + + if (period == null || period.isEmpty()) { + throw new GlusterValidationException("Statistics period name must not be empty! Valid values are 1d/1w/1m/1y"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + return notFoundResponse("Cluster [" + clusterName + "] not found!"); + } + + if (cluster.getServers().isEmpty()) { + // cluster is empty. return empty stats. + return okResponse(new ServerStats(), mediaType); + } + + List serverNames = getServerNames(glusterServerService.getGlusterServers(clusterName, false, null, null)); + return okResponse(getStatsFactory(type).fetchAggregatedStats(serverNames, period), mediaType); + } + + private Response getPerformanceData(String clusterName, String serverName, String type, String period, String networkInterface, String mediaType) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (serverName == null || serverName.isEmpty()) { + throw new GlusterValidationException("Server name must not be empty!"); + } + + if (type == null || type.isEmpty()) { + throw new GlusterValidationException("Statistics type name must not be empty!"); + } + + if (period == null || period.isEmpty()) { + throw new GlusterValidationException("Statistics period name must not be empty! Valid values are 1d/1w/1m/1y"); + } + + return okResponse(getStatsFactory(type).fetchStats(serverName, period, networkInterface), mediaType); + } + + private StatsFactory getStatsFactory(String type) { + if(type.equals(STATISTICS_TYPE_CPU)) { + return cpuStatsFactory; + } else if(type.equals(STATISTICS_TYPE_MEMORY)) { + return memoryStatsFactory; + } else if(type.equals(STATISTICS_TYPE_NETWORK)) { + return networkStatsFactory; + } else { + throw new GlusterValidationException("Invalid server statistics type [" + type + "]. Valid values are [" + + STATISTICS_TYPE_CPU + ", " + STATISTICS_TYPE_NETWORK + ", " + STATISTICS_TYPE_MEMORY + "]"); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/KeysResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/KeysResource.java new file mode 100644 index 00000000..3063c23e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/KeysResource.java @@ -0,0 +1,155 @@ +/** + * KeysResource.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_KEYS; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.utils.FileUtil; +import org.gluster.storage.management.core.utils.ProcessResult; +import org.gluster.storage.management.core.utils.ProcessUtil; +import org.gluster.storage.management.gateway.utils.SshUtil; + +import com.sun.jersey.multipart.FormDataParam; + +@Path(RESOURCE_PATH_KEYS) +public class KeysResource extends AbstractResource { + private static final Logger logger = Logger.getLogger(KeysResource.class); + private ProcessUtil processUtil = new ProcessUtil(); + + @GET + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportSshkeys() { + File archiveFile = new File(createSskKeyZipFile()); + byte[] data = FileUtil.readFileAsByteArray(archiveFile); + archiveFile.delete(); + return streamingOutputResponse(createStreamingOutput(data)); + } + + private String createSskKeyZipFile() { + String targetDir = FileUtil.getTempDirName(); + String zipFile = targetDir + File.separator + "ssh-keys.tar"; + String sourcePrivateKeyFile = SshUtil.PRIVATE_KEY_FILE.getAbsolutePath(); + String sourcePublicKeyFile = SshUtil.PUBLIC_KEY_FILE.getAbsolutePath(); + String targetPrivateKeyFile = targetDir + File.separator + SshUtil.PRIVATE_KEY_FILE.getName(); + String targetPubKeyFile = targetDir + File.separator + SshUtil.PUBLIC_KEY_FILE.getName(); + + if (!SshUtil.PRIVATE_KEY_FILE.isFile()) { + throw new GlusterRuntimeException("No private key file [" + SshUtil.PRIVATE_KEY_FILE.getName() + "] found!"); + } + + if (!SshUtil.PUBLIC_KEY_FILE.isFile()) { + throw new GlusterRuntimeException("No public key file [" + SshUtil.PUBLIC_KEY_FILE.getName() + "] found!"); + } + + // Copy keys to temp folder + ProcessResult result = processUtil.executeCommand("cp", sourcePrivateKeyFile, targetPrivateKeyFile); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]"); + } + result = processUtil.executeCommand("cp", sourcePublicKeyFile, targetPubKeyFile); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Failed to copy key files! [" + result.getOutput() + "]"); + } + + // To compress the key files + result = processUtil.executeCommand("tar", "cvf", zipFile, "-C", targetDir, SshUtil.PRIVATE_KEY_FILE.getName(), + SshUtil.PUBLIC_KEY_FILE.getName()); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Failed to compress key files! [" + result.getOutput() + "]"); + } + + // To remove the copied key files + try { + processUtil.executeCommand("rm", "-f", targetPrivateKeyFile, targetPubKeyFile); // Ignore the errors if any + } catch (Exception e) { + logger.warn(e.toString()); + } + return zipFile; + } + + @POST + @Consumes(MediaType.MULTIPART_FORM_DATA) + public Response importSshKeys(@FormDataParam("file") InputStream uploadedInputStream) { + File uploadedFile = new File(System.getProperty("java.io.tmpdir") + File.separator + "keys.tar"); + String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); + + writeToFile(uploadedInputStream, uploadedFile.getAbsolutePath()); + + // To backup existing SSH private and public keys, if exist. + if (SshUtil.PRIVATE_KEY_FILE.isFile()) { + if (!SshUtil.PRIVATE_KEY_FILE.renameTo(new File(SshUtil.PRIVATE_KEY_FILE.getAbsolutePath() + "-" + timestamp))) { + throw new GlusterRuntimeException("Unable to backup private key!"); + } + } + + if (SshUtil.PUBLIC_KEY_FILE.isFile()) { + if (!SshUtil.PUBLIC_KEY_FILE + .renameTo(new File(SshUtil.PUBLIC_KEY_FILE.getAbsolutePath() + "-" + timestamp))) { + throw new GlusterRuntimeException("Unable to backup public key!"); + } + } + // Extract SSH private and public key files. + ProcessResult output = processUtil.executeCommand("tar", "xvf", uploadedFile.getAbsolutePath(), "-C", + SshUtil.SSH_AUTHORIZED_KEYS_DIR_LOCAL); + uploadedFile.delete(); + if (!output.isSuccess()) { + String errMsg = "Error in importing SSH keys: [" + output.toString() + "]"; + logger.error(errMsg); + throw new GlusterRuntimeException(errMsg); + } + return createdResponse("SSH Key imported successfully"); + } + + // save uploaded file to the file (with path) + private void writeToFile(InputStream inputStream, String toFile) { + try { + int read = 0; + byte[] bytes = new byte[1024]; + + OutputStream out = new FileOutputStream(new File(toFile)); + while ((read = inputStream.read(bytes)) != -1) { + out.write(bytes, 0, read); + } + out.flush(); + out.close(); + } catch (IOException e) { + throw new GlusterRuntimeException(e.getMessage()); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/TasksResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/TasksResource.java new file mode 100644 index 00000000..b57232fe --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/TasksResource.java @@ -0,0 +1,226 @@ +/** + * TaskResource.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OPERATION; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_TASK_ID; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.DELETE; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.response.TaskInfoListResponse; +import org.gluster.storage.management.gateway.tasks.Task; +import org.springframework.stereotype.Component; + +import com.sun.jersey.spi.resource.Singleton; + +@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_TASKS) +@Singleton +@Component + +public class TasksResource extends AbstractResource { + private Map> tasksMap = new HashMap>(); + + public TasksResource() { + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public void addTask(String clusterName, Task task) { + Map clusterTaskMap = tasksMap.get(clusterName); + if(clusterTaskMap == null) { + clusterTaskMap = new HashMap(); + tasksMap.put(clusterName, clusterTaskMap); + } + // Remove the task if already exist + if (clusterTaskMap.containsKey(task.getId())) { + removeTask(clusterName, task); + } + clusterTaskMap.put(task.getId(), task); + } + + @SuppressWarnings("rawtypes") + public void removeTask(String clusterName, Task task) { + Map clusterTaskMap = tasksMap.get(clusterName); + if (clusterTaskMap != null) { + clusterTaskMap.remove(task.getId()); + } + } + + public List getAllTasksInfo(String clusterName) { + Map clusterTasksMap = tasksMap.get(clusterName); + List allTasksInfo = new ArrayList(); + if ( clusterTasksMap == null) { + return allTasksInfo; + } + for (Map.Entry entry : clusterTasksMap.entrySet()) { + checkTaskStatus(clusterName, entry.getKey()); + allTasksInfo.add(entry.getValue().getTaskInfo()); // TaskInfo with latest status + } + return allTasksInfo; + } + + public Task getTask(String clusterName, String taskId) { + Map clusterTasksMap = tasksMap.get(clusterName); + for (Map.Entry entry : clusterTasksMap.entrySet()) { + if (entry.getValue().getId().equals(taskId)) { + return entry.getValue(); + } + } + return null; + } + + public List getAllTasks(String clusterName) { + Map clusterTasksMap = tasksMap.get(clusterName); + List tasks = new ArrayList(); + for (Map.Entry entry : clusterTasksMap.entrySet()) { + checkTaskStatus(clusterName, entry.getKey()); + tasks.add( (Task) entry.getValue()); + } + return tasks; + } + + @GET + @Produces(MediaType.APPLICATION_XML) + public Response getTasks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { + try { + return okResponse(new TaskInfoListResponse(getAllTasksInfo(clusterName)), MediaType.APPLICATION_XML); + } catch (GlusterRuntimeException e) { + return errorResponse(e.getMessage()); + } + } + + @GET + @Path("/{" + PATH_PARAM_TASK_ID + "}") + @Produces(MediaType.APPLICATION_XML) + public Response getTaskStatus(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_TASK_ID) String taskId) { + try { + Task task = checkTaskStatus(clusterName, taskId); + return okResponse(task.getTaskInfo(), MediaType.APPLICATION_XML); + } catch (GlusterRuntimeException e) { + return errorResponse(e.getMessage()); + } + } + + private Task checkTaskStatus(String clusterName, String taskId) { + Task task = getTask(clusterName, taskId); + // No status check required if the task already complete or failure + if (task.getTaskInfo().getStatus().getCode() == Status.STATUS_CODE_FAILURE + || task.getTaskInfo().getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { + return task; + } + task.getTaskInfo().setStatus(task.checkStatus()); + return task; + } + + @PUT + @Path("/{" + PATH_PARAM_TASK_ID + "}") + @Produces(MediaType.APPLICATION_XML) + public Response performTask(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_TASK_ID) String taskId, @FormParam(FORM_PARAM_OPERATION) String taskOperation) { + Task task = getTask(clusterName, taskId); + + try { + if (taskOperation.equals(RESTConstants.TASK_RESUME)) { + task.resume(); + } else if (taskOperation.equals(RESTConstants.TASK_PAUSE)) { + task.pause(); + } else if (taskOperation.equals(RESTConstants.TASK_STOP)) { + // task.stop(); + clearTask(clusterName, taskId, taskOperation); // Stop and remove from the task list + } else if (taskOperation.equals(RESTConstants.TASK_COMMIT)) { + task.commit(); + } + return (Response) noContentResponse(); + } catch(GlusterValidationException ve) { + return badRequestResponse(ve.getMessage()); + } catch (GlusterRuntimeException e) { + return errorResponse(e.getMessage()); + } + } + + @DELETE + @Path("/{" + PATH_PARAM_TASK_ID + "}") + @Produces(MediaType.APPLICATION_XML) + public Response clearTask(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_TASK_ID) String taskId, @QueryParam(FORM_PARAM_OPERATION) String taskOperation) { + Task task = getTask(clusterName, taskId); + if (task == null) { + return notFoundResponse("Requested task not found!"); + } + + if(clusterName == null || clusterName.isEmpty()) { + return badRequestResponse("Parameter [" + PATH_PARAM_CLUSTER_NAME + "] is missing in request!"); + } + + if(taskOperation == null || taskOperation.isEmpty()) { + int taskStatus = task.getTaskInfo().getStatus().getCode(); + if (taskStatus == Status.STATUS_CODE_SUCCESS || taskStatus == Status.STATUS_CODE_FAILURE) { + taskOperation = RESTConstants.TASK_DELETE; + } else { + taskOperation = RESTConstants.TASK_STOP; + } +// return badRequestResponse("Parameter [" + FORM_PARAM_OPERATION + "] is missing in request!"); + } + + if(!taskOperation.equals(RESTConstants.TASK_STOP) && !taskOperation.equals(RESTConstants.TASK_DELETE)) { + return badRequestResponse("Invalid value [" + taskOperation + "] for parameter [" + FORM_PARAM_OPERATION + + "]"); + } + + try { + if (taskOperation.equals(RESTConstants.TASK_STOP)) { + task.stop(); + // On successful, intentionally stopped task can be removed from task list also + taskOperation = RESTConstants.TASK_DELETE; + } + + if (taskOperation.equals(RESTConstants.TASK_DELETE)) { + removeTask(clusterName, task); + } + + return noContentResponse(); + } catch (Exception e) { + return errorResponse(e.getMessage()); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/UsersResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/UsersResource.java new file mode 100644 index 00000000..6594ed0f --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/UsersResource.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_NEW_PASSWORD; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OLD_PASSWORD; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_USER; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_USERS; + +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.model.Status; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.dao.SaltSource; +import org.springframework.security.authentication.encoding.PasswordEncoder; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.provisioning.JdbcUserDetailsManager; +import org.springframework.stereotype.Component; + +import com.sun.jersey.spi.resource.Singleton; + +@Singleton +@Component +@Path(RESOURCE_PATH_USERS) +public class UsersResource extends AbstractResource { + @Autowired + private JdbcUserDetailsManager jdbcUserService; + + @Autowired + private PasswordEncoder passwordEncoder; + + @Autowired + private SaltSource saltSource; + + @Autowired + private UserDetailsService userDetailsService; + + private static final Logger logger = Logger.getLogger(UsersResource.class); + + @Path("{" + PATH_PARAM_USER + "}") + @GET + @Produces(MediaType.APPLICATION_XML) + public Response authenticateXML(@PathParam("user") String user) { + // success only if the user passed in query is same as the one passed in security header + // spring security would have already authenticated the user credentials + return getAuthenticationResponse(user, MediaType.APPLICATION_XML); + } + + @Path("{" + PATH_PARAM_USER + "}") + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response authenticateJSON(@PathParam("user") String user) { + // success only if the user passed in query is same as the one passed in security header + // spring security would have already authenticated the user credentials + return getAuthenticationResponse(user, MediaType.APPLICATION_JSON); + } + + public Response getAuthenticationResponse(String user, String mediaType) { + return (SecurityContextHolder.getContext().getAuthentication().getName().equals(user) ? okResponse( + Status.STATUS_SUCCESS, mediaType) : unauthorizedResponse()); + } + + @Path("{" + PATH_PARAM_USER + "}") + @PUT + public Response changePassword(@PathParam(PATH_PARAM_USER) String username, + @FormParam(FORM_PARAM_OLD_PASSWORD) String oldPassword, + @FormParam(FORM_PARAM_NEW_PASSWORD) String newPassword) { + try { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + String loggedInUser = ((UserDetails)auth.getPrincipal()).getUsername(); + if(!loggedInUser.equals(username)) { + // Temporary check as we currently have only one user. + throw new GlusterValidationException("User [" + loggedInUser + + "] is not allowed to change password of user [" + username + "]!"); + } + + UserDetails user = userDetailsService.loadUserByUsername(username); + Object salt = saltSource.getSalt(user); + + String actualOldPasswordEncoded = ((UserDetails)auth.getPrincipal()).getPassword(); + String oldPasswordEncoded = passwordEncoder.encodePassword(oldPassword, salt); + if(!oldPasswordEncoded.equals(actualOldPasswordEncoded)) { + throw new GlusterValidationException("Invalid old password!"); + } + + String encodedNewPassword = passwordEncoder.encodePassword(newPassword, salt); + jdbcUserService.changePassword(oldPassword, encodedNewPassword); + } catch (Exception ex) { + String errMsg = "Could not change password. Error: [" + ex.getMessage() + "]"; + logger.error(errMsg, ex); + throw new GlusterRuntimeException(errMsg); + } + return noContentResponse(); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java new file mode 100644 index 00000000..18ed0314 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java @@ -0,0 +1,383 @@ +/** + * VolumesResource.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.resources.v1_0; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_ACCESS_PROTOCOLS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_AUTO_COMMIT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_ENABLE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_CIFS_USERS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FIX_LAYOUT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FORCE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FORCED_DATA_MIGRATE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_MIGRATE_DATA; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OPERATION; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_REPLICA_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SOURCE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_STRIPE_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TARGET; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TRANSPORT_TYPE; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_OPTIONS; +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_TYPE; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_VOLUME_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICKS; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICK_NAME; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DELETE_OPTION; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_DOWNLOAD; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_FROM_TIMESTAMP; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_LINE_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_LOG_SEVERITY; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_MAX_COUNT; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_NEXT_TO; +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TO_TIMESTAMP; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_BRICKS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DEFAULT_OPTIONS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DOWNLOAD; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_LOGS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_OPTIONS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_PATH_CLUSTERS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_TASKS; +import static org.gluster.storage.management.core.constants.RESTConstants.RESOURCE_VOLUMES; + +import java.io.File; +import java.util.Arrays; +import java.util.List; + +import javax.ws.rs.DELETE; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.RESTConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeLogMessage; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.response.LogMessageListResponse; +import org.gluster.storage.management.core.response.VolumeListResponse; +import org.gluster.storage.management.core.response.VolumeOptionInfoListResponse; +import org.gluster.storage.management.core.utils.FileUtil; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.gluster.storage.management.gateway.services.VolumeService; + +import com.sun.jersey.api.core.InjectParam; +import com.sun.jersey.spi.resource.Singleton; + +@Singleton +@Path(RESOURCE_PATH_CLUSTERS + "/{" + PATH_PARAM_CLUSTER_NAME + "}/" + RESOURCE_VOLUMES) +public class VolumesResource extends AbstractResource { + private static final Logger logger = Logger.getLogger(VolumesResource.class); + + @InjectParam + private ClusterService clusterService; + + @InjectParam + private VolumeService volumeService; + + @GET + @Produces({ MediaType.APPLICATION_XML }) + public Response getVolumesXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, + @QueryParam(QUERY_PARAM_NEXT_TO) String previousVolumeName) { + return okResponse(new VolumeListResponse(volumeService.getVolumes(clusterName, maxCount, previousVolumeName)), + MediaType.APPLICATION_XML); + } + + @GET + @Produces({ MediaType.APPLICATION_JSON }) + public Response getVolumesJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @QueryParam(QUERY_PARAM_MAX_COUNT) Integer maxCount, + @QueryParam(QUERY_PARAM_NEXT_TO) String previousVolumeName) { + return okResponse(new VolumeListResponse(volumeService.getVolumes(clusterName, maxCount, previousVolumeName)), + MediaType.APPLICATION_JSON); + } + + @POST + @Produces(MediaType.APPLICATION_XML) + public Response createVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @FormParam(FORM_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_VOLUME_TYPE) String volumeType, + @FormParam(FORM_PARAM_TRANSPORT_TYPE) String transportType, + @FormParam(FORM_PARAM_REPLICA_COUNT) Integer replicaCount, + @FormParam(FORM_PARAM_STRIPE_COUNT) Integer stripeCount, @FormParam(FORM_PARAM_BRICKS) String bricks, + @FormParam(FORM_PARAM_ACCESS_PROTOCOLS) String accessProtocols, + @FormParam(FORM_PARAM_VOLUME_OPTIONS) String options, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers) { + int count = 0; + if (clusterName == null || clusterName.isEmpty()) { + return badRequestResponse("Cluster name must not be empty!"); + } + + String missingParam = checkMissingParamsForCreateVolume(volumeName, volumeType, transportType, bricks, + accessProtocols, options); + if (missingParam != null) { + throw new GlusterValidationException("Parameter [" + missingParam + "] is missing in request!"); + } + + // For missing parameter, let default value + if (volumeType.equals(VOLUME_TYPE.REPLICATE.toString()) + || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE.toString())) { + count = (replicaCount == null) ? Volume.DEFAULT_REPLICA_COUNT : replicaCount; + } else if (volumeType.equals(VOLUME_TYPE.STRIPE.toString()) + || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE.toString())) { + count = (stripeCount == null) ? Volume.DEFAULT_STRIPE_COUNT : stripeCount; + } + + volumeService.createVolume(clusterName, volumeName, volumeType, transportType, count, bricks, accessProtocols, + options, cifsUsers); + return createdResponse(volumeName); + } + + /** + * Returns name of the missing parameter if any. If all parameters are present, + */ + private String checkMissingParamsForCreateVolume(String volumeName, String volumeType, + String transportType, String bricks, String accessProtocols, + String options) { + + return (volumeName == null || volumeName.isEmpty()) ? FORM_PARAM_VOLUME_NAME : + (volumeType == null || volumeType.isEmpty()) ? FORM_PARAM_VOLUME_TYPE : + (transportType == null || transportType.isEmpty()) ? FORM_PARAM_TRANSPORT_TYPE : + (bricks == null || bricks.isEmpty()) ? FORM_PARAM_BRICKS : + (accessProtocols == null || accessProtocols.isEmpty()) ? FORM_PARAM_ACCESS_PROTOCOLS : + (options == null || options.isEmpty()) ? FORM_PARAM_VOLUME_OPTIONS : + null; + } + + @GET + @Path("{" + PATH_PARAM_VOLUME_NAME + "}") + @Produces(MediaType.APPLICATION_XML) + public Response getVolumeXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { + return okResponse(volumeService.getVolume(clusterName, volumeName), MediaType.APPLICATION_XML); + } + + @GET + @Path("{" + PATH_PARAM_VOLUME_NAME + "}") + @Produces(MediaType.APPLICATION_JSON) + public Response getVolumeJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { + return okResponse(volumeService.getVolume(clusterName, volumeName), MediaType.APPLICATION_JSON); + } + + @PUT + @Path("{" + PATH_PARAM_VOLUME_NAME + "}") + public Response performOperation(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_OPERATION) String operation, + @FormParam(FORM_PARAM_FIX_LAYOUT) Boolean isFixLayout, + @FormParam(FORM_PARAM_MIGRATE_DATA) Boolean isMigrateData, + @FormParam(FORM_PARAM_FORCED_DATA_MIGRATE) Boolean isForcedDataMigrate, + @FormParam(FORM_PARAM_CIFS_ENABLE) Boolean enableCifs, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers, + @FormParam(FORM_PARAM_BRICKS) String bricks, @FormParam(FORM_PARAM_FORCE) Boolean force) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + try { + if (operation.equals(RESTConstants.TASK_REBALANCE_START)) { + String taskId = volumeService.rebalanceStart(clusterName, volumeName, isFixLayout, isMigrateData, isForcedDataMigrate); + return acceptedResponse(RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_TASKS + + "/" + taskId); + } else if (operation.equals(RESTConstants.TASK_REBALANCE_STOP)) { + volumeService.rebalanceStop(clusterName, volumeName); + } else if (operation.equals(RESTConstants.FORM_PARAM_CIFS_CONFIG)) { + Volume newVolume = volumeService.getVolume(clusterName, volumeName); + if (enableCifs) { + // After add/modify volume cifs users, start/restart the cifs service + volumeService.createCIFSUsers(clusterName, volumeName, cifsUsers); + if (newVolume.getStatus() == VOLUME_STATUS.ONLINE) { + volumeService.startCifsReExport(clusterName, volumeName); + } + } else { + // Stop the Cifs service and delete the users (!important) + if (newVolume.getStatus() == VOLUME_STATUS.ONLINE) { + volumeService.stopCifsReExport(clusterName, volumeName); + } + volumeService.deleteCifsUsers(clusterName, volumeName); + } + } else if (operation.equals(RESTConstants.TASK_LOG_ROTATE)) { + List brickList = Arrays.asList(bricks.split(",")); + volumeService.logRotate(clusterName, volumeName, brickList); + } else { + if (force == null) { + force = false; + } + volumeService.performVolumeOperation(clusterName, volumeName, operation, force); + } + return noContentResponse(); + } catch(Exception e) { + return errorResponse(e.getMessage()); + } + } + + @DELETE + @Path("{" + PATH_PARAM_VOLUME_NAME + "}") + public Response deleteVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, + @QueryParam(QUERY_PARAM_DELETE_OPTION) Boolean deleteFlag) { + volumeService.deleteVolume(clusterName, volumeName, deleteFlag); + + return noContentResponse(); + } + + @DELETE + @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS) + public Response removeBricks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICKS) String bricks, + @QueryParam(QUERY_PARAM_DELETE_OPTION) Boolean deleteFlag) { + volumeService.removeBricksFromVolume(clusterName, volumeName, bricks, deleteFlag); + return noContentResponse(); + } + + @POST + @Path("{" + PATH_PARAM_VOLUME_NAME + " }/" + RESOURCE_OPTIONS) + public Response setOption(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, + @FormParam(RESTConstants.FORM_PARAM_OPTION_KEY) String key, + @FormParam(RESTConstants.FORM_PARAM_OPTION_VALUE) String value) { + volumeService.setVolumeOption(clusterName, volumeName, key, value); + + return createdResponse(key); + } + + @PUT + @Path("{" + PATH_PARAM_VOLUME_NAME + " }/" + RESOURCE_OPTIONS) + public Response resetOptions(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) { + volumeService.resetVolumeOptions(clusterName, volumeName); + return noContentResponse(); + } + + @GET + @Path(RESOURCE_DEFAULT_OPTIONS) + @Produces(MediaType.APPLICATION_XML) + public VolumeOptionInfoListResponse getOptionsInfoXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { + return volumeService.getVolumeOptionsInfo(clusterName); + } + + @GET + @Path(RESOURCE_DEFAULT_OPTIONS) + @Produces(MediaType.APPLICATION_JSON) + public VolumeOptionInfoListResponse getOptionsInfoJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) { + return volumeService.getVolumeOptionsInfo(clusterName); + } + + @GET + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS + "/" + RESOURCE_DOWNLOAD) + public Response downloadLogs(@PathParam(PATH_PARAM_CLUSTER_NAME) final String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) final String volumeName) { + if (clusterName == null || clusterName.isEmpty()) { + return badRequestResponse("Cluster name must not be empty!"); + } + + if (volumeName == null || volumeName.isEmpty()) { + return badRequestResponse("Volume name must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + return notFoundResponse("Cluster [" + clusterName + "] not found!"); + } + + try { + final Volume volume = volumeService.getVolume(clusterName, volumeName); + File archiveFile = new File(volumeService.downloadLogs(volume)); + byte[] data = FileUtil.readFileAsByteArray(archiveFile); + archiveFile.delete(); + return streamingOutputResponse(createStreamingOutput(data)); + } catch (Exception e) { + logger.error("Volume [" + volumeName + "] doesn't exist in cluster [" + clusterName + "]! [" + + e.getStackTrace() + "]"); + throw (GlusterRuntimeException) e; + } + } + + @GET + @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS) + @Produces(MediaType.APPLICATION_XML) + public Response getLogsXML(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICK_NAME) String brickName, + @QueryParam(QUERY_PARAM_LOG_SEVERITY) String severity, + @QueryParam(QUERY_PARAM_FROM_TIMESTAMP) String fromTimestamp, + @QueryParam(QUERY_PARAM_TO_TIMESTAMP) String toTimestamp, + @QueryParam(QUERY_PARAM_LINE_COUNT) Integer lineCount, @QueryParam(QUERY_PARAM_DOWNLOAD) Boolean download) { + return getLogs(clusterName, volumeName, brickName, severity, fromTimestamp, toTimestamp, lineCount, MediaType.APPLICATION_XML); + } + + @GET + @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_LOGS) + @Produces(MediaType.APPLICATION_JSON) + public Response getLogsJSON(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICK_NAME) String brickName, + @QueryParam(QUERY_PARAM_LOG_SEVERITY) String severity, + @QueryParam(QUERY_PARAM_FROM_TIMESTAMP) String fromTimestamp, + @QueryParam(QUERY_PARAM_TO_TIMESTAMP) String toTimestamp, + @QueryParam(QUERY_PARAM_LINE_COUNT) Integer lineCount, @QueryParam(QUERY_PARAM_DOWNLOAD) Boolean download) { + return getLogs(clusterName, volumeName, brickName, severity, fromTimestamp, toTimestamp, lineCount, MediaType.APPLICATION_JSON); + } + + private Response getLogs(String clusterName, String volumeName, String brickName, String severity, + String fromTimestamp, String toTimestamp, Integer lineCount, String mediaType) { + List logMessages = volumeService.getLogs(clusterName, volumeName, brickName, severity, + fromTimestamp, toTimestamp, lineCount); + + return okResponse(new LogMessageListResponse(logMessages), mediaType); + } + + @POST + @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS) + public Response addBricks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_BRICKS) String bricks) { + volumeService.addBricksToVolume(clusterName, volumeName, bricks); + + return createdResponse(volumeName + "/" + RESOURCE_BRICKS); + } + + @PUT + @Path("{" + PATH_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS) + public Response migrateBrick(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName, + @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_SOURCE) String fromBrick, + @FormParam(FORM_PARAM_TARGET) String toBrick, @FormParam(FORM_PARAM_AUTO_COMMIT) Boolean autoCommit) { + + String taskId = volumeService.migrateBrickStart(clusterName, volumeName, fromBrick, toBrick, autoCommit); + + return acceptedResponse(RESTConstants.RESOURCE_PATH_CLUSTERS + "/" + clusterName + "/" + RESOURCE_TASKS + "/" + + taskId); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/GlusterUserDetailsService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/GlusterUserDetailsService.java new file mode 100644 index 00000000..a73f2d61 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/GlusterUserDetailsService.java @@ -0,0 +1,31 @@ +/** + * GlusterUserDetailsService.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.security; + +import org.springframework.security.core.userdetails.UserDetailsService; + +/** + * + */ +public interface GlusterUserDetailsService extends UserDetailsService { + void changePassword(String username, String password); +} + diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/UserAuthDao.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/UserAuthDao.java new file mode 100644 index 00000000..b0473f0c --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/security/UserAuthDao.java @@ -0,0 +1,57 @@ +/** + * UserAuthDao.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.security; + +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.DefaultTransactionDefinition; + + +/** + * + */ +public class UserAuthDao extends JdbcDaoImpl implements GlusterUserDetailsService { + + /* + * (non-Javadoc) + * + * @see org.gluster.storage.management.gateway.security.GlusterUserDetailsService#changePassword(java.lang.String, + * java.lang.String) + */ + @Override + public void changePassword(String username, String password) { + DataSourceTransactionManager txnManager = new DataSourceTransactionManager(); + txnManager.setDataSource(getDataSource()); + + TransactionDefinition def = new DefaultTransactionDefinition(); + TransactionStatus status = txnManager.getTransaction(def); + try { + getJdbcTemplate().update("UPDATE USERS SET PASSWORD = ? WHERE USERNAME = ?", password, username); + txnManager.commit(status); + } catch(Exception e) { + txnManager.rollback(status); + throw new GlusterRuntimeException("Exception while changing password of user [" + username + "]. Error: " + e.getMessage()); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/AbstractGlusterInterface.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/AbstractGlusterInterface.java new file mode 100644 index 00000000..99935749 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/AbstractGlusterInterface.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.services; + +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.beans.factory.annotation.Autowired; + + +/** + * Abstract Gluster Interface - provides functionality common across all versions of GlusterFS e.g. version check. + */ +public abstract class AbstractGlusterInterface implements GlusterInterface { + + @Autowired + protected ServerUtil serverUtil; + + @Override + public String getVersion(String serverName) { + return serverUtil.executeOnServer(serverName, "gluster --version").split("\n")[0].replaceAll("glusterfs ", "") + .replaceAll(" built.*", ""); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/ClusterService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/ClusterService.java new file mode 100644 index 00000000..e7a5af3d --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/ClusterService.java @@ -0,0 +1,269 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.services; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.EntityTransaction; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.utils.LRUCache; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.data.PersistenceDao; +import org.gluster.storage.management.gateway.data.ServerInfo; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.gluster.storage.management.gateway.utils.SshUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * Service class for functionality related to clusters + */ +@Component +public class ClusterService { + @Autowired + private PersistenceDao clusterDao; + + @Autowired + private PersistenceDao serverDao; + + @Autowired + private GlusterServerService glusterServerService; + + @Autowired + private SshUtil sshUtil; + + @Autowired + private ServerUtil serverUtil; + + private LRUCache onlineServerCache = new LRUCache(3); + + private static final Logger logger = Logger.getLogger(ClusterService.class); + + public void addOnlineServer(String clusterName, GlusterServer server) { + onlineServerCache.put(clusterName, server); + } + + public void removeOnlineServer(String clusterName) { + onlineServerCache.remove(clusterName); + } + + // uses cache + public GlusterServer getOnlineServer(String clusterName, String exceptServerName) { + GlusterServer server = onlineServerCache.get(clusterName); + if (server != null && !server.getName().equalsIgnoreCase(exceptServerName)) { + return server; + } + + return getNewOnlineServer(clusterName, exceptServerName); + } + + public GlusterServer getNewOnlineServer(String clusterName) { + return getNewOnlineServer(clusterName, ""); + } + + public GlusterServer getOnlineServer(String clusterName) { + return getOnlineServer(clusterName, ""); + } + + // Doesn't use cache + public GlusterServer getNewOnlineServer(String clusterName, String exceptServerName) { + ClusterInfo cluster = getCluster(clusterName); + if (cluster == null) { + throw new GlusterRuntimeException("Cluster [" + clusterName + "] is not found!"); + } + + for (ServerInfo serverInfo : cluster.getServers()) { + GlusterServer server = new GlusterServer(serverInfo.getName()); + try { + serverUtil.fetchServerDetails(server); // Online status come with server details + // server is online. add it to cache and return + if (server.isOnline() && !server.getName().equalsIgnoreCase(exceptServerName)) { + addOnlineServer(clusterName, server); + return server; + } + } catch (ConnectionException e) { + // server is offline. continue checking next one. + continue; + } + } + + // no online server found. + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + + public List getAllClusters() { + return clusterDao.findAll(); + } + + public ClusterInfo getCluster(String clusterName) { + List clusters = clusterDao.findBy("UPPER(name) = ?1", clusterName.toUpperCase()); + if(clusters.size() == 0) { + return null; + } + + return clusters.get(0); + } + + public ClusterInfo getClusterForServer(String serverName) { + List servers = serverDao.findBy("UPPER(name) = ?1", serverName.toUpperCase()); + if(servers.size() == 0) { + return null; + } + + return servers.get(0).getCluster(); + } + + public void createCluster(String clusterName) { + EntityTransaction txn = clusterDao.startTransaction(); + ClusterInfo cluster = new ClusterInfo(); + cluster.setName(clusterName); + + try { + clusterDao.save(cluster); + txn.commit(); + } catch (RuntimeException e) { + txn.rollback(); + logger.error("Exception while trying to save cluster [" + clusterName + "] : [" + e.getMessage() + "]", e); + throw e; + } + } + + public void registerCluster(String clusterName, String knownServer) { + EntityTransaction txn = clusterDao.startTransaction(); + ClusterInfo cluster = new ClusterInfo(); + cluster.setName(clusterName); + + GlusterServer server = new GlusterServer(knownServer); + try { + List glusterServers = glusterServerService.getGlusterServers(server.getName()); + List servers = new ArrayList(); + for(GlusterServer glusterServer : glusterServers) { + String serverName = glusterServer.getName(); + + serverUtil.fetchServerDetails(glusterServer); + if(glusterServer.isOnline()) { + checkAndSetupPublicKey(serverName); + } + + ServerInfo serverInfo = new ServerInfo(serverName); + serverInfo.setCluster(cluster); + clusterDao.save(serverInfo); + servers.add(serverInfo); + } + cluster.setServers(servers); + clusterDao.save(cluster); + txn.commit(); + } catch(RuntimeException e) { + logger.error("Error in registering cluster [" + clusterName + "] : " + e.getMessage(), e); + txn.rollback(); + logger.error("Error in registering cluster [" + clusterName + "] : " + e.getMessage(), e); + throw e; + } + } + + private void checkAndSetupPublicKey(String serverName) { + if(sshUtil.isPublicKeyInstalled(serverName)) { + return; + } + + if(!sshUtil.hasDefaultPassword(serverName)) { + // public key not installed, default password doesn't work. can't install public key + throw new GlusterRuntimeException( + "Gluster Management Gateway uses the default password to set up keys on the server." + + CoreConstants.NEWLINE + "However it seems that the password on server [" + serverName + + "] has been changed manually." + CoreConstants.NEWLINE + + "Please reset it back to the standard default password and try again."); + } + + // install public key (this will also disable password based ssh login) + sshUtil.installPublicKey(serverName); + } + + public void unregisterCluster(String clusterName) { + ClusterInfo cluster = getCluster(clusterName); + + if (cluster == null) { + throw new GlusterRuntimeException("Cluster [" + clusterName + "] doesn't exist!"); + } + + unregisterCluster(cluster); + } + + public void unregisterCluster(ClusterInfo cluster) { + EntityTransaction txn = clusterDao.startTransaction(); + try { + for(ServerInfo server : cluster.getServers()) { + clusterDao.delete(server); + } + cluster.getServers().clear(); + clusterDao.update(cluster); + clusterDao.delete(cluster); + txn.commit(); + } catch (RuntimeException e) { + logger.error("Error in unregistering cluster [" + cluster.getName() + "] : " + e.getMessage(), e); + txn.rollback(); + throw e; + } + } + + public void mapServerToCluster(String clusterName, String serverName) { + EntityTransaction txn = clusterDao.startTransaction(); + ClusterInfo cluster = getCluster(clusterName); + ServerInfo server = new ServerInfo(serverName); + server.setCluster(cluster); + try { + clusterDao.save(server); + cluster.addServer(server); + clusterDao.update(cluster); + txn.commit(); + } catch (Exception e) { + txn.rollback(); + throw new GlusterRuntimeException("Couldn't create cluster-server mapping [" + clusterName + "][" + + serverName + "]! Error: " + e.getMessage(), e); + } + } + + public void unmapServerFromCluster(String clusterName, String serverName) { + EntityTransaction txn = clusterDao.startTransaction(); + ClusterInfo cluster = getCluster(clusterName); + List servers = cluster.getServers(); + for(ServerInfo server : servers) { + if(server.getName().equalsIgnoreCase(serverName)) { + servers.remove(server); + clusterDao.delete(server); + break; + } + } + try { + clusterDao.update(cluster); + txn.commit(); + } catch(Exception e) { + txn.rollback(); + throw new GlusterRuntimeException("Couldn't unmap server [" + serverName + "] from cluster [" + clusterName + + "]! Error: " + e.getMessage(), e); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/DiscoveredServerService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/DiscoveredServerService.java new file mode 100644 index 00000000..95a8eecb --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/DiscoveredServerService.java @@ -0,0 +1,130 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.services; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.utils.ProcessUtil; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +public class DiscoveredServerService { + @Autowired + protected ServerUtil serverUtil; + + private List discoveredServerNames = new ArrayList(); + private static final Logger logger = Logger.getLogger(DiscoveredServerService.class); + + public List getDiscoveredServerDetails() { + try { + List discoveredServers = Collections.synchronizedList(new ArrayList()); + List threads = createThreads(discoveredServers); + ProcessUtil.waitForThreads(threads); + return discoveredServers; + } catch (Exception e) { + String errMsg = "Exception while fetching details of discovered servers! Error: [" + e.getMessage() + "]"; + logger.error(errMsg, e); + throw new GlusterRuntimeException(errMsg, e); + } + } + + /** + * Creates threads that will run in parallel and fetch details of all discovered servers + * @param discoveredServers The list to be populated with details of discovered servers + * @return + * @throws InterruptedException + */ + private List createThreads(List discoveredServers) throws InterruptedException { + List discoveredServerNames = getDiscoveredServerNames(); + List threads = new ArrayList(); + for (int i = discoveredServerNames.size() - 1; i >= 0; i--) { + Thread thread = new DiscoveredServerDetailsThread(discoveredServers, discoveredServerNames.get(i)); + threads.add(thread); + thread.start(); + if (i >= 5 && i % 5 == 0) { + // After every 5 servers, wait for 1 second so that we don't end up with too many running threads + Thread.sleep(1000); + } + } + return threads; + } + + public List getDiscoveredServerNames() { + return discoveredServerNames; + } + + public void setDiscoveredServerNames(List discoveredServerNames) { + synchronized (discoveredServerNames) { + this.discoveredServerNames = discoveredServerNames; + } + } + + public void removeDiscoveredServer(String serverName) { + discoveredServerNames.remove(serverName); + } + + public void addDiscoveredServer(String serverName) { + discoveredServerNames.add(serverName); + } + + public Server getDiscoveredServer(String serverName) { + Server server = new Server(serverName); + serverUtil.fetchServerDetails(server); + return server; + } + + public class DiscoveredServerDetailsThread extends Thread { + private List servers; + private String serverName; + private final Logger logger = Logger.getLogger(DiscoveredServerDetailsThread.class); + + /** + * Private constructor called on each thread + * @param servers The list to be populated with fetched server details + * @param serverName Name of the server whose details should be fetched by this thread + */ + private DiscoveredServerDetailsThread(List servers, String serverName) { + this.servers = servers; + this.serverName = serverName; + } + + @Override + public void run() { + try { + logger.info("fetching details of discovered server [" + serverName + "] - start"); + servers.add(getDiscoveredServer(serverName)); + logger.info("fetching details of discovered server [" + serverName + "] - end"); + } catch(Exception e) { + logger.warn("fetching details of discovered server [" + serverName + "] - error", e); + // eat the exception as we can't consider this server as a discovered server any more + } + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/Gluster323InterfaceService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/Gluster323InterfaceService.java new file mode 100644 index 00000000..ec7ae77e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/Gluster323InterfaceService.java @@ -0,0 +1,598 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.services; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import org.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.response.VolumeOptionInfoListResponse; +import org.gluster.storage.management.core.utils.StringUtil; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + + +/** + * Gluster Interface for GlusterFS version 3.2.3 + */ +@Component +@Lazy(value=true) +public class Gluster323InterfaceService extends AbstractGlusterInterface { + + private static final String VOLUME_NAME_PFX = "Volume Name:"; + private static final String VOLUME_TYPE_PFX = "Type:"; + private static final String VOLUME_STATUS_PFX = "Status:"; + private static final String VOLUME_NUMBER_OF_BRICKS = "Number of Bricks:"; + private static final String VOLUME_TRANSPORT_TYPE_PFX = "Transport-type:"; + private static final String VOLUME_BRICKS_GROUP_PFX = "Bricks"; + private static final String VOLUME_OPTIONS_RECONFIG_PFX = "Options Reconfigured"; + private static final String VOLUME_LOG_LOCATION_PFX = "log file location:"; + private static final String VOLUME_TYPE_DISTRIBUTE = "Distribute"; + private static final String VOLUME_TYPE_REPLICATE = "Replicate"; + private static final String VOLUME_TYPE_DISTRIBUTED_REPLICATTE = "Distributed-Replicate"; + private static final String VOLUME_TYPE_STRIPE = "Stripe"; + private static final String VOLUME_TYPE_DISTRIBUTED_STRIPE = "Distributed-Stripe"; + + private static final String BRICK_STATUS_SCRIPT = "get_brick_status.py"; + private static final Logger logger = Logger.getLogger(Gluster323InterfaceService.class); + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#addServer(java.lang.String, java.lang.String) + */ + @Override + public void addServer(String existingServer, String newServer) { + serverUtil.executeOnServer(existingServer, "gluster peer probe " + newServer); + // reverse peer probe to ensure that host names appear in peer status on both sides + serverUtil.executeOnServer(newServer, "gluster peer probe " + existingServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) + */ + @Override + public void startVolume(String volumeName, String knownServer, Boolean force) { + serverUtil.executeOnServer(knownServer, "gluster volume start " + volumeName + ((force) ? " force" : "")); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) + */ + @Override + public void stopVolume(String volumeName, String knownServer, Boolean force) { + serverUtil.executeOnServer(knownServer, "gluster --mode=script volume stop " + volumeName + + ((force) ? " force" : "")); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#resetOptions(java.lang.String, java.lang.String) + */ + @Override + public void resetOptions(String volumeName, String knownServer) { + serverUtil.executeOnServer(knownServer, "gluster volume reset " + volumeName); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#createVolume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr, + Integer count, String bricks, String accessProtocols, String options) { + + // TODO: Disable NFS if required depending on value of accessProtocols + VOLUME_TYPE volType = Volume.getVolumeTypeByStr(volumeTypeStr); + String volTypeArg = null; + if (volType == VOLUME_TYPE.REPLICATE || volType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { + volTypeArg = "replica"; + } else if (volType == VOLUME_TYPE.STRIPE || volType == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + volTypeArg = "stripe"; + } + + String transportTypeArg = null; + TRANSPORT_TYPE transportType = Volume.getTransportTypeByStr(transportTypeStr); + transportTypeArg = (transportType == TRANSPORT_TYPE.ETHERNET) ? "tcp" : "rdma"; + + String command = prepareVolumeCreateCommand(volumeName, StringUtil.extractList(bricks, ","), count, + volTypeArg, transportTypeArg); + + serverUtil.executeOnServer(knownServer, command); + + try { + createOptions(volumeName, StringUtil.extractMap(options, ",", "="), knownServer); + } catch(Exception e) { + throw new GlusterRuntimeException( + "Volume created successfully, however following errors occurred while setting options: " + + CoreConstants.NEWLINE + e.getMessage()); + } + } + + private String prepareVolumeCreateCommand(String volumeName, List brickDirectories, int count, + String volumeType, String transportTypeStr) { + StringBuilder command = new StringBuilder("gluster volume create " + volumeName + " "); + if (volumeType != null) { + command.append(volumeType + " " + count + " "); + } + command.append("transport " + transportTypeStr); + for (String brickDir : brickDirectories) { + command.append(" " + brickDir); + } + return command.toString(); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#createOptions(java.lang.String, java.util.Map, java.lang.String) + */ + @Override + public void createOptions(String volumeName, Map options, String knownServer) { + String errors = ""; + if (options != null) { + for (Entry option : options.entrySet()) { + String key = option.getKey(); + String value = option.getValue(); + + try { + setOption(volumeName, key, value, knownServer); + } catch(Exception e) { + // append error + errors += e.getMessage() + CoreConstants.NEWLINE; + } + } + } + if (!errors.trim().isEmpty()) { + throw new GlusterRuntimeException("Errors while setting option(s) on volume [" + volumeName + "] : " + + errors.trim()); + } + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#setOption(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void setOption(String volumeName, String key, String value, String knownServer) { + serverUtil.executeOnServer(knownServer, "gluster volume set " + volumeName + " " + key + " " + "\"" + + value + "\""); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#deleteVolume(java.lang.String, java.lang.String) + */ + @Override + public void deleteVolume(String volumeName, String knownServer) { + serverUtil.executeOnServer(knownServer, "gluster --mode=script volume delete " + volumeName); + } + + private String getVolumeInfo(String volumeName, String knownServer) { + return serverUtil.executeOnServer(knownServer, "gluster volume info " + volumeName, String.class); + } + + private String getVolumeInfo(String knownServer) { + return serverUtil.executeOnServer(knownServer, "gluster volume info", String.class); + } + + private boolean readVolumeType(Volume volume, String line) { + String volumeType = StringUtil.extractToken(line, VOLUME_TYPE_PFX); + if (volumeType != null) { + if (volumeType.equals(VOLUME_TYPE_DISTRIBUTE)) { + volume.setVolumeType(VOLUME_TYPE.DISTRIBUTE); + + } else if (volumeType.equals(VOLUME_TYPE_REPLICATE)) { + volume.setVolumeType(VOLUME_TYPE.REPLICATE); + volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); + + } else if ( volumeType.equals(VOLUME_TYPE_DISTRIBUTED_REPLICATTE) ){ + volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_REPLICATE); + volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); + + } else if ( volumeType.equals(VOLUME_TYPE_STRIPE) ){ + volume.setVolumeType(VOLUME_TYPE.STRIPE); + volume.setReplicaCount(Volume.DEFAULT_REPLICA_COUNT); + + } else if ( volumeType.equals(VOLUME_TYPE_DISTRIBUTED_STRIPE) ){ + volume.setVolumeType(VOLUME_TYPE.DISTRIBUTED_STRIPE); + volume.setReplicaCount(Volume.DEFAULT_STRIPE_COUNT); + } + return true; + } + return false; + } + + private void readReplicaOrStripeCount(Volume volume, String line) { + if (StringUtil.extractToken(line, "x") != null) { + // expected formated of line is "Number of Bricks: 3 x 2 = 6" + int count = Integer.parseInt(line.split("x")[1].split("=")[0].trim()); + if (volume.getVolumeType() == VOLUME_TYPE.STRIPE + || volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_STRIPE) { + volume.setStripeCount(count); + } else if (volume.getVolumeType() == VOLUME_TYPE.REPLICATE + || volume.getVolumeType() == VOLUME_TYPE.DISTRIBUTED_REPLICATE) { + volume.setReplicaCount(count); + volume.setStripeCount(0); + } + } + return; + } + + private boolean readVolumeStatus(Volume volume, String line) { + String volumeStatus = StringUtil.extractToken(line, VOLUME_STATUS_PFX); + if (volumeStatus != null) { + volume.setStatus(volumeStatus.equals("Started") ? VOLUME_STATUS.ONLINE : VOLUME_STATUS.OFFLINE); + return true; + } + return false; + } + + private boolean readTransportType(Volume volume, String line) { + String transportType = StringUtil.extractToken(line, VOLUME_TRANSPORT_TYPE_PFX); + if (transportType != null) { + volume.setTransportType(transportType.equals("tcp") ? TRANSPORT_TYPE.ETHERNET : TRANSPORT_TYPE.INFINIBAND); + return true; + } + return false; + } + + private boolean readBrick(Volume volume, String brickLine) { + BRICK_STATUS brickStatus; + if (brickLine.matches("Brick[0-9]+:.*")) { + // line: "Brick1: server1:/export/md0/volume-name" + String brickName = brickLine.split(": ")[1]; + String[] brickParts = brickLine.split(":"); + String serverName = brickParts[1].trim(); + String brickDir = brickParts[2].trim(); + //To get the brick status + brickStatus = getBrickStatus(serverName, volume.getName(), brickName); + + addBrickToVolume(volume, serverName, brickDir, brickStatus); + return true; + } + return false; + } + + private void addBrickToVolume(Volume volume, String serverName, String brickDir, BRICK_STATUS status) { + volume.addBrick(new Brick(serverName, status, brickDir)); + } + + // Do not throw exception, Gracefully handle as Offline brick. + private BRICK_STATUS getBrickStatus(String serverName, String volumeName, String brick){ + try { + String output = serverUtil.executeScriptOnServer(serverName, BRICK_STATUS_SCRIPT + " " + volumeName + + " " + brick, String.class); + if (output.equals(CoreConstants.ONLINE)) { + return BRICK_STATUS.ONLINE; + } else { + return BRICK_STATUS.OFFLINE; + } + } catch(Exception e) { // Particularly interested on ConnectionExecption, if the server is offline + logger.warn("Exception while fetching brick status for [" + volumeName + "][" + brick + + "]. Marking it as offline!", e); + return BRICK_STATUS.OFFLINE; + } + } + + private boolean readBrickGroup(String line) { + return StringUtil.extractToken(line, VOLUME_BRICKS_GROUP_PFX) != null; + } + + private boolean readOptionReconfigGroup(String line) { + return StringUtil.extractToken(line, VOLUME_OPTIONS_RECONFIG_PFX) != null; + } + + private boolean readOption(Volume volume, String line) { + if (line.matches("^[^:]*:.*$")) { + int index = line.indexOf(':'); + volume.setOption(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim()); + + if (line.substring(0, index).trim().equals(Volume.OPTION_NFS_DISABLE)) { + if (line.substring(index + 1, line.length()).trim().equals(GlusterConstants.ON)) { + volume.disableNFS(); + } else { + volume.enableNFS(); + } + } + + return true; + } + return false; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getVolume(java.lang.String, java.lang.String) + */ + @Override + public Volume getVolume(String volumeName, String knownServer) { + return parseVolumeInfo(getVolumeInfo(volumeName, knownServer)).get(0); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getAllVolumes(java.lang.String) + */ + @Override + public List getAllVolumes(String knownServer) { + return parseVolumeInfo(getVolumeInfo(knownServer)); + } + + private List parseVolumeInfo(String volumeInfoText) { + List volumes = new ArrayList(); + boolean isBricksGroupFound = false; + boolean isOptionReconfigFound = false; + Volume volume = null; + + for (String line : volumeInfoText.split(CoreConstants.NEWLINE)) { + String volumeName = StringUtil.extractToken(line, VOLUME_NAME_PFX); + if (volumeName != null) { + if (volume != null) { + volumes.add(volume); + } + + // prepare next volume to be read + volume = new Volume(); + volume.setName(volumeName); + isBricksGroupFound = isOptionReconfigFound = false; + continue; + } + + if (readVolumeType(volume, line)) + continue; + if (StringUtil.extractToken(line, VOLUME_NUMBER_OF_BRICKS) != null) { + readReplicaOrStripeCount(volume, line); + } + if (readVolumeStatus(volume, line)) + continue; + if (readTransportType(volume, line)) + continue; + if (readBrickGroup(line)) { + isBricksGroupFound = true; + continue; + } + + if (isBricksGroupFound) { + if (readBrick(volume, line)) { + continue; + } else { + isBricksGroupFound = false; + } + } + + if (readOptionReconfigGroup(line)) { + isOptionReconfigFound = true; + continue; + } + + if (isOptionReconfigFound) { + if (readOption(volume, line)) { + continue; + } else { + isOptionReconfigFound = false; + } + } + } + + // add the last read volume + if (volume != null) { + volumes.add(volume); + } + + return volumes; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#addBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override + public void addBricks(String volumeName, List bricks, String knownServer) { + StringBuilder command = new StringBuilder("gluster volume add-brick " + volumeName); + for (String brickDir : bricks) { + command.append(" " + brickDir); + } + + serverUtil.executeOnServer(knownServer, command.toString()); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getLogLocation(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public String getLogLocation(String volumeName, String brickName, String knownServer) { + String command = "gluster volume log locate " + volumeName + " " + brickName; + String output = serverUtil.executeOnServer(knownServer, command, String.class); + if (output.startsWith(VOLUME_LOG_LOCATION_PFX)) { + return output.substring(VOLUME_LOG_LOCATION_PFX.length()).trim(); + } + + throw new GlusterRuntimeException("Couldn't parse output of command [" + command + "]. Output [" + output + + "] doesn't start with prefix [" + VOLUME_LOG_LOCATION_PFX + "]"); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getLogFileNameForBrickDir(java.lang.String) + */ + @Override + public String getLogFileNameForBrickDir(String serverName, String brickDir) { + String logFileName = brickDir; + if (logFileName.length() > 0 && logFileName.charAt(0) == '/') { + logFileName = logFileName.replaceFirst("/", ""); + } + logFileName = logFileName.replaceAll("/", "-") + ".log"; + return logFileName; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#removeBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override + public void removeBricks(String volumeName, List bricks, String knownServer) { + StringBuilder command = new StringBuilder("gluster --mode=script volume remove-brick " + volumeName); + for (String brickDir : bricks) { + command.append(" " + brickDir); + } + serverUtil.executeOnServer(knownServer, command.toString()); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#removeServer(java.lang.String, java.lang.String) + */ + @Override + public void removeServer(String existingServer, String serverName) { + serverUtil.executeOnServer(existingServer, "gluster --mode=script peer detach " + serverName); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#checkRebalanceStatus(java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkRebalanceStatus(String serverName, String volumeName) { + String command = "gluster volume rebalance " + volumeName + " status"; + String output = serverUtil.executeOnServer(serverName, command, String.class).trim(); + TaskStatus taskStatus = new TaskStatus(); + if (output.matches("^rebalance completed.*")) { + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + } else if (output.matches(".*in progress.*")) { + taskStatus.setCode(Status.STATUS_CODE_RUNNING); + } else { + taskStatus.setCode(Status.STATUS_CODE_FAILURE); + } + taskStatus.setMessage(output); + return taskStatus; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#stopRebalance(java.lang.String, java.lang.String) + */ + @Override + public void stopRebalance(String serverName, String volumeName) { + String command = "gluster volume rebalance " + volumeName + " stop"; + serverUtil.executeOnServer(serverName, command); + } + + /** + * Performs given Brick Migration (replace-brick) Operation on given volume + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume on which the Brick Migration Operation is to be executed + * @param fromBrick + * The source Brick (being replaced) + * @param toBrick + * The destination Brick (which is replacing the source Brick) + * @param operation + * @return + */ + private String performBrickMigrationOperation(String serverName, String volumeName, String fromBrick, + String toBrick, String operation) { + String command = "gluster volume replace-brick " + volumeName + " " + fromBrick + " " + toBrick + " " + + operation; + return serverUtil.executeOnServer(serverName, command, String.class); + } + + /* + * (non-Javadoc) + * + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#executeBrickMigration(java.lang.String, + * java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void startBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "start"); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#pauseBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "pause"); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#stopBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "abort"); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#commitBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "commit"); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#checkBrickMigrationStatus(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, String toBrick) { + String output = performBrickMigrationOperation(serverName, volumeName, fromBrick, toBrick, "status"); + + TaskStatus taskStatus = new TaskStatus(); + if (output.matches("^Number of files migrated.*Migration complete$") + || output.matches("^Number of files migrated = 0 .*Current file=")) { + // Note: Workaround - if no file in the volume brick to migrate, + // Gluster CLI is not giving proper (complete) status + taskStatus.setCode(Status.STATUS_CODE_COMMIT_PENDING); + taskStatus.setMessage(output.replaceAll("Migration complete", "Commit pending")); + } else if (output.matches("^Number of files migrated.*Current file=.*")) { + taskStatus.setCode(Status.STATUS_CODE_RUNNING); + } else if (output.matches("^replace brick has been paused.*")) { + taskStatus.setCode(Status.STATUS_CODE_PAUSE); + } else { + taskStatus.setCode(Status.STATUS_CODE_FAILURE); + } + + taskStatus.setMessage(output); + return taskStatus; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getVolumeOptionsInfo(java.lang.String) + */ + @Override + public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { + return serverUtil.executeOnServer(serverName, "gluster volume set help-xml", VolumeOptionInfoListResponse.class); + } + + public void logRotate(String volumeName, List brickList, String knownServer) { + if (brickList == null || brickList.size() > 0) { + for (String brickDir : brickList) { + serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName + " " + brickDir); + } + } else { + serverUtil.executeOnServer(knownServer, "gluster volume log rotate " + volumeName); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterface.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterface.java new file mode 100644 index 00000000..71c9e081 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterface.java @@ -0,0 +1,369 @@ +package org.gluster.storage.management.gateway.services; + +import java.util.List; +import java.util.Map; + +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.response.VolumeOptionInfoListResponse; + + +/** + * Interface for interacting with GlusterFS. Every version of GlusterFS supported by the Gluster Management Gateway will + * have a corresponding implementation of this interface. + */ +public interface GlusterInterface { + + /** + * Returns the GlusterFS version on given server. + * + * @param serverName + * Server on which Gluster version is to be checked. + * @return + */ + public abstract String getVersion(String serverName); + + /** + * Adds the new server to an existing cluster. + * + * @param existingServer + * Server part of the existing cluster. + * @param newServer + * Server to be added to the cluster. + */ + public abstract void addServer(String existingServer, String newServer); + + /** + * Removes given server from the cluster by executing appropriate Gluster command on given server. + * + * @param existingServer + * Server part of the existing cluster. + * @param serverName + * Server to be removed from the cluster. + */ + public abstract void removeServer(String existingServer, String serverName); + + /** + * Starts the given volume by executing appropriate Gluster command on given server. + * + * @param volumeName + * Volume to be started. + * @param serverName + * Server on which the Gluster command is to be executed. This server must be part of the cluster to + * which the volume belongs. + * @param force + * Flag indicating whether the "force" option should be used for starting the Volume. This is typically + * used when Volume is already started, but at least one of its bricks is offline, and results in + * bringing up the offline bricks. + */ + public abstract void startVolume(String volumeName, String serverName, Boolean force); + + /** + * Stops the given volume by executing appropriate Gluster command on given server. + * + * @param volumeName + * Volume to be stopped. + * @param serverName + * Server on which the Gluster command is to be executed. This server must be part of the cluster to + * which the volume belongs. + * @param force + * Flag indicating whether the Volume should be stopped forcefully. This is typically used if the regular + * stop option fails because of issues like rebalance / brick migration / geo-replication being in + * progress. This results in forcefully stopping the volume, leaving the other processes intact. + */ + public abstract void stopVolume(String volumeName, String serverName, Boolean force); + + /** + * Resets volume options on the given volume by executing appropriate Gluster command on given server. + * + * @param volumeName + * Volume on which options are to be reset. + * @param serverName + * Server on which the Gluster command is to be executed. This server must be part of the cluster to + * which the volume belongs. + */ + public abstract void resetOptions(String volumeName, String serverName); + + /** + * Creates a volume on given volume using given properties. + * + * @param serverName + * Server on which the Gluster command for creating the volume will be executed. This must be part of the + * cluster in which the volume is to be created. + * @param volumeName + * Name of the volume. + * @param volumeType + * Type of the volume e.g. DISTRIBUTE, REPLICATE, STRIPE, etc. See {@link VOLUME_TYPE} for full list of + * valid values. + * @param transportType + * Transport type of the volume e.g. ETHERNET. See {@link TRANSPORT_TYPE} for full list of valid values. + * @param replOrStripeCount + * Replica Count or Stripe count depending on the volume type. Ignored in case of pure distribute volumes + * (no replicate, no stripe). + * @param bricks + * Comma separated list of volume brick directories in following format:
    + * server1:dir1,server2:dir2,server3:dir3,...,servern:dirn + * @param accessProtocols + * Optional parameter indicating access protocols to be enabled for the volume. If empty/null, GLUSTERFS + * and NFS will be enabled. + * @param options + * A comma separated list of volume options to be set on the newly created volume in following format:
    + * key1=value1,key2=value2,key3=value3,...,keyn=valuen + */ + public abstract void createVolume(String serverName, String volumeName, String volumeType, String transportType, + Integer replOrStripeCount, String bricks, String accessProtocols, String options); + + /** + * Creates / Sets the given options on the given volume by executing appropriate Gluster command on the given + * server. + * + * @param volumeName + * Volume on which the options are to be set. + * @param options + * Map containing the volume options to be set. Key = option key, Value = option value. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void createOptions(String volumeName, Map options, String serverName); + + /** + * Sets the given option on given volume by executing appropriate Gluster command on the given server. + * + * @param volumeName + * Volume on which the option is to be set. + * @param key + * Option key (name) + * @param value + * Option value + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void setOption(String volumeName, String key, String value, String serverName); + + /** + * Deletes the given volume by executing appropriate Gluster command on the given server. + * + * @param volumeName + * Volume to be deleted. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void deleteVolume(String volumeName, String serverName); + + /** + * Fetches properties of the given Volume by executing appropriate Gluster command on the given server. + * + * @param volumeName + * Volume whose properties are to be fetched. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return A {@link Volume} object containing all properties of the given volume + */ + public abstract Volume getVolume(String volumeName, String serverName); + + /** + * Fetches the list of all volumes (along with their properties) by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return A list of {@link Volume} objects representing every volume present in the cluster to which the given + * server belongs. + */ + public abstract List getAllVolumes(String serverName); + + /** + * Adds given list of bricks to given Volume by executing appropriate Gluster command on the + * given server. + * + * @param volumeName + * Volume to which the bricks are to be added. + * @param bricks + * List of bricks to be added, each in the format serverName:brickDirectory + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void addBricks(String volumeName, List bricks, String serverName); + + /** + * Removes given list of bricks from given volume by executing appropriate Gluster command on the + * given server. + * + * @param volumeName + * Volume from which the bricks are to be removed + * @param bricks + * List of bricks to be removed, each in the format serverName:brickDirectory + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void removeBricks(String volumeName, List bricks, String serverName); + + /** + * Returns the log location of given brick of given volume by executing appropriate Gluster command on the + * given server. + * + * @param volumeName + * Volume for which log location is to be fetched. + * @param brickName + * Brick of the volume for which log location is to be fetched. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return Full path of the log file location (directory) for the given Volume Brick. + */ + public abstract String getLogLocation(String volumeName, String brickName, String serverName); + + /** + * Returns the log file name for given brick directory. + * + * @param serverName + * Server to which the brick belongs + * @param brickDir + * Brick directory for which log file name is to be returned. + * @return The log file name (without path) for the given brick directory. + */ + public abstract String getLogFileNameForBrickDir(String serverName, String brickDir); + + /** + * Checks the status of "Rebalance" operation on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose rebalance status is to be checked. + * @return Object of {@link TaskStatus} representing the status of Volume Rebalance. + */ + public abstract TaskStatus checkRebalanceStatus(String serverName, String volumeName); + + /** + * Stops "Rebalance" operation running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Rebalance is to be stopped. + */ + public abstract void stopRebalance(String serverName, String volumeName); + + /** + * Starts Brick Migration (replace-brick) on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is to be migrated/replaced. + * @param fromBrick + * The source Brick (to be replaced). + * @param toBrick + * The destination Brick (will replace the source Brick). + */ + public abstract void startBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Pauses Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick). + */ + public abstract void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Aborts Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick) + */ + public abstract void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Commits Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command on the + * given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick) + */ + public abstract void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick); + + /** + * Checks status of Brick Migration (replace-brick) running on given Volume by executing appropriate Gluster command + * on the given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @param volumeName + * Volume whose Brick is being migrated/replaced. + * @param fromBrick + * The source Brick (being replaced). + * @param toBrick + * The destination Brick (which is replacing the source Brick) + * @return A {@link TaskStatus} object representing the status of Brick Migration + */ + public abstract TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, + String toBrick); + + /** + * Returns information about all the supported Volume Options by executing appropriate Gluster command + * on the given server. + * + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + * @return A {@link VolumeOptionInfoListResponse} object containing information about each and every supported + * Volume Option + */ + public abstract VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName); + + /** + * Rotates the logs for given Bricks of given Volume by executing appropriate Gluster command + * on the given server. + * + * @param volumeName + * Volume whose logs are to be rotated. + * @param brickList + * List of bricks whose logs are to be rotated, each in the format serverName:brickDirectory
    + * This is an optional parameter. If null or empty, all logs of the Volume will be rotated. + * @param serverName + * The server on which the Gluster command will be executed. This must be part of the cluster to which + * the volume belongs. + */ + public abstract void logRotate(String volumeName, List brickList, String serverName); +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterfaceService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterfaceService.java new file mode 100644 index 00000000..07e152b8 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterInterfaceService.java @@ -0,0 +1,256 @@ +/** + * GlusterInterfaceService.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.services; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.response.VolumeOptionInfoListResponse; +import org.springframework.stereotype.Component; + + +@Component +public class GlusterInterfaceService extends AbstractGlusterInterface { + private HashMap glusterInterfaces = new HashMap(); + + /** + * Returns an instance of the Gluster Interface for given version of GlusterFS + * @param glusterFsVersion + * @return + */ + private GlusterInterface getGlusterInterfaceForVersion(String glusterFsVersion) { + GlusterInterface glusterInterface = glusterInterfaces.get(glusterFsVersion); + if(glusterInterface != null) { + return glusterInterface; + } + + glusterInterface = serverUtil.getBean(Gluster323InterfaceService.class); + glusterInterfaces.put(glusterFsVersion, glusterInterface); + return glusterInterface; + } + + /** + * Returns an instance of Gluster Interface for the version of GlusterFS installed on given server. + * + * @param serverName + * @return + */ + private GlusterInterface getGlusterInterface(String serverName) { + return getGlusterInterfaceForVersion(getVersion(serverName)); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#addServer(java.lang.String, java.lang.String) + */ + @Override + public void addServer(String existingServer, String newServer) { + getGlusterInterface(existingServer).addServer(existingServer, newServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) + */ + @Override + public void startVolume(String volumeName, String knownServer, Boolean force) { + getGlusterInterface(knownServer).startVolume(volumeName, knownServer, force); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) + */ + @Override + public void stopVolume(String volumeName, String knownServer, Boolean force) { + getGlusterInterface(knownServer).stopVolume(volumeName, knownServer, force); + } + + public void logRotate(String volumeName, List brickList, String knownServer) { + getGlusterInterface(knownServer).logRotate(volumeName, brickList, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#resetOptions(java.lang.String, java.lang.String) + */ + @Override + public void resetOptions(String volumeName, String knownServer) { + getGlusterInterface(knownServer).resetOptions(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#createVolume(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr, + Integer count, String bricks, String accessProtocols, String options) { + getGlusterInterface(knownServer).createVolume(knownServer, volumeName, volumeTypeStr, transportTypeStr, count, + bricks, accessProtocols, options); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#createOptions(java.lang.String, java.util.Map, java.lang.String) + */ + @Override + public void createOptions(String volumeName, Map options, String knownServer) { + getGlusterInterface(knownServer).createOptions(volumeName, options, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#setOption(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void setOption(String volumeName, String key, String value, String knownServer) { + getGlusterInterface(knownServer).setOption(volumeName, key, value, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#deleteVolume(java.lang.String, java.lang.String) + */ + @Override + public void deleteVolume(String volumeName, String knownServer) { + getGlusterInterface(knownServer).deleteVolume(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getVolume(java.lang.String, java.lang.String) + */ + @Override + public Volume getVolume(String volumeName, String knownServer) { + return getGlusterInterface(knownServer).getVolume(volumeName, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getAllVolumes(java.lang.String) + */ + @Override + public List getAllVolumes(String knownServer) { + return getGlusterInterface(knownServer).getAllVolumes(knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#addBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override + public void addBricks(String volumeName, List bricks, String knownServer) { + getGlusterInterface(knownServer).addBricks(volumeName, bricks, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getLogLocation(java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public String getLogLocation(String volumeName, String brickName, String knownServer) { + return getGlusterInterface(knownServer).getLogLocation(volumeName, brickName, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getLogFileNameForBrickDir(java.lang.String) + */ + @Override + public String getLogFileNameForBrickDir(String serverName, String brickDir) { + return getGlusterInterface(serverName).getLogFileNameForBrickDir(serverName, brickDir); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#removeBricks(java.lang.String, java.util.List, java.lang.String) + */ + @Override + public void removeBricks(String volumeName, List bricks, String knownServer) { + getGlusterInterface(knownServer).removeBricks(volumeName, bricks, knownServer); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#removeServer(java.lang.String, java.lang.String) + */ + @Override + public void removeServer(String existingServer, String serverName) { + getGlusterInterface(serverName).removeServer(existingServer, serverName); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#checkRebalanceStatus(java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkRebalanceStatus(String serverName, String volumeName) { + return getGlusterInterface(serverName).checkRebalanceStatus(serverName, volumeName); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#stopRebalance(java.lang.String, java.lang.String) + */ + @Override + public void stopRebalance(String serverName, String volumeName) { + getGlusterInterface(serverName).stopRebalance(serverName, volumeName); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#executeBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void startBrickMigration(String onlineServerName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(onlineServerName).startBrickMigration(onlineServerName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#pauseBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void pauseBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(serverName).pauseBrickMigration(serverName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#stopBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void stopBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(serverName).stopBrickMigration(serverName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#commitBrickMigration(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void commitBrickMigration(String serverName, String volumeName, String fromBrick, String toBrick) { + getGlusterInterface(serverName).commitBrickMigration(serverName, volumeName, fromBrick, toBrick); + } + + /* + * (non-Javadoc) + * @see org.gluster.storage.management.gateway.services.GlusterInterface#checkBrickMigrationStatus(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public TaskStatus checkBrickMigrationStatus(String serverName, String volumeName, String fromBrick, String toBrick) { + return getGlusterInterface(serverName).checkBrickMigrationStatus(serverName, volumeName, fromBrick, toBrick); + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getVolumeOptionsInfo(java.lang.String) + */ + @Override + public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { + return getGlusterInterface(serverName).getVolumeOptionsInfo(serverName); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterServerService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterServerService.java new file mode 100644 index 00000000..58482958 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/GlusterServerService.java @@ -0,0 +1,530 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.services; + +import static org.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SERVER_NAME; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.response.StringListResponse; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.ProcessUtil; +import org.gluster.storage.management.core.utils.StringUtil; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.data.ServerInfo; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.gluster.storage.management.gateway.utils.SshUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +public class GlusterServerService { + private static final String HOSTNAME_PFX = "Hostname:"; + private static final String UUID_PFX = "Uuid:"; + private static final String STATE_PFX = "State:"; + private static final String GLUSTER_SERVER_STATUS_ONLINE = "Peer in Cluster (Connected)"; + private static final String GLUSTERD_INFO_FILE = "/etc/glusterd/glusterd.info"; + + @Autowired + protected ServerUtil serverUtil; + + @Autowired + private ClusterService clusterService; + + @Autowired + private GlusterInterfaceService glusterUtil; + + @Autowired + private SshUtil sshUtil; + + @Autowired + private VolumeService volumeService; + + @Autowired + private DiscoveredServerService discoveredServerService; + + private static final Logger logger = Logger.getLogger(GlusterServerService.class); + + public List getGlusterServers(String clusterName, boolean fetchDetails, Integer maxCount, + String previousServerName) { + List glusterServers; + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + try { + glusterServers = getGlusterServers(clusterName, onlineServer, fetchDetails, maxCount, previousServerName); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterServers = getGlusterServers(clusterName, onlineServer, fetchDetails, maxCount, previousServerName); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + + } + return glusterServers; + } + + private List getGlusterServers(String clusterName, GlusterServer onlineServer, boolean fetchDetails, + Integer maxCount, String previousServerName) { + List glusterServers; + try { + glusterServers = getGlusterServers(onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterServers = getGlusterServers(onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + + // skip the servers by maxCount / previousServerName + glusterServers = GlusterCoreUtil.skipEntities(glusterServers, maxCount, previousServerName); + + if (fetchDetails) { + String errMsg = fetchDetailsOfServers(Collections.synchronizedList(glusterServers)); + if (!errMsg.isEmpty()) { + throw new GlusterRuntimeException("Couldn't fetch details for server(s): " + errMsg); + } + } + return glusterServers; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getGlusterServer(org.gluster.storage.management.core.model.GlusterServer, java.lang.String) + */ + public GlusterServer getGlusterServer(String onlineServer, String serverName) { + List servers = getGlusterServers(onlineServer); + for (GlusterServer server : servers) { + if (server.getName().equalsIgnoreCase(serverName)) { + return server; + } + } + + // Server not found. It's possible that the server name returned by glusterfs is actually IP address + // Hence fetch details of all servers and then compare the host names again. + String errMsg = fetchDetailsOfServers(Collections.synchronizedList(servers)); + if (!errMsg.isEmpty()) { + throw new GlusterRuntimeException("Couldn't fetch details for server(s): " + errMsg); + } + for (GlusterServer server : servers) { + if (server.getName().equalsIgnoreCase(serverName)) { + return server; + } + } + + // still not found! + return null; + } + + private String getUuid(String serverName) { + return serverUtil.executeOnServer(serverName, "cat " + GLUSTERD_INFO_FILE, String.class).split("=")[1]; + } + + /* (non-Javadoc) + * @see org.gluster.storage.management.gateway.utils.GlusterInterface#getGlusterServers(org.gluster.storage.management.core.model.GlusterServer) + */ + public List getGlusterServers(String knownServerName) { + String output = getPeerStatus(knownServerName); + + GlusterServer knownServer = new GlusterServer(knownServerName); + knownServer.setUuid(getUuid(knownServerName)); + + List glusterServers = new ArrayList(); + glusterServers.add(knownServer); + + GlusterServer server = null; + boolean foundHost = false; + boolean foundUuid = false; + for (String line : output.split(CoreConstants.NEWLINE)) { + if (foundHost && foundUuid) { + // Host and UUID is found, we should look for state + String state = StringUtil.extractToken(line, STATE_PFX); + if (state != null) { + server.setStatus(state.contains(GLUSTER_SERVER_STATUS_ONLINE) ? SERVER_STATUS.ONLINE + : SERVER_STATUS.OFFLINE); + // Completed populating current server. Add it to the list + // and reset all related variables. + glusterServers.add(server); + + foundHost = false; + foundUuid = false; + server = null; + } + } else if (foundHost) { + // Host is found, look for UUID + String uuid = StringUtil.extractToken(line, UUID_PFX); + if (uuid != null) { + server.setUuid(uuid); + foundUuid = true; + } + } else { + // Look for the next host + if (server == null) { + server = new GlusterServer(); + } + String hostName = StringUtil.extractToken(line, HOSTNAME_PFX); + if (hostName != null) { + server.setName(hostName); + foundHost = true; + } + } + + } + return glusterServers; + } + + /** + * @param knownServer + * A known server on which the gluster command will be executed to fetch peer status + * @return Outout of the "gluster peer status" command + */ + private String getPeerStatus(String knownServer) { + return serverUtil.executeOnServer(knownServer, "gluster peer status", String.class); + } + + private String fetchDetailsOfServers(List glusterServers) { + try { + List errors = Collections.synchronizedList(new ArrayList()); + + List threads = createThreads(glusterServers, errors); + ProcessUtil.waitForThreads(threads); + + return prepareErrorMessage(errors); + } catch(InterruptedException e) { + String errMsg = "Exception while fetching details of servers! Error: [" + e.getMessage() + "]"; + logger.error(errMsg, e); + throw new GlusterRuntimeException(errMsg, e); + } + } + + private String prepareErrorMessage(List errors) { + String errMsg = ""; + for(String error : errors) { + if(!errMsg.isEmpty()) { + errMsg += CoreConstants.NEWLINE; + } + errMsg += error; + } + + return errMsg; + } + + /** + * Creates threads that will run in parallel and fetch details of given gluster servers + * @param discoveredServers The list to be populated with details of gluster servers + * @param errors List to be populated with errors if any + * @return + * @throws InterruptedException + */ + private List createThreads(List glusterServers, List errors) + throws InterruptedException { + List threads = new ArrayList(); + for (int i = glusterServers.size()-1; i >= 0 ; i--) { + Thread thread = new ServerDetailsThread(glusterServers.get(i), errors); + threads.add(thread); + thread.start(); + if(i >= 5 && i % 5 == 0) { + // After every 5 servers, wait for 1 second so that we don't end up with too many running threads + Thread.sleep(1000); + } + } + return threads; + } + + public class ServerDetailsThread extends Thread { + private List errors; + private GlusterServer server; + private final Logger logger = Logger.getLogger(ServerDetailsThread.class); + + /** + * Private constructor called on each thread + * @param server The server whose details are to be fetched by this thread + * @param errors + */ + private ServerDetailsThread(GlusterServer server, List errors) { + this.errors = errors; + this.server = server; + } + + @Override + public void run() { + try { + logger.info("fetching details of server [" + server.getName() + "] - start"); + serverUtil.fetchServerDetails(server); + logger.info("fetching details of server [" + server.getName() + "] - end"); + } catch (Exception e) { + logger.error("fetching details of server [" + server.getName() + "] - error", e); + errors.add(server.getName() + " : [" + e.getMessage() + "]"); + } + } + } + + public GlusterServer getGlusterServer(String clusterName, String serverName, Boolean fetchDetails) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (serverName == null || serverName.isEmpty()) { + throw new GlusterValidationException("Server name must not be empty!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + throw new GlusterRuntimeException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + return getGlusterServer(clusterName, serverName, onlineServer, fetchDetails); + } + + private GlusterServer getGlusterServer(String clusterName, String serverName, GlusterServer onlineServer, + Boolean fetchDetails) { + GlusterServer server = null; + try { + server = getGlusterServer(onlineServer.getName(), serverName); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + server = getGlusterServer(onlineServer.getName(), serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + + if (fetchDetails && server.isOnline()) { + serverUtil.fetchServerDetails(server); + } + return server; + } + + public boolean isValidServer(String clusterName, String serverName) { + try { + GlusterServer server = getGlusterServer(clusterName, serverName, false); + return server != null; + } catch(Exception e) { + return false; + } + } + + public void removeServerFromCluster(String clusterName, String serverName) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (serverName == null || serverName.isEmpty()) { + throw new GlusterValidationException("Server name must not be empty!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + List servers = cluster.getServers(); + if (servers == null || servers.isEmpty() || !containsServer(servers, serverName)) { + throw new GlusterValidationException("Server [" + serverName + "] is not attached to cluster [" + + clusterName + "]!"); + } + + if (servers.size() == 1) { + // Only one server mapped to the cluster, no "peer detach" required. + // remove the cached online server for this cluster if present + clusterService.removeOnlineServer(clusterName); + } else { + // get an online server that is not same as the server being removed + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName, serverName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + + try { + glusterUtil.removeServer(onlineServer.getName(), serverName); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName, serverName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + glusterUtil.removeServer(onlineServer.getName(), serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + + clusterService.unmapServerFromCluster(clusterName, serverName); + + // since the server is removed from the cluster, it is now available to be added to other clusters. + // Hence add it back to the discovered servers list. + discoveredServerService.addDiscoveredServer(serverName); + + try { + if (serverUtil.isServerOnline(new Server(serverName))) { + volumeService.clearCifsConfiguration(clusterName, onlineServer.getName(), serverName); + } + } catch (Exception e1) { + throw new GlusterRuntimeException( + "Server removed from cluster, however deleting cifs configuration failed ! [ " + + e1.getMessage() + "]"); + } + if (onlineServer.getName().equals(serverName)) { + // since the cached server has been removed from the cluster, remove it from the cache + clusterService.removeOnlineServer(clusterName); + } + } + } + + private boolean containsServer(List servers, String serverName) { + for (ServerInfo server : servers) { + if (server.getName().toUpperCase().equals(serverName.toUpperCase())) { + return true; + } + } + return false; + } + + /** + * Adds given server to cluster and returns its host name. e.g. If serverName passed is an IP address, this method + * will return the host name of the machine with given IP address. + * + * @param clusterName + * @param serverName + * @return + */ + public String addServerToCluster(String clusterName, String serverName) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (serverName == null || serverName.isEmpty()) { + throw new GlusterValidationException("Parameter [" + FORM_PARAM_SERVER_NAME + "] is missing in request!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + boolean publicKeyInstalled = sshUtil.isPublicKeyInstalled(serverName); + if (!publicKeyInstalled && !sshUtil.hasDefaultPassword(serverName)) { + // public key not installed, default password doesn't work. return with error. + throw new GlusterRuntimeException("Gluster Management Gateway uses the default password to set up keys on the server." + + CoreConstants.NEWLINE + "However it seems that the password on server [" + serverName + + "] has been changed manually." + CoreConstants.NEWLINE + + "Please reset it back to the standard default password and try again."); + } + + String hostName = serverUtil.fetchHostName(serverName); + List servers = cluster.getServers(); + if (servers != null && !servers.isEmpty()) { + // cluster has at least one existing server, so that peer probe can be performed + performAddServer(clusterName, hostName); + } else { + // this is the first server to be added to the cluster, which means no + // gluster CLI operation required. just add it to the cluster-server mapping + } + + // add the cluster-server mapping + clusterService.mapServerToCluster(clusterName, hostName); + + // since the server is added to a cluster, it should not more be considered as a + // discovered server available to other clusters + discoveredServerService.removeDiscoveredServer(hostName); + + if (!publicKeyInstalled) { + try { + // install public key (this will also disable password based ssh login) + sshUtil.installPublicKey(hostName); + } catch (Exception e) { + throw new GlusterRuntimeException("Public key could not be installed on [" + hostName + "]! Error: [" + + e.getMessage() + "]"); + } + } + return hostName; + } + + private void performAddServer(String clusterName, String serverName) { + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + + try { + glusterUtil.addServer(onlineServer.getName(), serverName); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online server found in cluster [" + clusterName + "]"); + } + glusterUtil.addServer(onlineServer.getName(), serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + public List getFsTypes(String clusterName, String serverName) { + if (isValidServer(clusterName, serverName)) { + return serverUtil.getFsTypes(serverName); + } else { + throw new GlusterRuntimeException(serverName + " does not belong to the cluster [" + clusterName + "]"); + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/VolumeService.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/VolumeService.java new file mode 100644 index 00000000..4235d674 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/services/VolumeService.java @@ -0,0 +1,984 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.services; + +import static org.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICKS; +import static org.gluster.storage.management.core.constants.RESTConstants.TASK_START; +import static org.gluster.storage.management.core.constants.RESTConstants.TASK_STOP; + +import java.io.File; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.exceptions.GlusterValidationException; +import org.gluster.storage.management.core.model.Brick; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.Volume; +import org.gluster.storage.management.core.model.VolumeLogMessage; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.model.Volume.NAS_PROTOCOL; +import org.gluster.storage.management.core.model.Volume.VOLUME_STATUS; +import org.gluster.storage.management.core.model.Volume.VOLUME_TYPE; +import org.gluster.storage.management.core.response.LogMessageListResponse; +import org.gluster.storage.management.core.response.VolumeOptionInfoListResponse; +import org.gluster.storage.management.core.utils.DateUtil; +import org.gluster.storage.management.core.utils.FileUtil; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.ProcessResult; +import org.gluster.storage.management.core.utils.ProcessUtil; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.resources.v1_0.TasksResource; +import org.gluster.storage.management.gateway.tasks.MigrateBrickTask; +import org.gluster.storage.management.gateway.tasks.RebalanceVolumeTask; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +public class VolumeService { + private static final String ALL_SERVERS_FILE_NAME = "servers"; + private static final String VOLUME_GET_CIFS_USERS_SCRIPT = "get_volume_user_cifs.py"; + private static final String VOLUME_CIFS_GRUN_SCRIPT = "grun.py"; + private static final String VOLUME_CREATE_CIFS_SCRIPT = "create_volume_cifs_all.py"; + private static final String VOLUME_MODIFY_CIFS_SCRIPT = "update_volume_cifs_all.py"; + private static final String VOLUME_START_CIFS_PEER_SCRIPT = "start_volume_cifs.py"; + private static final String VOLUME_STOP_CIFS_PEER_SCRIPT = "stop_volume_cifs.py"; + private static final String VOLUME_DELETE_CIFS_SCRIPT = "delete_volume_cifs_all.py"; + private static final String VOLUME_BRICK_LOG_SCRIPT = "get_volume_brick_log.py"; + private static final String VOLUME_DIRECTORY_CLEANUP_SCRIPT = "clear_volume_directory.py"; + private static final String REMOVE_SERVER_VOLUME_CIFS_CONFIG = "remove_server_volume_cifs_config.py"; + private static final String ALL_ONLINE_VOLUMES_FILE_NAME = "volumes"; + + @Autowired + private ClusterService clusterService; + + @Autowired + private GlusterInterfaceService glusterUtil; + + @Autowired + private GlusterServerService glusterServerService; + + @Autowired + protected ServerUtil serverUtil; + + // TODO: To be replaced with taskService + @Autowired + private TasksResource taskResource; + + private static final Logger logger = Logger.getLogger(VolumeService.class); + + public void addBricksToVolume(String clusterName, String volumeName, String bricks) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (bricks == null || bricks.isEmpty()) { + throw new GlusterValidationException("Bricks must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + List brickList = Arrays.asList(bricks.split(",")); + try { + glusterUtil.addBricks(volumeName, brickList, onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterUtil.addBricks(volumeName, brickList, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + public Volume getVolume(String clusterName, String volumeName) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + Volume volume; + try { + volume = glusterUtil.getVolume(volumeName, onlineServer.getName()); + // Collect the CIFS users if CIFS Re-exported + fetchVolumeCifsUsers(clusterName, volume); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + volume = glusterUtil.getVolume(volumeName, onlineServer.getName()); + // Collect the CIFS users if CIFS Re-exported + fetchVolumeCifsUsers(clusterName, volume); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + return volume; + } + + public List getVolumes(String clusterName, Integer maxCount, String previousVolumeName) { + List volumes = getVolumes(clusterName); + // Skip the volumes by maxCount / previousServerName + volumes = GlusterCoreUtil.skipEntities(volumes, maxCount, previousVolumeName); + // fetch CIFS users of the volumes + fetchCifsUsers(clusterName, volumes); + + return volumes; + } + + private List getVolumes(String clusterName) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + if(cluster.getServers().size() == 0) { + // no server added yet. return an empty array. + return new ArrayList(); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + try { + return glusterUtil.getAllVolumes(onlineServer.getName()); + } catch (Exception e) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + return glusterUtil.getAllVolumes(onlineServer.getName()); + } + } + + private void fetchVolumeCifsUsers(String clusterName, Volume volume) { + List users = new ArrayList(); + try { + ProcessResult result = serverUtil + .executeGlusterScript(true, VOLUME_GET_CIFS_USERS_SCRIPT, volume.getName()); + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + String output = result.getOutput().trim(); + if (output.isEmpty()) { + volume.disableCifs(); + } else { + users = Arrays.asList(output.split(CoreConstants.NEWLINE)); + volume.enableCifs(); + volume.setCifsUsers(users); + } + } catch (Exception e) { + throw new GlusterRuntimeException("Error in fetching CIFS users [" + volume.getName() + "]: " + + e.getMessage()); + } + return; + } + + private void fetchCifsUsers(String clusterName, List volumes) { + for (Volume volume: volumes) { + fetchVolumeCifsUsers(clusterName, volume); + } + } + + private File createOnlineServerList(String clusterName) { + String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); + String clusterServersListFile = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR + + ALL_SERVERS_FILE_NAME + "_" + timestamp; + + try { + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + List glusterServers = glusterServerService.getGlusterServers(onlineServer.getName()); + File serversFile = new File(clusterServersListFile); + FileOutputStream fos = new FileOutputStream(serversFile); + for (GlusterServer server : glusterServers) { + if (server.getStatus() == SERVER_STATUS.ONLINE) { + fos.write((server.getName() + CoreConstants.NEWLINE).getBytes()); + } + } + fos.close(); + return serversFile; + } catch (Exception e) { + throw new GlusterRuntimeException("Error in preparing server list: [" + e.getMessage() + "]"); + } + } + + public void startCifsReExport(String clusterName, String volumeName) { + try { + File file = createOnlineServerList(clusterName); + ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_CIFS_GRUN_SCRIPT, + file.getAbsolutePath(), VOLUME_START_CIFS_PEER_SCRIPT, volumeName); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + } catch (Exception e) { + throw new GlusterRuntimeException("Error in starting CIFS services for volume [" + volumeName + "]: " + + e.getMessage()); + } + } + + public void stopCifsReExport(String clusterName, String volumeName) { + try { + File file = createOnlineServerList(clusterName); + ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_CIFS_GRUN_SCRIPT, + file.getAbsolutePath(), VOLUME_STOP_CIFS_PEER_SCRIPT, volumeName); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + } catch (Exception e) { + throw new GlusterRuntimeException("Error in stoping CIFS services for volume [" + volumeName + "]: " + + e.getMessage()); + } + } + + public void deleteCifsUsers(String clusterName, String volumeName) { + try { + File file = createOnlineServerList(clusterName); + ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_DELETE_CIFS_SCRIPT, + file.getAbsolutePath(), volumeName); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + } catch (Exception e) { + throw new GlusterRuntimeException("Error in deleting CIFS configuration [" + volumeName + "]: " + + e.getMessage()); + } + } + + public void createCIFSUsers(String clusterName, String volumeName, String cifsUsers) { + try { + File file = createOnlineServerList(clusterName); + List arguments = new ArrayList(); + arguments.add(file.getAbsolutePath()); + arguments.add(volumeName); + arguments.addAll( Arrays.asList(cifsUsers.replaceAll(" ", "").split(","))); + ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_CREATE_CIFS_SCRIPT, arguments); + file.delete(); + Volume volume = getVolume(clusterName, volumeName); + // If the volume service is already in running, create user may start CIFS re-export automatically. + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + startCifsReExport(clusterName, volumeName); + } + /* + * else { stopCifsReExport(clusterName, volumeName); } + */ + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + } catch (Exception e) { + throw new GlusterRuntimeException("Error in creating CIFS configuration [" + volumeName + "]: " + + e.getMessage()); + } + } + + @Deprecated + public void modifyCIFSUsers(String clusterName, String volumeName, String cifsUsers) { + try { + File file = createOnlineServerList(clusterName); + List arguments = new ArrayList(); + arguments.add(file.getAbsolutePath()); + arguments.add(volumeName); + arguments.addAll( Arrays.asList(cifsUsers.split(","))); + ProcessResult result = serverUtil.executeGlusterScript(true, VOLUME_MODIFY_CIFS_SCRIPT, arguments); + file.delete(); + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + } catch (Exception e) { + throw new GlusterRuntimeException("Error in updating CIFS configuration [" + volumeName + "]: " + + e.getMessage()); + } + } + + // To clear all the volume CIFS configurations from the server + public void clearCifsConfiguration(String clusterName, String onlineServerName, String serverName) { + File volumesFile = createOnlineVolumeList(clusterName, onlineServerName); + if (volumesFile == null) { + return; + } + try { + removeServerVolumeCifsConfig(serverName, volumesFile.getAbsolutePath()); + volumesFile.delete(); + } catch(Exception e) { + volumesFile.delete(); + throw new GlusterRuntimeException("Error in clearing volume CIFS configuration: [" + e.getMessage() + "]"); + } + } + + private File createOnlineVolumeList(String clusterName, String onlineServerName) { + String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); + String volumeListFileName = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR + + ALL_ONLINE_VOLUMES_FILE_NAME + "_" + timestamp; + try { + List volumes = getVolumes(clusterName); + if (volumes == null || volumes.size() == 0) { + return null; + } + File volumesFile = new File(volumeListFileName); + FileOutputStream fos = new FileOutputStream(volumesFile); + for (Volume volume : volumes) { + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + fos.write((volume.getName() + CoreConstants.NEWLINE).getBytes()); + } + } + fos.close(); + return volumesFile; + } catch (Exception e) { + throw new GlusterRuntimeException("Error in preparing volume list: [" + e.getMessage() + "]"); + } + } + + + public void removeServerVolumeCifsConfig(String serverName, String volumesFileName) { + ProcessResult result = serverUtil.executeGlusterScript(true, REMOVE_SERVER_VOLUME_CIFS_CONFIG, serverName, + volumesFileName); + if (!result.isSuccess()) { + throw new GlusterRuntimeException(result.toString()); + } + } + + public void createVolume(String clusterName, String volumeName, String volumeType, String transportType, + Integer count, String bricks, String accessProtocols, String options, + String cifsUsers) { + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + if ((volumeType.equals(VOLUME_TYPE.REPLICATE.toString()) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE + .toString())) && count <= 0) { + throw new GlusterValidationException("Replica count must be a positive integer"); + } + + if ((volumeType.equals(VOLUME_TYPE.STRIPE.toString()) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE + .toString())) && count <= 0) { + throw new GlusterValidationException("Stripe count must be a positive integer"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + try { + glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, count, + bricks, accessProtocols, options); + + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, count, + bricks, accessProtocols, options); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + + List nasProtocols = Arrays.asList(accessProtocols.split(",")); + // if cifs enabled + if (nasProtocols.contains(NAS_PROTOCOL.CIFS.toString())) { + try { + createCIFSUsers(clusterName, volumeName, cifsUsers); + } catch (Exception e) { + throw new GlusterRuntimeException(CoreConstants.NEWLINE + e.getMessage()); + } + } + } + + public String downloadLogs(Volume volume) { + // create temporary directory + File tempDir = FileUtil.createTempDir(); + String tempDirPath = tempDir.getPath(); + + for (Brick brick : volume.getBricks()) { + String logDir = glusterUtil.getLogLocation(volume.getName(), brick.getQualifiedName(), + brick.getServerName()); + String logFileName = glusterUtil.getLogFileNameForBrickDir(brick.getServerName(), brick.getBrickDirectory()); + String logFilePath = logDir + CoreConstants.FILE_SEPARATOR + logFileName; + + serverUtil.getFileFromServer(brick.getServerName(), logFilePath, tempDirPath); + + String fetchedLogFile = tempDirPath + File.separator + logFileName; + // append log file name with server name so that log files don't overwrite each other + // in cases where the brick log file names are same on multiple servers + String localLogFile = tempDirPath + File.separator + brick.getServerName() + "-" + logFileName; + + FileUtil.renameFile(fetchedLogFile, localLogFile); + } + + String gzipPath = FileUtil.getTempDirName() + CoreConstants.FILE_SEPARATOR + volume.getName() + "-logs.tar.gz"; + ProcessUtil.executeCommand("tar", "czvf", gzipPath, "-C", tempDir.getParent(), tempDir.getName()); + + // delete the temp directory + FileUtil.recursiveDelete(tempDir); + + return gzipPath; + } + + public List getLogs(String clusterName, String volumeName, String brickName, String severity, + String fromTimestamp, String toTimestamp, Integer lineCount) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + if (lineCount == null || lineCount == 0) { + lineCount = 100; + } + + List logMessages = null; + Volume volume = getVolume(clusterName, volumeName); + + if (brickName == null || brickName.isEmpty() || brickName.equals(CoreConstants.ALL)) { + logMessages = getLogsForAllBricks(volume, lineCount); + } else { + // fetch logs for given brick of the volume + for (Brick brick : volume.getBricks()) { + if (brick.getQualifiedName().equals(brickName)) { + logMessages = getBrickLogs(volume, brick, lineCount); + break; + } + } + } + + filterLogsBySeverity(logMessages, severity); + filterLogsByTime(logMessages, fromTimestamp, toTimestamp); + return logMessages; + } + + private void filterLogsByTime(List logMessages, String fromTimestamp, String toTimestamp) { + Date fromTime = null, toTime = null; + + if (fromTimestamp != null && !fromTimestamp.isEmpty()) { + fromTime = DateUtil.stringToDate(fromTimestamp); + } + + if (toTimestamp != null && !toTimestamp.isEmpty()) { + toTime = DateUtil.stringToDate(toTimestamp); + } + + List messagesToRemove = new ArrayList(); + for (VolumeLogMessage logMessage : logMessages) { + Date logTimestamp = logMessage.getTimestamp(); + if (fromTime != null && logTimestamp.before(fromTime)) { + messagesToRemove.add(logMessage); + continue; + } + + if (toTime != null && logTimestamp.after(toTime)) { + messagesToRemove.add(logMessage); + } + } + logMessages.removeAll(messagesToRemove); + } + + private void filterLogsBySeverity(List logMessages, String severity) { + if (severity == null || severity.isEmpty()) { + return; + } + + List messagesToRemove = new ArrayList(); + for (VolumeLogMessage logMessage : logMessages) { + if (!logMessage.getSeverity().equals(severity)) { + messagesToRemove.add(logMessage); + } + } + logMessages.removeAll(messagesToRemove); + } + + private List getLogsForAllBricks(Volume volume, Integer lineCount) { + List logMessages; + logMessages = new ArrayList(); + // fetch logs for every brick of the volume + for (Brick brick : volume.getBricks()) { + logMessages.addAll(getBrickLogs(volume, brick, lineCount)); + } + + // Sort the log messages based on log timestamp + Collections.sort(logMessages, new Comparator() { + @Override + public int compare(VolumeLogMessage message1, VolumeLogMessage message2) { + return message1.getTimestamp().compareTo(message2.getTimestamp()); + } + }); + + return logMessages; + } + + private List getBrickLogs(Volume volume, Brick brick, Integer lineCount) + throws GlusterRuntimeException { + String logDir = glusterUtil.getLogLocation(volume.getName(), brick.getQualifiedName(), brick.getServerName()); + String logFileName = glusterUtil.getLogFileNameForBrickDir(brick.getServerName(), brick.getBrickDirectory()); + String logFilePath = logDir + CoreConstants.FILE_SEPARATOR + logFileName; + + // Usage: get_volume_disk_log.py + LogMessageListResponse response = serverUtil.executeScriptOnServer(brick.getServerName(), + VOLUME_BRICK_LOG_SCRIPT + " " + logFilePath + " " + lineCount, LogMessageListResponse.class); + + // populate disk and trim other fields + List logMessages = response.getLogMessages(); + for (VolumeLogMessage logMessage : logMessages) { + logMessage.setBrick(brick.getQualifiedName()); + } + return logMessages; + } + + public String migrateBrickStart(String clusterName, String volumeName, String fromBrick, String toBrick, + Boolean autoCommit) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty!"); + } + + if (fromBrick == null || fromBrick.isEmpty()) { + throw new GlusterValidationException("From brick must not be empty!"); + } + + if (toBrick == null || toBrick.isEmpty()) { + throw new GlusterValidationException("To brick must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + if(autoCommit == null) { + autoCommit = false; + } + + MigrateBrickTask migrateDiskTask = new MigrateBrickTask(clusterService, clusterName, volumeName, fromBrick, + toBrick); + migrateDiskTask.setAutoCommit(autoCommit); + migrateDiskTask.start(); + taskResource.addTask(clusterName, migrateDiskTask); + return migrateDiskTask.getTaskInfo().getName(); // Return Task ID + } + + private String getLayout(Boolean isFixLayout, Boolean isMigrateData, + Boolean isForcedDataMigrate) { + String layout = ""; + if (isForcedDataMigrate) { + layout = "forced-data-migrate"; + } else if (isMigrateData) { + layout = "migrate-data"; + } else if (isFixLayout) { + layout = "fix-layout"; + } + return layout; + } + + public String rebalanceStart(String clusterName, String volumeName, Boolean isFixLayout, Boolean isMigrateData, + Boolean isForcedDataMigrate) { + RebalanceVolumeTask rebalanceTask = new RebalanceVolumeTask(clusterService, clusterName, volumeName, getLayout( + isFixLayout, isMigrateData, isForcedDataMigrate)); + rebalanceTask.start(); + taskResource.addTask(clusterName, rebalanceTask); + return rebalanceTask.getId(); + } + + public void rebalanceStop(String clusterName, String volumeName) { + // TODO: arrive at the task id and fetch it + String taskId = ""; + + taskResource.getTask(clusterName, taskId).stop(); + } + + public void startVolume(String clusterName, GlusterServer onlineServer, Volume volume, Boolean force) { + glusterUtil.startVolume(volume.getName(), onlineServer.getName(), force); + + // call the start_volume_cifs.py script only if the volume is cifs enabled + if (volume.isCifsEnable()) { + startCifsReExport(clusterName, volume.getName()); + } + } + + public void stopVolume(String clusterName, GlusterServer onlineServer, Volume volume, Boolean force) { + glusterUtil.stopVolume(volume.getName(), onlineServer.getName(), force); + + // call the stop_volume_cifs.py script only if the volume is cifs enabled + if (volume.isCifsEnable()) { + stopCifsReExport(clusterName, volume.getName()); + } + } + + public void logRotate(String clusterName, String volumeName, List brickList) { + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + try { + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + glusterUtil.logRotate(volumeName, brickList, onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + glusterUtil.logRotate(volumeName, brickList, onlineServer.getName()); + } else { + throw new GlusterRuntimeException("Volume [" + volumeName + "] log rotation failed!", e); + } + } + } + + public void performVolumeOperation(String clusterName, String volumeName, String operation, Boolean force) { + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + try { + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + performOperation(clusterName, volumeName, operation, onlineServer, force); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + performOperation(clusterName, volumeName, operation, onlineServer, force); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void performOperation(String clusterName, String volumeName, String operation, GlusterServer onlineServer, + Boolean force) { + Volume volume = null; + try { + volume = getVolume(clusterName, volumeName); + } catch (Exception e) { + throw new GlusterRuntimeException("Could not fetch volume info for volume [" + volumeName + "]" + + e.getMessage()); + } + + if (operation.equals(TASK_START)) { + startVolume(clusterName, onlineServer, volume, force); + } else if (operation.equals(TASK_STOP)) { + stopVolume(clusterName, onlineServer, volume, force); + } else { + throw new GlusterValidationException("Invalid operation code [" + operation + "]"); + } + } + + public void removeBricksFromVolume(String clusterName, String volumeName, String bricks, Boolean deleteFlag) { + // Convert from comma separated string (query parameter) + List brickList = Arrays.asList(bricks.split(",")); + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if (volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty!"); + } + + if (bricks == null || bricks.isEmpty()) { + throw new GlusterValidationException("Parameter [" + QUERY_PARAM_BRICKS + "] is missing in request!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + if(deleteFlag == null) { + deleteFlag = false; + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + removeBricks(clusterName, volumeName, brickList, onlineServer); + cleanupDirectories(brickList, volumeName, brickList.size(), deleteFlag); + } + + private void removeBricks(String clusterName, String volumeName, List brickList, GlusterServer onlineServer) { + try { + glusterUtil.removeBricks(volumeName, brickList, onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterUtil.removeBricks(volumeName, brickList, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void cleanupDirectories(List bricks, String volumeName, int maxIndex, boolean deleteFlag) { + String errors = ""; + for (int i = 0; i < maxIndex; i++) { + String[] brickInfo = bricks.get(i).split(":"); + String serverName = brickInfo[0]; + String brickDirectory = brickInfo[1]; + + try { + serverUtil.executeScriptOnServer(serverName, VOLUME_DIRECTORY_CLEANUP_SCRIPT + " " + + brickDirectory + " " + (deleteFlag ? "-d" : "")); + } catch(Exception e) { + logger.error("Error while cleaning brick [" + serverName + ":" + brickDirectory + "] of volume [" + + volumeName + "] : " + e.getMessage(), e); + errors += "[" + brickDirectory + "] => " + e.getMessage() + CoreConstants.NEWLINE; + } + } + if(!errors.trim().isEmpty()) { + throw new GlusterRuntimeException("Volume directory cleanup errors: " + errors.trim()); + } + } + + public void deleteVolume(String clusterName, String volumeName, Boolean deleteFlag) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty"); + } + + if (volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if(onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + if (deleteFlag == null) { + deleteFlag = false; + } + + Volume volume = getVolume(clusterName, volumeName); + + List bricks = volume.getBricks(); + glusterUtil.deleteVolume(volumeName, onlineServer.getName()); + + try { + postDelete(volumeName, bricks, deleteFlag); + if (volume.isCifsEnable()) { + if (volume.getStatus() == VOLUME_STATUS.ONLINE) { + stopCifsReExport(clusterName, volumeName); + } + deleteCifsUsers(clusterName, volumeName); + } + } catch(Exception e) { + throw new GlusterRuntimeException("Volume [" + volumeName + + "] deleted from cluster, however following error(s) occurred: " + CoreConstants.NEWLINE + + e.getMessage()); + } + } + + private void postDelete(String volumeName, List bricks, boolean deleteFlag) { + for (Brick brick : bricks) { + String brickDirectory = brick.getBrickDirectory(); + // String mountPoint = brickDirectory.substring(0, brickDirectory.lastIndexOf("/")); + + serverUtil.executeScriptOnServer(brick.getServerName(), VOLUME_DIRECTORY_CLEANUP_SCRIPT + " " + + brickDirectory + " " + (deleteFlag ? "-d" : "")); + } + } + + public void resetVolumeOptions(String clusterName, String volumeName) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if(volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + try { + glusterUtil.resetOptions(volumeName, onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + glusterUtil.resetOptions(volumeName, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + + } + } + + public void setVolumeOption(String clusterName, String volumeName, String key, String value) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + if(volumeName == null || volumeName.isEmpty()) { + throw new GlusterValidationException("Volume name must not be empty!"); + } + + if(key == null || key.isEmpty()) { + throw new GlusterValidationException("Option key must not be empty!"); + } + + if(value == null || value.isEmpty()) { + throw new GlusterValidationException("Option value must not be empty!"); + } + + if (clusterService.getCluster(clusterName) == null) { + throw new GlusterRuntimeException("Cluster [" + clusterName + "] not found!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + try { + glusterUtil.setOption(volumeName, key, value, onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + // online server has gone offline! try with a different one. + onlineServer = clusterService.getNewOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + glusterUtil.setOption(volumeName, key, value, onlineServer.getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + public VolumeOptionInfoListResponse getVolumeOptionsInfo(String clusterName) { + if (clusterName == null || clusterName.isEmpty()) { + throw new GlusterValidationException("Cluster name must not be empty!"); + } + + ClusterInfo cluster = clusterService.getCluster(clusterName); + if (cluster == null) { + throw new GlusterValidationException("Cluster [" + clusterName + "] not found!"); + } + + if(cluster.getServers().isEmpty()) { + throw new GlusterValidationException("Cluster [" + clusterName + "] is empty! Can't fetch Volume Options Information!"); + } + + GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); + if (onlineServer == null) { + throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); + } + + try { + return glusterUtil.getVolumeOptionsInfo(onlineServer.getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { + onlineServer = clusterService.getNewOnlineServer(clusterName); + return glusterUtil.getVolumeOptionsInfo(onlineServer.getName()); + } else { + throw new GlusterRuntimeException("Fetching volume options info failed! [" + e.getMessage() + "]"); + } + } + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitServerTask.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitServerTask.java new file mode 100644 index 00000000..3193d926 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitServerTask.java @@ -0,0 +1,161 @@ +/** + * GlusterServerInitializer.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.tasks; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.servlet.ServletContext; + +import org.apache.derby.tools.ij; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.data.PersistenceDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.jdbc.core.support.JdbcDaoSupport; +import org.springframework.security.authentication.dao.SaltSource; +import org.springframework.security.authentication.encoding.PasswordEncoder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; + + +/** + * Initializes the Gluster Management Server. + */ +public class InitServerTask extends JdbcDaoSupport { + @Autowired + private PasswordEncoder passwordEncoder; + + @Autowired + private SaltSource saltSource; + + @Autowired + private UserDetailsService userDetailsService; + + @Autowired + private String appVersion; + + @Autowired + private PersistenceDao clusterDao; + + @Autowired + ServletContext servletContext; + + private static final String SCRIPT_DIR = "data/scripts/"; + + public void securePasswords() { + getJdbcTemplate().query("select username, password from users", new RowCallbackHandler() { + @Override + public void processRow(ResultSet rs) throws SQLException { + String username = rs.getString(1); + String password = rs.getString(2); + UserDetails user = userDetailsService.loadUserByUsername(username); + + String encodedPassword = passwordEncoder.encodePassword(password, saltSource.getSalt(user)); + getJdbcTemplate().update("update users set password = ? where username = ?", encodedPassword, username); + logger.debug("Updating password for username: " + username); + } + }); + } + + private void executeScript(File script) { + ByteArrayOutputStream sqlOut = new ByteArrayOutputStream(); + int numOfExceptions; + try { + numOfExceptions = ij.runScript(getJdbcTemplate().getDataSource().getConnection(), new FileInputStream( + script), CoreConstants.ENCODING_UTF8, sqlOut, CoreConstants.ENCODING_UTF8); + String output = sqlOut.toString(); + sqlOut.close(); + logger.debug("Data script [" + script.getName() + "] returned with exit status [" + numOfExceptions + + "] and output [" + output + "]"); + if (numOfExceptions != 0) { + throw new GlusterRuntimeException("Server data initialization script [ " + script.getName() + + "] failed with [" + numOfExceptions + "] exceptions! [" + output + "]"); + } + } catch (Exception ex) { + throw new GlusterRuntimeException("Server data initialization script [" + script.getName() + "] failed!", + ex); + } + } + + private void initDatabase() { + logger.info("Initializing server data..."); + executeScriptsFrom(getDirFromRelativePath(SCRIPT_DIR + appVersion)); + + securePasswords(); // encrypt the passwords + } + + private File getDirFromRelativePath(String relativePath) { + String scriptDirPath = servletContext.getRealPath(relativePath); + File scriptDir = new File(scriptDirPath); + return scriptDir; + } + + private void executeScriptsFrom(File scriptDir) { + if (!scriptDir.exists()) { + throw new GlusterRuntimeException("Script directory [" + scriptDir.getAbsolutePath() + "] doesn't exist!"); + } + + List scripts = Arrays.asList(scriptDir.listFiles()); + if(scripts.size() == 0) { + throw new GlusterRuntimeException("Script directory [" + scriptDir.getAbsolutePath() + "] is empty!"); + } + + Collections.sort(scripts); + for (File script : scripts) { + executeScript(script); + } + } + + /** + * Initializes the server database, if running for the first time. + */ + public synchronized void initServer() { + try { + String dbVersion = getDBVersion(); + if (!appVersion.equals(dbVersion)) { + logger.info("App version [" + appVersion + "] differs from data version [" + dbVersion + + "]. Trying to upgrade data..."); + upgradeData(dbVersion, appVersion); + } + } catch (Exception ex) { + logger.info("No cluster created yet. DB version query failed with error [" + ex.getMessage() + "]", ex); + // Database not created yet. Create it! + initDatabase(); + } + } + + private void upgradeData(String fromVersion, String toVersion) { + executeScriptsFrom(getDirFromRelativePath(SCRIPT_DIR + fromVersion + "-" + toVersion)); + } + + private String getDBVersion() { + return (String) clusterDao.getSingleResultFromSQL("select version from version"); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitializeDiskTask.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitializeDiskTask.java new file mode 100644 index 00000000..45be980a --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/InitializeDiskTask.java @@ -0,0 +1,198 @@ +/** + * InitializeDiskTask.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.tasks; + +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.model.InitDiskStatusResponse; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.InitDiskStatusResponse.FORMAT_STATUS; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.context.ApplicationContext; +import org.springframework.web.context.ContextLoader; + +import com.sun.jersey.core.util.Base64; + +public class InitializeDiskTask extends Task { + + private static final String INITIALIZE_DISK_SCRIPT = "format_device.py"; + private static final String INITIALIZE_DISK_STATUS_SCRIPT = "get_format_device_status.py"; + + private String serverName; + private String diskName; + private String fsType; + private String mountPoint; + private ServerUtil serverUtil; + + public InitializeDiskTask(ClusterService clusterService, String clusterName, String serverName, String diskName, + String fsType, String mountPoint) { + // Reference contains "Server:disk" + super(clusterService, clusterName, TASK_TYPE.DISK_FORMAT, serverName + ":" + diskName, "Initialize disk " + + serverName + ":" + diskName, false, false, false); + + setServerName(serverName); + setDiskName(diskName); + setFsType(fsType); + setMountpoint(mountPoint); + taskInfo.setName(getId()); + init(); + } + + public InitializeDiskTask(ClusterService clusterService, String clusterName, TaskInfo info) { + super(clusterService, clusterName, info); + init(); + } + + private void init() { + ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); + serverUtil = ctx.getBean(ServerUtil.class); + } + + @Override + public String getId() { + return new String( + Base64.encode(getClusterName() + "-" + taskInfo.getType() + "-" + serverName + ":" + diskName)); + } + + @Override + public void resume() { + getTaskInfo().setStatus( + new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, + "Stop/Pause/Resume is not supported in Disk Initialization"))); + } + + @Override + public void stop() { + getTaskInfo().setStatus( + new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, + "Stop/Pause/Resume is not supported in Disk Initialization"))); + } + + @Override + public void pause() { + getTaskInfo().setStatus( + new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, + "Stop/Pause/Resume is not supported in Disk Initialization"))); + } + + @Override + public void commit() { + // TODO Auto-generated method stub + } + + @Override + public TASK_TYPE getType() { + return TASK_TYPE.DISK_FORMAT; + } + + + @Override + public void start() { + try { + startInitializeDisk(serverName); + } catch(ConnectionException e) { + // online server might have gone offline. update the failure status + getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); + } + } + + private void startInitializeDisk(String serverName) { + String output = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_SCRIPT + " " + getFsType() + " \"" + + getMountpoint() + "\" " + getDiskName() ); + TaskStatus taskStatus = new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, output)); + taskStatus.setPercentageSupported((getFsType().equals(GlusterConstants.FSTYPE_XFS)) ? false : true); + getTaskInfo().setStatus(taskStatus); + } + + @Override + public TaskStatus checkStatus() { + + try { + return getInitializingDeviceStatus(serverName, getDiskName()); + } catch(ConnectionException e) { + // online server might have gone offline. update the failure status + return new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage())); + } + } + + private TaskStatus getInitializingDeviceStatus(String serverName, String diskName) { + InitDiskStatusResponse initDiskStatusResponse; + TaskStatus taskStatus = new TaskStatus(); + + try { + initDiskStatusResponse = serverUtil.executeScriptOnServer(serverName, INITIALIZE_DISK_STATUS_SCRIPT + " " + + diskName, InitDiskStatusResponse.class); + } catch(RuntimeException e) { + taskStatus.setCode(Status.STATUS_CODE_FAILURE); + taskStatus.setMessage(e.getMessage()); + throw e; + } + + if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.COMPLETED) { + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + } else if (initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.IN_PROGRESS) { + taskStatus.setCode(Status.STATUS_CODE_RUNNING); + taskStatus.setPercentCompleted(Math.round(initDiskStatusResponse.getCompletedBlocks() + / initDiskStatusResponse.getTotalBlocks() * 100)); + } else if(initDiskStatusResponse.getFormatStatus() == FORMAT_STATUS.NOT_RUNNING) { + taskStatus.setCode(Status.STATUS_CODE_FAILURE); + } + + taskStatus.setMessage(initDiskStatusResponse.getMessage()); + return taskStatus; + } + + public void setDiskName(String diskName) { + this.diskName = diskName; + } + + public String getDiskName() { + return diskName; + } + + public void setServerName(String serverName) { + this.serverName = serverName; + } + + public String getServerName() { + return serverName; + } + + public void setFsType(String fsType) { + this.fsType = fsType; + } + + public String getFsType() { + return fsType; + } + + public void setMountpoint(String deviceMountPoint) { + this.mountPoint = deviceMountPoint; + } + + public String getMountpoint() { + return mountPoint; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/MigrateBrickTask.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/MigrateBrickTask.java new file mode 100644 index 00000000..8a31f9a9 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/MigrateBrickTask.java @@ -0,0 +1,220 @@ +/** + * MigrateDiskTask.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.tasks; + +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.gluster.storage.management.gateway.services.GlusterInterfaceService; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.context.ApplicationContext; +import org.springframework.web.context.ContextLoader; + +import com.sun.jersey.core.util.Base64; + +public class MigrateBrickTask extends Task { + + private String fromBrick; + private String toBrick; + private Boolean autoCommit; + private GlusterInterfaceService glusterInterface; + protected ServerUtil serverUtil; + + public String getFromBrick() { + return fromBrick; + } + + public void setFromBrick(String fromBrick) { + this.fromBrick = fromBrick; + } + + public String getToBrick() { + return toBrick; + } + + public void setToBrick(String toBrick) { + this.toBrick = toBrick; + } + + public Boolean getAutoCommit() { + return autoCommit; + } + + public void setAutoCommit(Boolean autoCommit) { + this.autoCommit = autoCommit; + } + + public MigrateBrickTask(ClusterService clusterService, String clusterName, String volumeName, String fromBrick, + String toBrick) { + super(clusterService, clusterName, TASK_TYPE.BRICK_MIGRATE, volumeName + "#" + fromBrick + "#" + toBrick, + "Brick Migration on volume [" + volumeName + "] from [" + fromBrick + "] to [" + toBrick + "]", true, + true, true); + setFromBrick(fromBrick); + setToBrick(toBrick); + taskInfo.setName(getId()); + init(); + } + + private void init() { + ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); + glusterInterface = ctx.getBean(GlusterInterfaceService.class); + serverUtil = ctx.getBean(ServerUtil.class); + } + + @Override + public String getId() { + return new String(Base64.encode(clusterName + "-" + taskInfo.getType() + "-" + taskInfo.getReference() + "-" + fromBrick + "-" + + toBrick)); + } + + @Override + public void start() { + try { + startMigration(getOnlineServer().getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone Offline. try with a new one. + startMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void startMigration(String onlineServerName) { + String volumeName = getTaskInfo().getReference().split("#")[0]; + glusterInterface.startBrickMigration(onlineServerName, volumeName, getFromBrick(), getToBrick()); + getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, "Brick Migration Started."))); + } + + @Override + public void pause() { + try { + pauseMigration(getOnlineServer().getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. try with a new one. + pauseMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void pauseMigration(String onlineServer) { + String volumeName = getTaskInfo().getReference().split("#")[0]; + glusterInterface.pauseBrickMigration(onlineServer, volumeName, getFromBrick(), getToBrick()); + TaskStatus taskStatus = new TaskStatus(); + taskStatus.setCode(Status.STATUS_CODE_PAUSE); + taskStatus.setMessage("Brick Migration Paused"); + getTaskInfo().setStatus(taskStatus); + } + + @Override + public void resume() { + start(); + } + + @Override + public void commit() { + try { + commitMigration(getOnlineServer().getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. try with a new one. + commitMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void commitMigration(String serverName) { + String volumeName = getTaskInfo().getReference().split("#")[0]; + glusterInterface.commitBrickMigration(serverName, volumeName, getFromBrick(), getToBrick()); + TaskStatus taskStatus = new TaskStatus(); + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + taskStatus.setMessage("Brick Migration Committed."); + getTaskInfo().setStatus(taskStatus); + } + + @Override + public void stop() { + try { + stopMigration(getOnlineServer().getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. try with a new one. + stopMigration(getNewOnlineServer().getName()); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void stopMigration(String serverName) { + String volumeName = getTaskInfo().getReference().split("#")[0]; + glusterInterface.stopBrickMigration(serverName, volumeName, getFromBrick(), getToBrick()); + TaskStatus taskStatus = new TaskStatus(); + taskStatus.setCode(Status.STATUS_CODE_SUCCESS); + taskStatus.setMessage("Brick Migration Stopped"); + getTaskInfo().setStatus(taskStatus); + } + + @Override + public TaskStatus checkStatus() { + try { + return checkMigrationStatus(getOnlineServer().getName()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. try with a new one. + return checkMigrationStatus(getNewOnlineServer().getName()); + } + } + return null; + } + + private TaskStatus checkMigrationStatus(String serverName) { + // For committed task, status command (CLI) is invalid, just return current status + if (taskInfo.getStatus().getCode() == Status.STATUS_CODE_SUCCESS) { + return taskInfo.getStatus(); + } + + String volumeName = getTaskInfo().getReference().split("#")[0]; + TaskStatus taskStatus = glusterInterface.checkBrickMigrationStatus(serverName, volumeName, getFromBrick(), + getToBrick()); + if (autoCommit && taskStatus.isCommitPending()) { + commitMigration(serverName); + return taskInfo.getStatus(); // return the committed status + } + + taskInfo.setStatus(taskStatus); // Update the task status + return taskStatus; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java new file mode 100644 index 00000000..288179e9 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/RebalanceVolumeTask.java @@ -0,0 +1,141 @@ +/** + * RebalanceVolumeTask.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.tasks; + +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.gluster.storage.management.gateway.services.GlusterInterfaceService; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.context.ApplicationContext; +import org.springframework.web.context.ContextLoader; + +import com.sun.jersey.core.util.Base64; + +public class RebalanceVolumeTask extends Task { + + private String layout; + private String serverName; + private ServerUtil serverUtil; + private GlusterInterfaceService glusterUtil; + + public RebalanceVolumeTask(ClusterService clusterService, String clusterName, String volumeName, String layout) { + super(clusterService, clusterName, TASK_TYPE.VOLUME_REBALANCE, volumeName, "Volume " + volumeName + + " Rebalance", false, true, false); + setLayout(layout); + taskInfo.setName(getId()); + init(); + } + + private void init() { + ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); + serverUtil = ctx.getBean(ServerUtil.class); + glusterUtil = ctx.getBean(GlusterInterfaceService.class); + } + + @Override + public String getId() { + return new String(Base64.encode(getClusterName() + "-" + taskInfo.getType() + "-" + taskInfo.getReference())); + } + + @Override + public void start() { + try { + serverName = getOnlineServer().getName(); + startRebalance(serverName); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. try with a new one + serverName = getNewOnlineServer().getName(); + startRebalance(serverName); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + private void startRebalance(String serverName) { + String command = "gluster volume rebalance " + getTaskInfo().getReference() + " " + getLayout() + " start"; + String output = serverUtil.executeOnServer(serverName, command); + getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_RUNNING, output))); + } + + @Override + public void resume() { + getTaskInfo().setStatus( + new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, + "Pause/Resume is not supported in Volume Rebalance"))); + } + + @Override + public void stop() { + try { + glusterUtil.stopRebalance(serverName, getTaskInfo().getReference()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. update the failure status + getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); + } else { + throw new GlusterRuntimeException(e.getMessage()); + } + } + } + + @Override + public void pause() { + getTaskInfo().setStatus( + new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, + "Pause/Resume is not supported in Volume Rebalance"))); + } + + @Override + public TaskStatus checkStatus() { + try { + return glusterUtil.checkRebalanceStatus(serverName, getTaskInfo().getReference()); + } catch (Exception e) { + // check if online server has gone offline. If yes, try again one more time. + if (e instanceof ConnectionException || serverUtil.isServerOnline(getOnlineServer()) == false) { + // online server might have gone offline. update the failure status + getTaskInfo().setStatus(new TaskStatus(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()))); + return getTaskInfo().getStatus(); + } + } + return null; + } + + public void setLayout(String layout) { + this.layout = layout; + } + + public String getLayout() { + return layout; + } + + @Override + public void commit() { + // TODO Auto-generated method stub + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/ServerSyncTask.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/ServerSyncTask.java new file mode 100644 index 00000000..c3073d97 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/ServerSyncTask.java @@ -0,0 +1,168 @@ +/** + * ServerDiscoveryTask.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.tasks; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.constants.GlusterConstants; +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.utils.GlusterCoreUtil; +import org.gluster.storage.management.core.utils.ProcessResult; +import org.gluster.storage.management.gateway.data.ClusterInfo; +import org.gluster.storage.management.gateway.data.PersistenceDao; +import org.gluster.storage.management.gateway.data.ServerInfo; +import org.gluster.storage.management.gateway.services.ClusterService; +import org.gluster.storage.management.gateway.services.DiscoveredServerService; +import org.gluster.storage.management.gateway.services.GlusterServerService; +import org.gluster.storage.management.gateway.utils.ServerUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * Task for syncing server details. This performs two things:
    + * 1. Auto-discovery of servers eligible to be added to the Gluster cluster.
    + * 2. Syncing of cluster-server mapping with actual servers of the cluster. This mapping can go out of sync if user + * adds/removes servers manually using the CLI. + */ +@Component +public class ServerSyncTask { + private static final String SCRIPT_NAME_SFX = "-discover-servers.py"; + + @Autowired + private ServerUtil serverUtil; + + @Autowired + private DiscoveredServerService discoveredServersService; + + @Autowired + private GlusterServerService glusterServerService; + + @Autowired + private String discoveryMechanism; + + @Autowired + private ClusterService clusterService; + + @Autowired + private PersistenceDao clusterDao; + + private static final Logger logger = Logger.getLogger(ServerSyncTask.class); + + public void perform() { + discoverServers(); + syncClusterServerMapping(); + } + + private void syncClusterServerMapping() { + List clusters = clusterService.getAllClusters(); + for(ClusterInfo cluster : clusters) { + try { + List servers = cluster.getServers(); + if(servers.isEmpty()) { + logger.info("Cluster [" + cluster.getName() + "] is empty, nothing to sync!"); + continue; + } + List actualServers = glusterServerService.getGlusterServers(cluster.getName(), false, + null, null); + updateRemovedServers(cluster, servers, actualServers); + updateAddedServers(cluster, servers, actualServers); + } catch(Exception e) { + // log error and continue with next cluster + logger.error("Couldn't sync cluster-server mapping for cluster [" + cluster.getName() + "]!", e); + continue; + } + } + } + + private void updateAddedServers(ClusterInfo cluster, List servers, List actualServers) { + List addedServers = findAddedServers(cluster.getName(), servers, actualServers); + for(String addedServer : addedServers) { + clusterService.mapServerToCluster(cluster.getName(), addedServer); + } + } + + private void updateRemovedServers(ClusterInfo cluster, List servers, List actualServers) { + List removedServers = findRemovedServers(servers, actualServers); + for(String removedServer : removedServers) { + clusterService.unmapServerFromCluster(cluster.getName(), removedServer); + } + } + + private List findRemovedServers(List servers, List actualServers) { + List removedServers = new ArrayList(); + + for(ServerInfo server : servers) { + if (!GlusterCoreUtil.containsEntityWithName(actualServers, server.getName(), true)) { + removedServers.add(server.getName()); + } + } + return removedServers; + } + + private List findAddedServers(String clusterName, List servers, List actualServers) { + List addedServers = new ArrayList(); + for(GlusterServer actualServer : actualServers) { + if(!serverExists(servers, actualServer.getName())) { + addedServers.add(actualServer.getName()); + } + } + return addedServers; + } + + private boolean serverExists(List servers, String name) { + for(ServerInfo server : servers) { + if(server.getName().equalsIgnoreCase(name)) { + return true; + } + } + return false; + } + + @SuppressWarnings("unchecked") + private void discoverServers() { + if(discoveryMechanism.equals(GlusterConstants.NONE)) { + return; + } + + List serverNameList = new ArrayList(); + + ProcessResult result = serverUtil.executeGlusterScript(true, discoveryMechanism + SCRIPT_NAME_SFX, new ArrayList()); + if(result.isSuccess()) { + List existingServers = clusterDao.findBySQL("select name from server_info"); + String serverNames = result.getOutput(); + String[] parts = serverNames.split(CoreConstants.NEWLINE); + for(String serverName : parts) { + // The server discovery mechanism will return every server that has not been "peer probed". However we + // need to filter out those servers that are the "first" server of a new cluster, and hence are still + // not peer probed. + if(!existingServers.contains(serverName)) { + serverNameList.add(serverName); + } + } + } + + discoveredServersService.setDiscoveredServerNames(serverNameList); + } +} \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/Task.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/Task.java new file mode 100644 index 00000000..0fee3c2e --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/tasks/Task.java @@ -0,0 +1,113 @@ +/** + * Task.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.tasks; + +import org.gluster.storage.management.core.model.GlusterServer; +import org.gluster.storage.management.core.model.TaskInfo; +import org.gluster.storage.management.core.model.TaskStatus; +import org.gluster.storage.management.core.model.TaskInfo.TASK_TYPE; +import org.gluster.storage.management.gateway.services.ClusterService; + + +public abstract class Task { + public String[] TASK_TYPE_STR = { "Format Disk", "Migrate Brick", "Volume Rebalance" }; + + protected TaskInfo taskInfo; + protected String clusterName; + private ClusterService clusterService; + + public Task(ClusterService clusterService, String clusterName, TASK_TYPE type, String reference, String desc, + boolean canPause, boolean canStop, boolean canCommit) { + TaskInfo taskInfo = new TaskInfo(); + taskInfo.setType(type); + taskInfo.setReference(reference); + taskInfo.setDescription(desc); + taskInfo.setPauseSupported(canPause); + taskInfo.setStopSupported(canStop); + taskInfo.setCommitSupported(canCommit); + + init(clusterService, clusterName, taskInfo); + + } + + public Task(ClusterService clusterService, String clusterName, TaskInfo taskInfo) { + init(clusterService, clusterName, taskInfo); + } + + private void init(ClusterService clusterService, String clusterName, TaskInfo taskInfo) { + this.clusterService = clusterService; + setClusterName(clusterName); + setTaskInfo(taskInfo); + } + + protected GlusterServer getOnlineServer() { + return clusterService.getOnlineServer(clusterName); + } + + protected GlusterServer getNewOnlineServer() { + return clusterService.getNewOnlineServer(clusterName); + } + + protected GlusterServer getNewOnlineServer(String exceptServerName) { + return clusterService.getNewOnlineServer(clusterName, exceptServerName); + } + + public String getTypeStr() { + return TASK_TYPE_STR[taskInfo.getType().ordinal()]; + } + + public TASK_TYPE getType() { + return getTaskInfo().getType(); + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + public TaskInfo getTaskInfo() { + return taskInfo; + } + + public void setTaskInfo(TaskInfo info) { + this.taskInfo = info; + } + + public abstract String getId(); + + public abstract void start(); + + public abstract void resume(); + + public abstract void stop(); + + public abstract void pause(); + + public abstract void commit(); + + /** + * This method should check current status of the task and update it's taskInfo accordingly + */ + public abstract TaskStatus checkStatus(); +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/AbstractStatsFactory.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/AbstractStatsFactory.java new file mode 100644 index 00000000..ebc1ccba --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/AbstractStatsFactory.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.ServerStatsRow; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +public abstract class AbstractStatsFactory implements StatsFactory { + @Autowired + protected ServerUtil serverUtil; + + private Logger logger = Logger.getLogger(AbstractStatsFactory.class); + + protected ServerStats getFirstOnlineServerStats(List serverNames, String period, + boolean removeServerOnError, boolean removeOnlineServer) { + for(int i = serverNames.size() - 1; i >= 0; i--) { + String serverName = serverNames.get(i); + try { + ServerStats stats = fetchStats(serverName, period); + if(removeOnlineServer) { + serverNames.remove(serverName); + } + return stats; + } catch(Exception e) { + // server might be offline - continue with next one + logger.warn("Couldn't fetch stats from server [" + serverName + "]!", e); + if(removeServerOnError) { + serverNames.remove(serverName); + } + continue; + } + } + throw new GlusterRuntimeException("All servers offline!"); + } + + protected void aggregateStats(List serverNames, ServerStats aggregatedStats, String period) { + if(serverNames.isEmpty()) { + return; + } + + int rowCount = aggregatedStats.getMetadata().getRowCount(); + int columnCount = aggregatedStats.getMetadata().getLegend().size(); + int[][] dataCount = initDataCountArray(rowCount, columnCount); + + List allStats = serverUtil.executeScriptOnServers(serverNames, getStatsScriptName() + " " + period, ServerStats.class, false); + + for (ServerStats stats : allStats) { + // add to aggregated stats + addServerStats(stats, aggregatedStats, dataCount); + } + + averageAggregatedStats(aggregatedStats, dataCount); + } + + /** + * + * @param statsToBeAdded + * @param targetStats + * @param dataCount Each element of this matrix will be incremented for every valid element added + * @return + */ + protected List addServerStats(ServerStats statsToBeAdded, ServerStats targetStats, int[][] dataCount) { + List serverStatsRows = statsToBeAdded.getRows(); + for (int rowNum = 0; rowNum < serverStatsRows.size() && rowNum < targetStats.getMetadata().getRowCount() + && rowNum < dataCount.length; rowNum++) { + ServerStatsRow row = serverStatsRows.get(rowNum); + List rowData = row.getUsageData(); + + List aggregatedStatsRowData = targetStats.getRows().get(rowNum).getUsageData(); + for(int i = 1; i < targetStats.getMetadata().getLegend().size(); i++) { + // Add the data + Double data = rowData.get(i); + if(!data.isNaN()) { + // data is available. add it. + Double oldData = aggregatedStatsRowData.get(i); + if(oldData.isNaN()) { + oldData = 0d; + } + aggregatedStatsRowData.set(i, oldData + data); + // increment record count. this will be used for calculating average of aggregated data. + dataCount[rowNum][i]++; + } + } + } + return serverStatsRows; + } + + protected void averageAggregatedStats(ServerStats aggregatedStats, int[][] dataCount) { + List rows = aggregatedStats.getRows(); + for(int rowNum = 0; rowNum < rows.size() && rowNum < dataCount.length; rowNum++) { + List data = rows.get(rowNum).getUsageData(); + for(int columnNum = 0; columnNum < data.size(); columnNum++) { + data.set(columnNum, data.get(columnNum) / dataCount[rowNum][columnNum]); + } + } + } + + protected int[][] initDataCountArray(int rowCount, int columnCount) { + int[][] dataCount = new int[rowCount][columnCount]; + // initialize all data counts to 1 + for(int rowNum = 0; rowNum < rowCount; rowNum++) { + for(int columnNum = 0; columnNum < columnCount; columnNum++) { + dataCount[rowNum][columnNum] = 1; + } + } + return dataCount; + } + + @Override + public ServerStats fetchAggregatedStats(List serverNames, String period) { + if(serverNames == null || serverNames.size() == 0) { + throw new GlusterRuntimeException("No server names passed to fetchAggregaredStats!"); + } + + ServerStats firstServerStats = getFirstOnlineServerStats(serverNames, period, true, true); + + ServerStats aggregatedStats = new ServerStats(firstServerStats); + aggregateStats(serverNames, aggregatedStats, period); + return aggregatedStats; + } + + @Override + public ServerStats fetchStats(String serverName, String period, String...args) { + String argsStr = ""; + for (String arg : args) { + if(arg != null) { + argsStr += " " + arg; + } + } + return serverUtil.executeScriptOnServer(serverName, getStatsScriptName() + argsStr + " " + period, + ServerStats.class); + } + + public abstract String getStatsScriptName(); +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/CpuStatsFactory.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/CpuStatsFactory.java new file mode 100644 index 00000000..412794eb --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/CpuStatsFactory.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import org.springframework.stereotype.Component; + +/** + * + */ +@Component +public class CpuStatsFactory extends AbstractStatsFactory { + + private static final String CPU_STATS_SCRIPT = "get_rrd_cpu_details.py"; + + @Override + public String getStatsScriptName() { + return CPU_STATS_SCRIPT; + } + +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/DBUtil.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/DBUtil.java new file mode 100644 index 00000000..1c186a0a --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/DBUtil.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; + + +/** + * + */ +public class DBUtil { + private static final Logger logger = Logger.getLogger(DBUtil.class); + public static void shutdownDerby() { + try { + // the shutdown=true attribute shuts down Derby + DriverManager.getConnection("jdbc:derby:;shutdown=true"); + + // To shut down a specific database only, but keep the + // engine running (for example for connecting to other + // databases), specify a database in the connection URL: + //DriverManager.getConnection("jdbc:derby:" + dbName + ";shutdown=true"); + } catch (Exception e) { + if(e instanceof SQLException) { + SQLException se = (SQLException) e; + if (((se.getErrorCode() == 50000) && ("XJ015".equals(se.getSQLState())))) { + // we got the expected exception + logger.info("Derby shut down normally"); + // Note that for single database shutdown, the expected + // SQL state is "08006", and the error code is 45000. + } else { + // if the error code or SQLState is different, we have + // an unexpected exception (shutdown failed) + logger.error("Derby did not shut down normally!" + inspectSQLException(se), se); + } + } else { + logger.error("Derby did not shut down normally! [" + e.getMessage() + "]", e); + } + } + // force garbage collection to unload the EmbeddedDriver + // so Derby can be restarted + System.gc(); + } + + /** + * Extracts details of an SQLException chain to String. + * Details included are SQL State, Error code, Exception message. + * + * @param e the SQLException from which to print details. + */ + private static String inspectSQLException(SQLException e) + { + // Unwraps the entire exception chain to unveil the real cause of the + // Exception. + String errMsg = ""; + while (e != null) + { + errMsg += "\n----- SQLException -----" + CoreConstants.NEWLINE + " SQL State: " + e.getSQLState() + + CoreConstants.NEWLINE + " Error Code: " + e.getErrorCode() + CoreConstants.NEWLINE + + " Message: " + e.getMessage(); + e = e.getNextException(); + } + return errMsg; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/MemoryStatsFactory.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/MemoryStatsFactory.java new file mode 100644 index 00000000..691662e6 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/MemoryStatsFactory.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import java.util.List; + +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.ServerStatsRow; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +public class MemoryStatsFactory extends AbstractStatsFactory { + + private static final String MEM_STATS_SCRIPT = "get_rrd_memory_details.py"; + + @Override + public String getStatsScriptName() { + return MEM_STATS_SCRIPT; + } + + @Override + public ServerStats fetchStats(String serverName, String period, String... args) { + ServerStats stats = super.fetchStats(serverName, period, args); + + // stats returned by rrd script contains five columns - user, free, cache, buffer, total + // out of this, the "user" memory includes cached and buffer. We remove them to get the + // actual memory used by "user" + for(ServerStatsRow row : stats.getRows()) { + List data = row.getUsageData(); + Double user = data.get(0); + Double free = data.get(1); + Double cache = data.get(2); + Double buffer = data.get(3); + Double total = data.get(4); + + Double actualUser = user - cache - buffer; + + // convert all figures from bytes to percentages + data.set(0, (actualUser * 100) / total); + data.set(1, (free * 100) / total); + data.set(2, (cache * 100) / total); + data.set(3, (buffer * 100) / total); + data.set(4, (total * 100) / total); + } + + return stats; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/NetworkStatsFactory.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/NetworkStatsFactory.java new file mode 100644 index 00000000..03c252a9 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/NetworkStatsFactory.java @@ -0,0 +1,173 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.NetworkInterface; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.ServerStats; +import org.gluster.storage.management.core.model.ServerStatsRow; +import org.gluster.storage.management.core.utils.ProcessUtil; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +public class NetworkStatsFactory extends AbstractStatsFactory { + private static final Logger logger = Logger.getLogger(NetworkStatsFactory.class); + private static final String NETWORK_STATS_SCRIPT = "get_rrd_net_details.py"; + private int[][] dataCount; + + @Override + public String getStatsScriptName() { + return NETWORK_STATS_SCRIPT; + } + + @Override + protected ServerStats getFirstOnlineServerStats(List serverNames, String period, + boolean removeServerOnError, boolean removeOnlineServer) { + ServerStats firstOnlineServerStats = null; + for(int i = serverNames.size() - 1; i >= 0; i--) { + String serverName = serverNames.get(i); + Server server = new Server(serverName); + serverUtil.fetchServerDetails(server); + if(!server.isOnline()) { + if(removeServerOnError) { + // server is offline. no point in trying to fetch it's details. + serverNames.remove(serverName); + } + continue; + } + try { + for(NetworkInterface networkInterface : server.getNetworkInterfaces()) { + ServerStats stats = fetchStats(serverName, period, networkInterface.getName()); + if(firstOnlineServerStats == null) { + firstOnlineServerStats = stats; + int rowCount = firstOnlineServerStats.getMetadata().getRowCount(); + int columnCount = firstOnlineServerStats.getMetadata().getLegend().size(); + dataCount = initDataCountArray(rowCount, columnCount); + } else { + addServerStats(stats, firstOnlineServerStats, dataCount); + } + } + + if(removeOnlineServer) { + serverNames.remove(serverName); + } + return firstOnlineServerStats; + } catch(Exception e) { + // server might be offline - continue with next one + logger.warn("Couldn't fetch stats from server [" + serverName + "]!", e); + if(removeServerOnError) { + serverNames.remove(serverName); + } + continue; + } + } + throw new GlusterRuntimeException("All servers offline!"); + } + + protected void aggregateStats(List serverNames, ServerStats aggregatedStats, String period) { + if(serverNames.isEmpty()) { + return; + } + + List statsList = Collections.synchronizedList(new ArrayList()); + try { + List threads = createThreads(serverNames, period, statsList); + ProcessUtil.waitForThreads(threads); + for(ServerStats stats : statsList) { + addServerStats(stats, aggregatedStats, dataCount); + } + } catch (InterruptedException e) { + String errMsg = "Exception while aggregating network statistics on servers [" + serverNames + + "] for period [" + period + "]! Error: [" + e.getMessage() + "]"; + logger.error(errMsg, e); + throw new GlusterRuntimeException(errMsg, e); + } + + averageAggregatedStats(aggregatedStats, dataCount); + } + + private List createThreads(List serverNames, String period, List statsList) + throws InterruptedException { + List threads = new ArrayList(); + for (int i = serverNames.size()-1; i >= 0 ; i--) { + Thread thread = new NetworkStatsThread(serverNames.get(i), period, statsList); + threads.add(thread); + thread.start(); + if(i >= 5 && i % 5 == 0) { + // After every 5 servers, wait for 1 second so that we don't end up with too many running threads + Thread.sleep(1000); + } + } + return threads; + } + + public class NetworkStatsThread extends Thread { + private String serverName; + private String period; + private List statsList; + + public NetworkStatsThread(String serverName, String period, List statsList) { + this.serverName = serverName; + this.period = period; + this.statsList = statsList; + } + + @Override + public void run() { + try { + Server server = new Server(serverName); + serverUtil.fetchServerDetails(server); + + for (NetworkInterface networkInterface : server.getNetworkInterfaces()) { + // fetch the stats and add to aggregated stats + statsList.add(fetchStats(serverName, period, networkInterface.getName())); + } + } catch(Exception e) { + // server might be offline - continue with next one + logger.warn("Couldn't fetch Network stats from server [" + serverName + "]!", e); + } + } + } + + @Override + public ServerStats fetchStats(String serverName, String period, String... args) { + ServerStats stats = super.fetchStats(serverName, period, args); + + // the data returned by rrd contains "bytes/sec". Update the stats object to represent KiB/s + for(ServerStatsRow row : stats.getRows()) { + List data = row.getUsageData(); + for (int i = 0; i < data.size(); i++) { + Double val = data.get(i); + data.set(i, val / 1024); + } + } + + return stats; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/PasswordManager.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/PasswordManager.java new file mode 100644 index 00000000..a44b5bf3 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/PasswordManager.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import org.apache.derby.jdbc.EmbeddedDriver; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.gateway.security.UserAuthDao; +import org.springframework.jdbc.datasource.SimpleDriverDataSource; +import org.springframework.security.authentication.dao.ReflectionSaltSource; +import org.springframework.security.authentication.encoding.ShaPasswordEncoder; + + +/** + * Tool to reset password of default user gluster + */ +public class PasswordManager { + private static final int USAGE_ERR = 1; + private static final int SQL_ERR = 2; + + private void resetPassword(String username) { + try { + UserAuthDao userAuthDao = createUserAuthDao(); + ReflectionSaltSource saltSource = createSaltSource(); + + String encodedPassword = new ShaPasswordEncoder(256).encodePassword(CoreConstants.DEFAULT_PASSWORD, + saltSource.getSalt(userAuthDao.loadUserByUsername(username))); + + userAuthDao.changePassword(username, encodedPassword); + + System.out.println("Password for user [" + username + "] reset successsfully to default value of [" + + CoreConstants.DEFAULT_PASSWORD + "]." + CoreConstants.NEWLINE); + + DBUtil.shutdownDerby(); + } catch (Exception e) { + System.err.println(CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Password reset for user [" + username + + "] failed! " + CoreConstants.NEWLINE + + "Make sure that the Management Gateway is not running while performing password reset." + + CoreConstants.NEWLINE); + System.exit(SQL_ERR); + } + } + + private ReflectionSaltSource createSaltSource() { + ReflectionSaltSource saltSource = new ReflectionSaltSource(); + saltSource.setUserPropertyToUse("username"); + return saltSource; + } + + private UserAuthDao createUserAuthDao() throws InstantiationException, IllegalAccessException, + ClassNotFoundException { + UserAuthDao authDao = new UserAuthDao(); + EmbeddedDriver driver = (EmbeddedDriver) Class.forName(EmbeddedDriver.class.getName()).newInstance(); + SimpleDriverDataSource dataSource = new SimpleDriverDataSource(driver, "jdbc:derby:/opt/glustermg/data", "gluster", "syst3m"); + + authDao.setDataSource(dataSource); + return authDao; + } + + public static void main(String args[]) { + if (args.length != 2 || !args[0].equals("reset")) { + System.err.println("Usage: java " + PasswordManager.class.getName() + " reset \n"); + System.exit(USAGE_ERR); + } + + new PasswordManager().resetPassword(args[1]); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/ServerUtil.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/ServerUtil.java new file mode 100644 index 00000000..f65c5640 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/ServerUtil.java @@ -0,0 +1,370 @@ +/** + * ServerUtil.java + * + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + */ +package org.gluster.storage.management.gateway.utils; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.servlet.ServletContext; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.model.Server; +import org.gluster.storage.management.core.model.Status; +import org.gluster.storage.management.core.model.Server.SERVER_STATUS; +import org.gluster.storage.management.core.response.StringListResponse; +import org.gluster.storage.management.core.utils.ProcessResult; +import org.gluster.storage.management.core.utils.ProcessUtil; +import org.gluster.storage.management.gateway.services.GlusterInterfaceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; +import org.springframework.web.context.ContextLoader; + + +@Component +public class ServerUtil { + @Autowired + ServletContext servletContext; + + @Autowired + private SshUtil sshUtil; + + @Autowired + private String appVersion; + + private static final Logger logger = Logger.getLogger(ServerUtil.class); + + private static final String SCRIPT_DIR = "scripts"; + private static final String SCRIPT_COMMAND = "python"; + private static final String REMOTE_SCRIPT_GET_DISK_FOR_DIR = "get_disk_for_dir.py"; + private static final String REMOTE_SCRIPT_GET_SERVER_DETAILS = "get_server_details.py"; + private static final String REMOTE_SCRIPT_GET_FILE_SYSTEM_TYPE = "get_filesystem_type.py"; + private static final String REMOTE_SCRIPT_BASE_DIR = "/opt/glustermg"; + private static final String REMOTE_SCRIPT_DIR_NAME = "backend"; + + public void setSshUtil(SshUtil sshUtil) { + this.sshUtil = sshUtil; + } + + public ProcessResult executeGlusterScript(boolean runInForeground, String scriptName, String...arguments) { + return executeGlusterScript(runInForeground, scriptName, Arrays.asList(arguments)); + } + + public ProcessResult executeGlusterScript(boolean runInForeground, String scriptName, List arguments) { + List command = new ArrayList(); + + command.add(SCRIPT_COMMAND); + command.add(getScriptPath(scriptName)); + command.addAll(arguments); + return ProcessUtil.executeCommand(runInForeground, command); + } + + private String getScriptPath(String scriptName) { + return servletContext.getRealPath(SCRIPT_DIR) + CoreConstants.FILE_SEPARATOR + scriptName; + } + + private String getRemoteScriptDir() { + return REMOTE_SCRIPT_BASE_DIR + File.separator + appVersion + File.separator + REMOTE_SCRIPT_DIR_NAME; + } + + /** + * Fetch details of the given server. The server name must be populated in the object before calling this method. + * + * @param server + * Server whose details are to be fetched + */ + public void fetchServerDetails(Server server) { + try { + Server serverDetails = fetchServerDetails(server.getName()); + server.copyFrom(serverDetails); // Update the details in object + server.setDisks(serverDetails.getDisks()); + } catch (ConnectionException e) { + logger.warn("Couldn't connect to server [" + server.getName() + "]. Marking it offline!", e); + server.setStatus(SERVER_STATUS.OFFLINE); + } + } + + public boolean isServerOnline(Server server) { + // fetch latest details and check if server is still online + fetchServerDetails(server); + return server.isOnline(); + } + + public String fetchHostName(String serverName) { + Object response = fetchServerDetails(serverName); + return ((Server) response).getName(); + } + + private Server fetchServerDetails(String serverName) { + // fetch standard server details like cpu, disk, memory details + return executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_SERVER_DETAILS, Server.class); + } + + /** + * Executes given script on all given servers in parallel, collects the output in objects of given class, and + * returns a list of all returned objects. + * + * @param serverNames + * @param scriptWithArgs + * @param expectedClass + * @param failOnError + * If true, an exception will be thrown as soon as the script execution fails on any of the servers. If + * false, the exception will be caught and logged. Execution on all other servers will continue. + * @return + */ + public List executeScriptOnServers(List serverNames, String scriptWithArgs, + Class expectedClass, boolean failOnError) { + List result = Collections.synchronizedList(new ArrayList()); + try { + List threads = createScriptExecutionThreads(serverNames, getRemoteScriptDir() + File.separator + + scriptWithArgs, expectedClass, result, failOnError); + ProcessUtil.waitForThreads(threads); + return result; + } catch (InterruptedException e) { + String errMsg = "Exception while executing script [" + scriptWithArgs + "] on servers [" + serverNames + "]! Error: [" + e.getMessage() + "]"; + logger.error(errMsg, e); + throw new GlusterRuntimeException(errMsg, e); + } + } + + /** + * Creates threads that will run in parallel and execute the given command on each of the given servers + * + * @param serverNames + * @param commandWithArgs + * @param expectedClass + * @param result + * @param failOnError + * If true, an exception will be thrown as soon as the script execution fails on any of the servers. If + * false, the exception will be caught and logged. Execution on all other servers will continue. + * @return + * @throws InterruptedException + */ + private List createScriptExecutionThreads(List serverNames, String commandWithArgs, Class expectedClass, List result, + boolean failOnError) + throws InterruptedException { + List threads = new ArrayList(); + for (int i = serverNames.size()-1; i >= 0 ; i--) { + Thread thread = new RemoteExecutionThread(serverNames.get(i), commandWithArgs, expectedClass, result, failOnError); + threads.add(thread); + thread.start(); + if(i >= 5 && i % 5 == 0) { + // After every 5 servers, wait for 1 second so that we don't end up with too many running threads + Thread.sleep(1000); + } + } + return threads; + } + + + public class RemoteExecutionThread extends Thread { + private String serverName; + private String commandWithArgs; + private List result; + private Class expectedClass; + private boolean failOnError = false; + + public RemoteExecutionThread(String serverName, String commandWithArgs, Class expectedClass, List result, + boolean failOnError) { + this.serverName = serverName; + this.commandWithArgs = commandWithArgs; + this.result = result; + this.expectedClass = expectedClass; + this.failOnError = failOnError; + } + + @Override + public void run() { + try { + result.add(executeOnServer(serverName, commandWithArgs, expectedClass)); + } catch(Exception e) { + String errMsg = "Couldn't execute command [" + commandWithArgs + "] on [" + serverName + "]!"; + logger.error(errMsg, e); + if(failOnError) { + throw new GlusterRuntimeException(errMsg, e); + } + } + } + } + + + /** + * Executes given script on given server. Since the remote server may contain multiple versions of backend, this + * method will invoke the script present in directory of same version as the gateway. + * + * @param serverName + * @param scriptWithArgs + * The script name followed by arguments to be passed. Note that the script name should not contain path + * as it will be automatically identified by the method. + * @param expectedClass + * Class of the object expected from script execution + * @return Output (console/error) from the script execution + * @throws GlusterRuntimeException in case the remote execution fails. + */ + public String executeScriptOnServer(String serverName, String scriptWithArgs) { + return executeOnServer(serverName, getRemoteScriptDir() + File.separator + scriptWithArgs, String.class); + } + + /** + * Executes given script on given server. Since the remote server may contain multiple versions of backend, this + * method will invoke the script present in directory of same version as the gateway. + * + * @param serverName + * @param scriptWithArgs + * The script name followed by arguments to be passed. Note that the script name should not contain path + * as it will be automatically identified by the method. + * @param expectedClass + * Class of the object expected from script execution + * @return Object of the expected class from remote execution of the command. + * @throws GlusterRuntimeException in case the remote execution fails. + */ + public T executeScriptOnServer(String serverName, String scriptWithArgs, + Class expectedClass) { + return executeOnServer(serverName, getRemoteScriptDir() + File.separator + scriptWithArgs, + expectedClass); + } + + /** + * Executes given command on given server + * + * @param serverName + * @param commandWithArgs + * @param expectedClass + * Class of the object expected from script execution + * @return Object of the expected class from remote execution of the command. In case the remote execution fails + * ungracefully, an object of class {@link Status} will be returned. + */ + @SuppressWarnings("unchecked") + public T executeOnServer(String serverName, String commandWithArgs, + Class expectedClass) { + String output = executeOnServer(serverName, commandWithArgs); + if (expectedClass == String.class) { + return (T) output; + } + + return unmarshal(expectedClass, output); + } + + public String executeOnServer(String serverName, String commandWithArgs) { + ProcessResult result = sshUtil.executeRemote(serverName, commandWithArgs); + + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Command [" + commandWithArgs + "] failed on [" + serverName + + "] with error [" + result.getExitValue() + "][" + result.getOutput() + "]"); + } + return result.getOutput(); + } + + // This is the old executeOnServer that used socket communication. + // We can keep it commented for the time being. + // private String executeOnServerUsingSocket(String serverName, String commandWithArgs) { + // try { + // InetAddress address = InetAddress.getByName(serverName); + // Socket connection = new Socket(address, 50000); + // + // PrintWriter writer = new PrintWriter(connection.getOutputStream(), true); + // writer.println(commandWithArgs); + // writer.println(); // empty line means end of request + // + // InputStream inputStream = connection.getInputStream(); + // int available = inputStream.available(); + // + // StringBuffer output = new StringBuffer(); + // if( available > 0 ) { + // // This happens when PeerAgent sends complete file + // byte[] responseData = new byte[available]; + // inputStream.read(responseData); + // output.append(new String(responseData, "UTF-8")); + // } else { + // // This happens in case of normal XML response from PeerAgent + // BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + // + // String line; + // while (!(line = reader.readLine()).trim().isEmpty()) { + // output.append(line + CoreConstants.NEWLINE); + // } + // } + // connection.close(); + // + // return output.toString(); + // } catch (Exception e) { + // throw new GlusterRuntimeException("Error during remote execution: [" + e.getMessage() + "]"); + // } + // } + + public void getFileFromServer(String serverName, String remoteFileName, String localDirName) { + sshUtil.getFile(serverName, remoteFileName, localDirName); + } + + /** + * Unmarshals given input string into object of given class + * + * @param expectedClass + * Class whose object is expected + * @param input + * Input string + * @return Object of given expected class + */ + public T unmarshal(Class expectedClass, String input) { + try { + // create JAXB context and instantiate marshaller + JAXBContext context = JAXBContext.newInstance(expectedClass); + Unmarshaller um = context.createUnmarshaller(); + return (T)um.unmarshal(new ByteArrayInputStream(input.getBytes())); + } catch (JAXBException e) { + String errMsg = "Error during unmarshalling string [" + input + "] for class [" + expectedClass.getName() + + ": [" + e.getMessage() + "]"; + logger.error(errMsg, e); + throw new GlusterRuntimeException(errMsg, e); + } + } + + /** + * @param serverName + * Server on which the directory is present + * @param brickDir + * Directory whose disk is to be fetched + * @return Status object containing the disk name, or error message in case the remote script fails. + */ + public Status getDiskForDir(String serverName, String brickDir) { + return executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_DISK_FOR_DIR + " " + brickDir, Status.class); + } + + public T getBean(Class clazz) { + ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext(); + return ctx.getBean(clazz); + } + + public List getFsTypes(String serverName) { + String output = executeScriptOnServer(serverName, REMOTE_SCRIPT_GET_FILE_SYSTEM_TYPE); + return Arrays.asList(output.trim().split(CoreConstants.NEWLINE)); + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/SshUtil.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/SshUtil.java new file mode 100644 index 00000000..074cbd5b --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/SshUtil.java @@ -0,0 +1,463 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; + +import org.apache.log4j.Logger; +import org.gluster.storage.management.core.constants.CoreConstants; +import org.gluster.storage.management.core.exceptions.ConnectionException; +import org.gluster.storage.management.core.exceptions.GlusterRuntimeException; +import org.gluster.storage.management.core.utils.FileUtil; +import org.gluster.storage.management.core.utils.LRUCache; +import org.gluster.storage.management.core.utils.ProcessResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import ch.ethz.ssh2.ChannelCondition; +import ch.ethz.ssh2.Connection; +import ch.ethz.ssh2.SCPClient; +import ch.ethz.ssh2.Session; +import ch.ethz.ssh2.StreamGobbler; + + +/** + * + */ +@Component +public class SshUtil { + private static final String TEMP_DIR = "/tmp/"; + public static final String SSH_AUTHORIZED_KEYS_DIR_LOCAL = "/opt/glustermg/keys/"; + public static final String SSH_AUTHORIZED_KEYS_DIR_REMOTE = "/root/.ssh/"; + private static final String SSH_AUTHORIZED_KEYS_FILE = "authorized_keys"; + private static final String SSH_AUTHORIZED_KEYS_PATH_REMOTE = SSH_AUTHORIZED_KEYS_DIR_REMOTE + SSH_AUTHORIZED_KEYS_FILE; + public static final File PRIVATE_KEY_FILE = new File(SSH_AUTHORIZED_KEYS_DIR_LOCAL + "gluster.pem"); + public static final File PUBLIC_KEY_FILE = new File(SSH_AUTHORIZED_KEYS_DIR_LOCAL + "gluster.pub"); + private LRUCache sshConnCache = new LRUCache(10); + + // TODO: Make user name configurable + private static final String USER_NAME = "root"; + // TODO: Make default password configurable + private static final String DEFAULT_PASSWORD = "syst3m"; + + private static final Logger logger = Logger.getLogger(SshUtil.class); + + @Autowired + private Integer sshConnectTimeout; + @Autowired + private Integer sshKexTimeout; + @Autowired + private Integer sshExecTimeout; + + public boolean hasDefaultPassword(String serverName) { + try { + getConnectionWithPassword(serverName).close(); + return true; + } catch(Exception e) { + logger.warn("Couldn't connect to [" + serverName + "] with default password!", e); + return false; + } + } + + /** + * Checks if public key of management gateway is configured on given server + * + * @param serverName + * @return true if public key is configured, else false + */ + public boolean isPublicKeyInstalled(String serverName) { + try { + getConnectionWithPubKey(serverName).close(); + return true; + } catch(ConnectionException e) { + logger.warn("Couldn't connect to [" + serverName + "] with public key!", e); + return false; + } + } + + public void getFile(String serverName, String remoteFile, String localDir) { + try { + Connection conn = getConnection(serverName); + SCPClient scpClient = new SCPClient(conn); + scpClient.get(remoteFile, localDir); + } catch (IOException e) { + throw new GlusterRuntimeException("Error while fetching file [" + remoteFile + "] from server [" + + serverName + "]", e); + } + } + + public synchronized void installPublicKey(String serverName) { + Connection conn = null; + try { + conn = getConnectionWithPassword(serverName); + } catch(Exception e) { + // authentication failed. close the connection. + conn.close(); + if (e instanceof GlusterRuntimeException) { + throw (GlusterRuntimeException) e; + } else { + throw new GlusterRuntimeException("Exception during authentication with public key on server [" + + serverName + "]", e); + } + } + SCPClient scpClient = new SCPClient(conn); + + // delete file if it exists + File localTempFile = new File(TEMP_DIR + SSH_AUTHORIZED_KEYS_FILE); + if(localTempFile.exists()) { + localTempFile.delete(); + } + + try { + // get authorized_keys from server + scpClient.get(SSH_AUTHORIZED_KEYS_PATH_REMOTE, TEMP_DIR); + } catch (IOException e) { + // file doesn't exist. it will get created. + // create the .ssh directory in case it doesn't exist + logger.info("Couldn't fetch file [" + SSH_AUTHORIZED_KEYS_PATH_REMOTE +"].", e); + logger.info("Creating /root/.ssh on [" + serverName + "] in case it doesn't exist."); + String command = "mkdir -p " + SSH_AUTHORIZED_KEYS_DIR_REMOTE; + ProcessResult result = executeCommand(conn, command); + if(!result.isSuccess()) { + String errMsg = "Command [" + command + "] failed on server [" + serverName + "] with error: " + result; + logger.error(errMsg); + throw new GlusterRuntimeException(errMsg); + } + } + + byte[] publicKeyData; + try { + publicKeyData = FileUtil.readFileAsByteArray(PUBLIC_KEY_FILE); + } catch (Exception e) { + conn.close(); + throw new GlusterRuntimeException("Couldn't load public key file [" + PUBLIC_KEY_FILE + "]", e); + } + + try { + // append it + FileOutputStream outputStream = new FileOutputStream(localTempFile, true); + outputStream.write(CoreConstants.NEWLINE.getBytes()); + outputStream.write(publicKeyData); + outputStream.close(); + } catch (Exception e) { + conn.close(); + throw new GlusterRuntimeException("Couldnt append file [" + localTempFile + "] with public key!", e); + } + + try { + scpClient.put(localTempFile.getAbsolutePath(), SSH_AUTHORIZED_KEYS_FILE, SSH_AUTHORIZED_KEYS_DIR_REMOTE, "0600"); + } catch (IOException e) { + throw new GlusterRuntimeException("Couldn't add public key to server [" + serverName + "]", e); + } finally { + conn.close(); + localTempFile.delete(); + } + + // It was decided NOT to disable password login as this may not be acceptable in a bare-metal environment + // disableSshPasswordLogin(serverName, scpClient); + } + +// private void disableSshPasswordLogin(String serverName, SCPClient scpClient) { +// ProcessResult result = executeRemote(serverName, SCRIPT_DISABLE_SSH_PASSWORD_AUTH); +// if(!result.isSuccess()) { +// throw new GlusterRuntimeException("Couldn't disable SSH password authentication on [" + serverName +// + "]. Error: " + result); +// } +// } + + private synchronized Connection getConnectionWithPassword(String serverName) { + Connection conn = createConnection(serverName); + if(!authenticateWithPassword(conn)) { + conn.close(); + throw new ConnectionException("SSH Authentication (password) failed for server [" + + conn.getHostname() + "]"); + } + return conn; + } + + private synchronized Connection getConnectionWithPubKey(String serverName) { + Connection conn = createConnection(serverName); + if(!authenticateWithPublicKey(conn)) { + conn.close(); + throw new ConnectionException("SSH Authentication (public key) failed for server [" + + conn.getHostname() + "]"); + } + return conn; + } + + private synchronized Connection getConnection(String serverName) { + Connection conn = sshConnCache.get(serverName); + if (conn != null) { + return conn; + } + + conn = createConnection(serverName); + try { + if(!authenticateWithPublicKey(conn)) { + if(!authenticateWithPassword(conn)) { + conn.close(); + throw new ConnectionException("SSH authentication failed on server [" + serverName + "]!"); + } + } + } catch(Exception e) { + // authentication failed. close the connection. + conn.close(); + if(e instanceof GlusterRuntimeException) { + throw (GlusterRuntimeException)e; + } else { + throw new GlusterRuntimeException("Exception during authentication on server [" + serverName + "]", e); + } + } + + sshConnCache.put(serverName, conn); + return conn; + } + + private boolean authenticateWithPublicKey(Connection conn) { + try { + if (!supportsPublicKeyAuthentication(conn)) { + throw new ConnectionException("Public key authentication not supported on [" + conn.getHostname() + + "]"); + } + + if (!conn.authenticateWithPublicKey(USER_NAME, PRIVATE_KEY_FILE, null)) { + return false; + } + + return true; + } catch (IOException e) { + throw new ConnectionException("Exception during SSH authentication (public key) for server [" + + conn.getHostname() + "]", e); + } + } + + private boolean authenticateWithPassword(Connection conn) { + try { + if (!supportsPasswordAuthentication(conn)) { + throw new ConnectionException("Password authentication not supported on [" + conn.getHostname() + + "]"); + } + + if (!conn.authenticateWithPassword(USER_NAME, DEFAULT_PASSWORD)) { + return false; + } + return true; + } catch (IOException e) { + throw new ConnectionException("Exception during SSH authentication (password) for server [" + + conn.getHostname() + "]", e); + } + } + + private boolean supportsPasswordAuthentication(Connection conn) throws IOException { + return Arrays.asList(conn.getRemainingAuthMethods(USER_NAME)).contains("password"); + } + + private boolean supportsPublicKeyAuthentication(Connection conn) throws IOException { + return Arrays.asList(conn.getRemainingAuthMethods(USER_NAME)).contains("publickey"); + } + + private synchronized Connection createConnection(String serverName) { + Connection conn = new Connection(serverName); + try { + conn.connect(null, sshConnectTimeout, sshKexTimeout); + } catch (IOException e) { + logger.error("Couldn't establish SSH connection with server [" + serverName + "]", e); + conn.close(); + throw new ConnectionException("Exception while creating SSH connection with server [" + serverName + "]", e); + } + return conn; + } + + private boolean wasTerminated(int condition) { + return ((condition | ChannelCondition.EXIT_SIGNAL) == condition); + } + + private boolean hasErrors(int condition, Session session) { + return (hasErrorStream(condition) || (exitedGracefully(condition) && exitedWithError(session))); + } + + private boolean timedOut(int condition) { + return (condition == ChannelCondition.TIMEOUT); + } + + private boolean exitedWithError(Session session) { + return session.getExitStatus() != ProcessResult.SUCCESS; + } + + private boolean exitedGracefully(int condition) { + return (condition | ChannelCondition.EXIT_STATUS) == condition; + } + + private boolean hasErrorStream(int condition) { + return (condition | ChannelCondition.STDERR_DATA) == condition; + } + + private ProcessResult executeCommand(Connection sshConnection, String command) { + Session session = null; + try { + session = sshConnection.openSession(); + BufferedReader stdoutReader = new BufferedReader(new InputStreamReader(new StreamGobbler( + session.getStdout()))); + BufferedReader stderrReader = new BufferedReader(new InputStreamReader(new StreamGobbler( + session.getStderr()))); + session.execCommand(command); + ProcessResult result = getResultOfExecution(session, stdoutReader, stderrReader); + return result; + } catch (Exception e) { + String errMsg = "Exception while executing command [" + command + "] on [" + sshConnection.getHostname() + + "]"; + logger.error(errMsg, e); + + // remove the connection from cache and close it + sshConnCache.remove(sshConnection.getHostname()); + sshConnection.close(); + if(e instanceof IllegalStateException || e instanceof IOException) { + // The connection is no more valid. Create and throw a connection exception. + throw new ConnectionException("Couldn't open SSH session on [" + sshConnection.getHostname() + "]!", e); + } else { + throw new GlusterRuntimeException(errMsg, e); + } + } finally { + if(session != null) { + session.close(); + } + } + } + + private ProcessResult getResultOfExecution(Session session, BufferedReader stdoutReader, BufferedReader stderrReader) { + // Wait for program to come out either + // a) gracefully with an exit status, OR + // b) because of a termination signal + // c) command takes to long to exit (timeout) + int condition = session.waitForCondition(ChannelCondition.EXIT_SIGNAL | ChannelCondition.EXIT_STATUS, + sshExecTimeout); + StringBuilder output = new StringBuilder(); + + try { + if(!timedOut(condition)) { + readFromStream(stdoutReader, output); + if (hasErrors(condition, session)) { + readFromStream(stderrReader, output); + } + } + + return prepareProcessResult(session, condition, output.toString().trim()); + } catch (IOException e) { + String errMsg = "Error while reading output stream from SSH connection!"; + logger.error(errMsg, e); + return new ProcessResult(ProcessResult.FAILURE, errMsg); + } + } + + private ProcessResult prepareProcessResult(Session session, int condition, String output) { + ProcessResult result = null; + + if (wasTerminated(condition)) { + result = new ProcessResult(ProcessResult.FAILURE, output); + } else if (timedOut(condition)) { + result = new ProcessResult(ProcessResult.FAILURE, "Command timed out!"); + } else if (hasErrors(condition, session)) { + Integer exitStatus = session.getExitStatus(); + int statusCode = (exitStatus == null ? ProcessResult.FAILURE : exitStatus); + result = new ProcessResult(statusCode, output); + } else { + result = new ProcessResult(ProcessResult.SUCCESS, output); + } + + return result; + } + + private void readFromStream(BufferedReader streamReader, StringBuilder output) throws IOException { + while (true) { + String line = streamReader.readLine(); + if (line == null) { + break; + } + output.append(line + CoreConstants.NEWLINE); + } + } + + /** + * Executes given command on remote machine using password authentication + * + * @param serverName + * @param command + * @return Result of remote execution + */ + public ProcessResult executeRemoteWithPassword(String serverName, String command) { + logger.info("Executing command [" + command + "] on server [" + serverName + "] with default password."); + Connection conn = null; + try { + conn = getConnectionWithPassword(serverName); + return executeCommand(conn, command); + } finally { + // we don't cache password based connections. hence the connection must be closed. + if(conn != null) { + conn.close(); + } + } + } + + /** + * Executes given command on remote machine using public key authentication + * + * @param serverName + * @param command + * @return Result of remote execution + */ + public ProcessResult executeRemote(String serverName, String command) { + logger.info("Executing command [" + command + "] on server [" + serverName + "]"); + return executeCommand(getConnection(serverName), command); + } + + public void cleanup() { + for (Connection conn : sshConnCache.values()) { + conn.close(); + } + } + + public Integer getSshConnectTimeout() { + return sshConnectTimeout; + } + + public void setSshConnectTimeout(Integer sshConnectTimeout) { + this.sshConnectTimeout = sshConnectTimeout; + } + + public Integer getSshKexTimeout() { + return sshKexTimeout; + } + + public void setSshKexTimeout(Integer sshKexTimeout) { + this.sshKexTimeout = sshKexTimeout; + } + + public Integer getSshExecTimeout() { + return sshExecTimeout; + } + + public void setSshExecTimeout(Integer sshExecTimeout) { + this.sshExecTimeout = sshExecTimeout; + } +} diff --git a/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/StatsFactory.java b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/StatsFactory.java new file mode 100644 index 00000000..f856c05a --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/org/gluster/storage/management/gateway/utils/StatsFactory.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2011 Gluster, Inc. + * This file is part of Gluster Management Console. + * + * Gluster Management Console is free software; you can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Gluster Management Console is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License + * for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * . + *******************************************************************************/ +package org.gluster.storage.management.gateway.utils; + +import java.util.List; + +import org.gluster.storage.management.core.model.ServerStats; + + +/** + * + */ +public interface StatsFactory { + public ServerStats fetchStats(String serverName, String period, String...args); + public ServerStats fetchAggregatedStats(List serverName, String period); +} diff --git a/src/org.gluster.storage.management.gateway/src/rebel.xml b/src/org.gluster.storage.management.gateway/src/rebel.xml new file mode 100644 index 00000000..08707b75 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/rebel.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/org.gluster.storage.management.gateway/src/spring/gluster-server-base.xml b/src/org.gluster.storage.management.gateway/src/spring/gluster-server-base.xml new file mode 100644 index 00000000..ea3754f5 --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/spring/gluster-server-base.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.gluster.storage.management.gateway.data.ClusterInfo + + + + + + org.gluster.storage.management.gateway.data.ServerInfo + + + + + + + + + + + \ No newline at end of file diff --git a/src/org.gluster.storage.management.gateway/src/spring/gluster-server-security.xml b/src/org.gluster.storage.management.gateway/src/spring/gluster-server-security.xml new file mode 100644 index 00000000..e160d31a --- /dev/null +++ b/src/org.gluster.storage.management.gateway/src/spring/gluster-server-security.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit