Maor Lipchuk has uploaded a new change for review.

Change subject: webadmin: support OpenStack Volume in provider dialog
......................................................................

webadmin: support OpenStack Volume in provider dialog

Adding support for OpenStack Volume (Cinder) in
add/edit provider dialog:
* Adding appropriate default url for OPENSTACK_VOLUME
* Add data-center editor and set items accordingly.
* Pass the selected data-center ID on save.

Change-Id: Ic30b43378f9968e837611943891cef2bc7ef2104
Bug-Url: https://bugzilla.redhat.com/1185826
Signed-off-by: Maor Lipchuk <mlipc...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/AddProviderModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/EditProviderModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
5 files changed, 105 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/34/38934/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/AddProviderModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/AddProviderModel.java
index 99022b5..8953501 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/AddProviderModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/AddProviderModel.java
@@ -3,9 +3,16 @@
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.Provider;
 import org.ovirt.engine.core.common.businessentities.ProviderType;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
+import org.ovirt.engine.ui.frontend.INewAsyncCallback;
 import org.ovirt.engine.ui.uicommonweb.Linq;
+import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.help.HelpTag;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
+
+import java.util.ArrayList;
 
 public class AddProviderModel extends ProviderModel {
 
@@ -20,4 +27,22 @@
         getNeutronAgentModel().init(provider); // this is okay because 
AdditionalProperties == null at this point
     }
 
+    @Override
+    protected void updateDatacentersForVolumeProvider() {
+        AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery(this, 
new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object returnValue) {
+                ArrayList<StoragePool> dataCenters = (ArrayList<StoragePool>) 
returnValue;
+                ProviderModel providerModel = (ProviderModel) model;
+
+                // add an empty DataCenter to the list
+                StoragePool noneStoragePool = new StoragePool();
+                noneStoragePool.setId(Guid.Empty);
+                noneStoragePool.setName("(none)"); //$NON-NLS-1$
+                dataCenters.add(noneStoragePool);
+
+                providerModel.getDataCenter().setItems(dataCenters);
+            }
+        }));
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/EditProviderModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/EditProviderModel.java
index 1e32181..4a4ac84 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/EditProviderModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/EditProviderModel.java
@@ -8,14 +8,20 @@
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.Provider;
+import org.ovirt.engine.core.common.businessentities.StorageDomainStatic;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.StringHelper;
+import org.ovirt.engine.ui.frontend.AsyncQuery;
 import org.ovirt.engine.ui.frontend.Frontend;
+import org.ovirt.engine.ui.frontend.INewAsyncCallback;
 import org.ovirt.engine.ui.uicommonweb.UICommand;
+import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.help.HelpTag;
 import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel;
 import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
@@ -125,4 +131,28 @@
         }
     }
 
+    @Override
+    protected void updateDatacentersForVolumeProvider() {
+        getDataCenter().setIsChangable(false);
+        AsyncDataProvider.getInstance().getStorageDomainByName(new 
AsyncQuery(this, new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object target, Object returnValue) {
+                StorageDomainStatic storageDomainStatic = 
(StorageDomainStatic) returnValue;
+                
AsyncDataProvider.getInstance().getDataCentersByStorageDomain(new 
AsyncQuery(target, new INewAsyncCallback() {
+                    @Override
+                    public void onSuccess(Object model, Object returnValue) {
+                        ArrayList<StoragePool> dataCenters = 
(ArrayList<StoragePool>) returnValue;
+                        if (dataCenters != null && !dataCenters.isEmpty()) {
+                            
getDataCenter().setSelectedItem(dataCenters.get(0));
+                        } else {
+                            StoragePool noneStoragePool = new StoragePool();
+                            noneStoragePool.setId(Guid.Empty);
+                            noneStoragePool.setName("(none)"); //$NON-NLS-1$
+                            getDataCenter().setSelectedItem(noneStoragePool);
+                        }
+                    }
+                }), storageDomainStatic.getId());
+            }
+        }), provider.getName());
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
index 3c4059e..ec0f3d5 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
@@ -13,7 +13,9 @@
 import 
org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties;
 import org.ovirt.engine.core.common.businessentities.Provider;
 import org.ovirt.engine.core.common.businessentities.ProviderType;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.TenantProviderProperties;
+import 
org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties;
 import org.ovirt.engine.ui.frontend.AsyncQuery;
 import org.ovirt.engine.ui.frontend.Frontend;
 import org.ovirt.engine.ui.frontend.INewAsyncCallback;
@@ -62,6 +64,7 @@
     private UICommand testCommand;
     private EntityModel<String> testResult = new EntityModel<String>();
     private EntityModel<String> authUrl = new EntityModel<String>();
+    private ListModel<StoragePool> dataCenter;
 
     private NeutronAgentModel neutronAgentModel = new NeutronAgentModel();
     private String certificate;
@@ -130,9 +133,22 @@
         return getType().getSelectedItem() == ProviderType.OPENSTACK_IMAGE;
     }
 
