private void connectTargets() { VDS host = getContainer().getHost().getSelectedItem(); if (host == null) { return; } ArrayList<ActionType> actionTypes = new ArrayList<>(); ArrayList<ActionParametersBase> parameters = new ArrayList<>(); ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>(); final SanStorageModelBase sanStorageModel = this; IFrontendActionAsyncCallback loginCallback = result -> sanStorageModel.postLogin(result.getReturnValue(), sanStorageModel); for (int i = 0; i < targetsToConnect.size(); i++) { SanTargetModel model = targetsToConnect.get(i); StorageServerConnections connection = new StorageServerConnections(); connection.setStorageType(StorageType.ISCSI); connection.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : ""); //$NON-NLS-1$ connection.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : ""); //$NON-NLS-1$ connection.setIqn(model.getName()); connection.setConnection(model.getAddress()); connection.setPort(String.valueOf(model.getPort())); connection.setPortal(model.getPortal()); actionTypes.add(ActionType.ConnectStorageToVds); parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false)); callbacks.add(loginCallback); } Object target = getWidgetModel() != null ? getWidgetModel() : getContainer(); Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, null, target); }
private StorageServerConnections getInitializedConnectionIscsiDetails(Action action) { StorageServerConnections connectionDetails = new StorageServerConnections(); IscsiDetails iscsiDetails = action.getIscsi(); connectionDetails.setConnection(iscsiDetails.getAddress()); connectionDetails.setStorageType(StorageType.ISCSI); if (iscsiDetails.isSetPort()) { connectionDetails.setPort(iscsiDetails.getPort().toString()); } else { connectionDetails.setPort(DEFAULT_ISCSI_PORT); } if (iscsiDetails.isSetUsername()) { connectionDetails.setUserName(iscsiDetails.getUsername()); } if (iscsiDetails.isSetPassword()) { connectionDetails.setPassword(iscsiDetails.getPassword()); } return connectionDetails; }
private void discoverTargets() { if (!validateDiscoverTargetFields()) { return; } VDS host = getContainer().getHost().getSelectedItem(); StorageServerConnections tempVar = new StorageServerConnections(); tempVar.setConnection(getAddress().getEntity().trim()); tempVar.setPort(getPort().getEntity().trim()); tempVar.setStorageType(StorageType.ISCSI); tempVar.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : ""); //$NON-NLS-1$ tempVar.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : ""); //$NON-NLS-1$ DiscoverSendTargetsQueryParameters parameters = new DiscoverSendTargetsQueryParameters(host.getId(), tempVar); setMessage(null); final SanStorageModelBase model = this; AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> { Object result = returnValue.getReturnValue(); model.postDiscoverTargetsInternal(result != null ? (ArrayList<StorageServerConnections>) result : new ArrayList<>()); }, true); Frontend.getInstance().runQuery(QueryType.DiscoverSendTargets, parameters, asyncQuery); }
@Mapping(from = LogicalUnit.class, to = StorageServerConnections.class) public static StorageServerConnections map(LogicalUnit logicalUnit, StorageServerConnections connection) { StorageServerConnections entity = connection != null ? connection : new StorageServerConnections(); if (logicalUnit.isSetAddress()) { entity.setConnection(logicalUnit.getAddress()); } if (logicalUnit.isSetTarget()) { entity.setIqn(logicalUnit.getTarget()); } if (logicalUnit.isSetPort()) { entity.setPort(logicalUnit.getPort().toString()); } if (logicalUnit.isSetUsername()) { entity.setUserName(logicalUnit.getUsername()); } if (logicalUnit.isSetPassword()) { entity.setPassword(logicalUnit.getPassword()); } return entity; }
public StorageServerConnections(String connection, String id, String iqn, String password, StorageType storageType, String userName, String port, String portal, String vfsType, String mountOptions, NfsVersion nfsVersion, Short nfsRetrans, Short nfsTimeo, Guid glusterVolumeId) { setConnection(connection); setId(id); setIqn(iqn); setPassword(password); setStorageType(storageType); setUserName(userName); setPort(port); setPortal(portal); setVfsType(vfsType); setMountOptions(mountOptions); setNfsVersion(nfsVersion); setNfsRetrans(nfsRetrans); setNfsTimeo(nfsTimeo); setGlusterVolumeId(glusterVolumeId); }
@Override public Response iscsiLogin(Action action) { validateParameters(action, "iscsi.address", "iscsi.target"); StorageServerConnections cnx = new StorageServerConnections(); IscsiDetails iscsiDetails = action.getIscsi(); cnx.setConnection(iscsiDetails.getAddress()); cnx.setIqn(iscsiDetails.getTarget()); cnx.setStorageType(StorageType.ISCSI); if (iscsiDetails.isSetPort()) { cnx.setPort(iscsiDetails.getPort().toString()); } else { cnx.setPort(DEFAULT_ISCSI_PORT); } if (iscsiDetails.isSetPortal()) { cnx.setPortal(iscsiDetails.getPortal()); } if (iscsiDetails.isSetUsername()) { cnx.setUserName(iscsiDetails.getUsername()); } if (iscsiDetails.isSetPassword()) { cnx.setPassword(iscsiDetails.getPassword()); } StorageServerConnectionParametersBase connectionParms = new StorageServerConnectionParametersBase(cnx, guid, false); return doAction(ActionType.ConnectStorageToVds, connectionParms, action); }
private StorageServerConnections createConnection(String id, String connection, String iqn, String username, String password, String portal, String port) { StorageServerConnections newConn = new StorageServerConnections(); newConn.setId(id); newConn.setConnection(connection); newConn.setIqn(iqn); newConn.setPortal(portal); newConn.setPort(port); newConn.setUserName(username); newConn.setPassword(password); dao.save(newConn); return newConn; }
entity.setUserName(model.getUsername());
@Test public void checkISCSIStorageConnectionsMappings() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setIqn("iqn.my.target1"); connection.setPort("3260"); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI); connection.setConnection("1.2.135.255"); connection.setUserName("myuser1"); connection.setPassword("123"); HostStorage RESTConnection = new HostStorage(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.ISCSI); RESTConnection.setPort(3260); RESTConnection.setTarget("iqn.my.target1"); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setUsername("myuser1"); StorageConnection mappedResult = StorageDomainMapper.map(connection, null); assertEquals(RESTConnection.getId(), mappedResult.getId()); // Although password was set on StorageServerConnections object, it should not be returned via REST // thus testing here that it remains empty. assertEquals(RESTConnection.getPassword(), mappedResult.getPassword()); assertEquals(RESTConnection.getType(), mappedResult.getType()); assertEquals(RESTConnection.getAddress(), mappedResult.getAddress()); assertEquals(RESTConnection.getUsername(), mappedResult.getUsername()); assertEquals(RESTConnection.getTarget(), mappedResult.getTarget()); }
@Test public void checkISCSISStorageConnectionsMappingsToBll() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setIqn("iqn.my.target1"); connection.setPort("3260"); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI); connection.setConnection("1.2.135.255"); connection.setUserName("myuser1"); connection.setPassword("123"); StorageConnection RESTConnection = new StorageConnection(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.ISCSI); RESTConnection.setPort(3260); RESTConnection.setTarget("iqn.my.target1"); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setUsername("myuser1"); RESTConnection.setPassword("123"); StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null); assertEquals(mappedResult.getId(), mappedResult.getId()); assertEquals(mappedResult.getStorageType(), mappedResult.getStorageType()); assertEquals(mappedResult.getConnection(), mappedResult.getConnection()); assertEquals(mappedResult.getIqn(), mappedResult.getIqn()); assertEquals(mappedResult.getUserName(), mappedResult.getUserName()); assertEquals(mappedResult.getPassword(), mappedResult.getPassword()); assertEquals(mappedResult.getPort(), mappedResult.getPort()); }