public static StorageServerConnections copyOf(StorageServerConnections ssc) { // using the constructor since all fields do not need deep copy (string // is immutable, and storageType and nfsVersion are enums return new StorageServerConnections(ssc.connection, ssc.id, ssc.iqn, ssc.password, ssc.storageType, ssc.username, ssc.port, ssc.portal, ssc.vfsType, ssc.mountOptions, ssc.nfsVersion, ssc.nfsRetrans, ssc.nfsTimeo, ssc.glusterVolumeId); }
public static StorageServerConnections getConnection(StorageType storageType, String address, String target, String userName, String password, Integer port) { return new StorageServerConnections(address, null, target, password, storageType, userName, port == null ? null : Integer.toString(port), StorageServerConnections.DEFAULT_TPGT); }
@Override protected StorageServerConnections getEntity(int index) { StorageServerConnections entity = new StorageServerConnections(); entity.setId(GUIDS[index].toString()); return entity; }
@Override public Response remove() { get(); StorageServerConnections connection = new StorageServerConnections(); connection.setId(id); String host = ParametersHelper.getParameter(httpHeaders, uriInfo, HOST); Guid hostId = Guid.Empty; if (host != null) { hostId = getHostId(host); } StorageServerConnectionParametersBase parameters = new StorageServerConnectionParametersBase(connection, hostId, false); return performAction(ActionType.RemoveStorageServerConnection, parameters); }
protected List<LUNs> setUpLuns() { StorageServerConnections cnx = new StorageServerConnections(); cnx.setConnection(ADDRESSES[0]); cnx.setIqn(TARGET); cnx.setPort(Integer.toString(PORT)); LUNs lun = new LUNs(); lun.setLUNId(LUN); lun.setLunConnections(new ArrayList<>()); lun.getLunConnections().add(cnx); List<LUNs> luns = new ArrayList<>(); luns.add(lun); return luns; }
static StorageServerConnections setUpStorageServerConnection() { StorageServerConnections cnx = new StorageServerConnections(); cnx.setId(GUIDS[0].toString()); cnx.setConnection("10.11.12.13" + ":" + "/1"); return cnx; }
private StorageServerConnections setUpConnectionExpectations() { StorageServerConnections connection = new StorageServerConnections(); connection.setId(STORAGE_CONNECTION_ID.toString()); connection.setConnection("10.11.12.13" + ":" + "/1"); return connection; }
@Override protected StorageServerConnections getEntity(int index) { StorageServerConnections cnx = new StorageServerConnections(); cnx.setId(GUIDS[index].toString()); cnx.setConnection("10.11.12.13" + ":" + "/1"); return cnx; }
@Override protected StorageServerConnections getEntity(int index) { StorageServerConnections cnx = new StorageServerConnections(); cnx.setId(GUIDS[index].toString()); cnx.setConnection("10.11.12.13" + ":" + "/1"); return cnx; }
@Override protected StorageServerConnections generateNewEntity() { StorageServerConnections newServerConnection = new StorageServerConnections(); newServerConnection.setId("0cc146e8-e5ed-482c-8814-270bc48c2980"); newServerConnection.setConnection(EXISTING_DOMAIN_STORAGE_NAME); newServerConnection.setNfsVersion(NfsVersion.V4); newServerConnection.setNfsRetrans((short) 5); return newServerConnection; }
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; }
@Override protected void readLunDisk(XmlNode node, LunDisk lun) { lun.setDiskVmElements(Collections.singletonList(new DiskVmElement(lun.getId(), fullEntityOvfData.getVmBase().getId()))); LUNs luns = new LUNs(); consumeReadXmlAttribute(node, OVF_PREFIX + COLON + LUN_ID, val -> luns.setLUNId(val)); ArrayList<StorageServerConnections> lunConnections = new ArrayList<>(); for (XmlNode connNode : selectNodes(node, LUN_CONNECTION)) { StorageServerConnections conn = new StorageServerConnections(); consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_CONNECTION, val -> conn.setConnection(val)); consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_IQN, val -> conn.setIqn(val)); consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_PORT, val -> conn.setPort(val)); consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_STORAGE_TYPE, val -> conn.setStorageType(StorageType.valueOf(val))); consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_PORTAL, val -> conn.setPortal(val)); lunConnections.add(conn); } luns.setLunConnections(lunConnections); lun.setLun(luns); DiskVmElement dve = lun.getDiskVmElementForVm(fullEntityOvfData.getVmBase().getId()); initGeneralDiskAttributes(node, lun, dve); }
static StorageServerConnections setUpStorageServerConnection(int idIndex, int index, StorageType storageType) { StorageServerConnections cnx = new StorageServerConnections(); if (idIndex != -1) { cnx.setId(GUIDS[idIndex].toString()); } if (storageType == StorageType.LOCALFS) { cnx.setConnection(PATHS[index]); } else if (storageType == StorageType.POSIXFS) { cnx.setConnection(ADDRESSES[index] + ":" + PATHS[index]); cnx.setMountOptions(MOUNT_OPTIONS[index]); cnx.setVfsType(VFS_TYPES[index]); } else { cnx.setConnection(ADDRESSES[index] + ":" + PATHS[index]); } cnx.setStorageType(STORAGE_TYPES_MAPPED[index]); return cnx; }
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; }
@Test public void testRemove() { setUpGetEntityExpectations(); Host host = new Host(); host.setId(GUIDS[1].toString()); StorageServerConnections connection = new StorageServerConnections(); connection.setId(GUIDS[3].toString()); connection.setConnection("/data1"); UriInfo uriInfo = setUpActionExpectations( ActionType.RemoveStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection", "VdsId" }, new Object[] { connection, GUIDS[1] }, true, true, false ); uriInfo = addMatrixParameterExpectations( uriInfo, BackendStorageServerConnectionResource.HOST, GUIDS[1].toString() ); setUriInfo(uriInfo); verifyRemove(resource.remove()); }
@Test public void testRemoveValidateFail() { setUpGetEntityExpectations(); Host host = new Host(); host.setId(GUIDS[1].toString()); StorageServerConnections connection = new StorageServerConnections(); connection.setId(GUIDS[3].toString()); connection.setConnection("/data1"); UriInfo uriInfo = setUpActionExpectations( ActionType.RemoveStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection", "VdsId" }, new Object[] { connection, GUIDS[1] }, false, false, false ); uriInfo = addMatrixParameterExpectations( uriInfo, BackendStorageServerConnectionResource.HOST, GUIDS[1].toString() ); setUriInfo(uriInfo); verifyBadRequest(assertThrows(WebApplicationException.class, () -> resource.remove())); }
@Test public void testAddFailure() { setUriInfo(setUpBasicUriExpectations()); Host host = new Host(); host.setId(GUIDS[1].toString()); StorageServerConnections connection = new StorageServerConnections(); connection.setConnection("1.1.1.1:/data1"); connection.setStorageType(STORAGE_TYPES_MAPPED[0]); setUpCreationExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { connection.getConnection(), STORAGE_TYPES_MAPPED[0], GUIDS[1] }, false, false, GUIDS[0].toString(), QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[0].toString() }, getEntity(0)); verifyBadRequest(assertThrows(WebApplicationException.class, () -> collection.add(getModel(0)))); }
@Test public void checkPosixStorageConnectionsMappingsToBll() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.POSIXFS); connection.setConnection("1.2.135.255:/myshare/data"); connection.setVfsType("nfs"); connection.setMountOptions("timeo=30"); StorageConnection RESTConnection = new StorageConnection(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.POSIXFS); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setPath("/myshare/data"); RESTConnection.setVfsType("nfs"); RESTConnection.setMountOptions("timeo=30"); StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null); assertEquals(connection.getId(), mappedResult.getId()); assertEquals(connection.getStorageType(), mappedResult.getStorageType()); assertEquals(connection.getConnection(), mappedResult.getConnection()); assertEquals(connection.getVfsType(), mappedResult.getVfsType()); assertEquals(connection.getMountOptions(), mappedResult.getMountOptions()); }