+    private boolean isTypeOpenStackVolume() {
+        return getType().getSelectedItem() == ProviderType.OPENSTACK_VOLUME;
+    }
+
+    public ListModel<StoragePool> getDataCenter() {
+        return dataCenter;
+    }
+
+    public void setDataCenter(ListModel<StoragePool> dataCenter) {
+        this.dataCenter = dataCenter;
+    }
+
     private boolean isTypeTenantOrAuthUrlAware() {
         ProviderType type = getType().getSelectedItem();
-        return type == ProviderType.OPENSTACK_NETWORK || type == 
ProviderType.OPENSTACK_IMAGE;
+        return type == ProviderType.OPENSTACK_NETWORK || type == 
ProviderType.OPENSTACK_IMAGE ||
+                type == ProviderType.OPENSTACK_VOLUME;
     }
 
     public EntityModel<String> getAuthUrl() {
@@ -152,6 +168,8 @@
                 return "http://localhost:9696";; //$NON-NLS-1$
             case OPENSTACK_IMAGE:
                 return "http://localhost:9292";; //$NON-NLS-1$
+            case OPENSTACK_VOLUME:
+                return "http://localhost:8776";; //$NON-NLS-1$
             case FOREMAN:
             default:
                 return "http://localhost";; //$NON-NLS-1$
@@ -204,6 +222,12 @@
                 boolean requiresAuth = isTypeRequiresAuthentication();
                 
getRequiresAuthentication().setEntity(Boolean.valueOf(requiresAuth));
                 getRequiresAuthentication().setIsChangable(!requiresAuth);
+
+                boolean isCinder = isTypeOpenStackVolume();
+                getDataCenter().setIsAvailable(isCinder);
+                if (isCinder) {
+                    updateDatacentersForVolumeProvider();
+                }
             }
         });
 
@@ -219,6 +243,13 @@
         UICommand tempVar2 = UICommand.createCancelUiCommand(CMD_CANCEL, 
this); //$NON-NLS-1$
         getCommands().add(tempVar2);
         setTestCommand(new UICommand(CMD_TEST, this));
+
+        setDataCenter(new ListModel<StoragePool>());
+        getDataCenter().setIsAvailable(false);
+    }
+
+    protected void updateDatacentersForVolumeProvider() {
+        // implemented on sub-classes
     }
 
     private boolean validate() {
@@ -263,6 +294,8 @@
             getNeutronAgentModel().flush(provider);
         } else if (isTypeOpenStackImage()) {
             provider.setAdditionalProperties(new 
OpenStackImageProviderProperties());
+        } else if (isTypeOpenStackVolume()) {
+            provider.setAdditionalProperties(new 
OpenStackVolumeProviderProperties(getDataCenter().getSelectedItem().getId()));
         }
 
         boolean authenticationRequired = requiresAuthentication.getEntity();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
index 084e4cd..4c28d91 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.ui.webadmin.section.main.view.popup.provider;
 
 import org.ovirt.engine.core.common.businessentities.ProviderType;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.ui.common.idhandler.ElementIdHandler;
 import org.ovirt.engine.ui.common.idhandler.WithElementId;
 import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView;
@@ -15,6 +16,7 @@
 import 
org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelPasswordBoxEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor;
 import org.ovirt.engine.ui.common.widget.renderer.EnumRenderer;
+import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer;
 import org.ovirt.engine.ui.uicommonweb.models.providers.ProviderModel;
 import org.ovirt.engine.ui.webadmin.ApplicationConstants;
 import org.ovirt.engine.ui.webadmin.ApplicationResources;
@@ -60,6 +62,11 @@
     @Path(value = "type.selectedItem")
     @WithElementId
     ListModelListBoxEditor<ProviderType> typeEditor;
+
+    @UiField(provided = true)
+    @Path(value = "dataCenter.selectedItem")
+    @WithElementId
+    ListModelListBoxEditor<StoragePool> datacenterEditor;
 
     @UiField
     @Path(value = "url.entity")
@@ -130,6 +137,12 @@
         super(eventBus);
 
         typeEditor = new ListModelListBoxEditor<ProviderType>(new 
EnumRenderer());
+        datacenterEditor = new ListModelListBoxEditor<>(new 
NullSafeRenderer<StoragePool>() {
+            @Override
+            public String renderNullSafe(StoragePool storagePool) {
+                return storagePool.getName();
+            }
+        });
         requiresAuthenticationEditor = new 
EntityModelCheckBoxEditor(Align.RIGHT);
 
         initWidget(ViewUiBinder.uiBinder.createAndBindUi(this));
@@ -152,6 +165,7 @@
         passwordEditor.setLabel(constants.passwordProvider());
         tenantNameEditor.setLabel(constants.tenantName());
         pluginTypeEditor.setLabel(constants.pluginType());
+        datacenterEditor.setLabel(constants.dataCenter());
         authUrlEditor.setLabel(constants.authUrlProvider());
 
         // Agent configuration tab
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
index dee8079..2d74b03 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
@@ -61,7 +61,8 @@
                                                                                
<ge:StringEntityModelTextBoxEditor ui:field="nameEditor" />
                                                                                
<ge:StringEntityModelTextBoxEditor ui:field="descriptionEditor" />
                                                                                
<e:ListModelListBoxEditor ui:field="typeEditor" />
-                                                                       
</g:FlowPanel>
+                                        <e:ListModelListBoxEditor 
ui:field="datacenterEditor" />
+                                    </g:FlowPanel>
                                                                        
<g:FlowPanel>
                                                                                
<ge:ListModelSuggestBoxEditor ui:field="pluginTypeEditor" />
                                                                                
<ge:StringEntityModelTextBoxEditor ui:field="urlEditor" />


-- 
To view, visit https://gerrit.ovirt.org/38934
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic30b43378f9968e837611943891cef2bc7ef2104
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to