use of org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension in project ovirt-engine by oVirt.
the class StorageConnectionHelper method getStorageConnectionCredentialsForhost.
public Pair<String, String> getStorageConnectionCredentialsForhost(Guid hostId, StorageServerConnections connection) {
Pair<String, String> credentials;
StorageServerConnectionExtension connExt = storageServerConnectionExtensionDao.getByHostIdAndTarget(hostId, connection.getIqn());
if (connExt == null) {
credentials = new Pair<>(connection.getUserName(), connection.getPassword());
} else {
credentials = new Pair<>(connExt.getUserName(), connExt.getPassword());
}
return credentials;
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension in project ovirt-engine by oVirt.
the class StorageServerConnectionExtensionValidatorTest method testIsConnectionDoesNotExistForHostAndTargetFails.
@Test
public void testIsConnectionDoesNotExistForHostAndTargetFails() {
when(storageServerConnectionExtensionDao.getByHostIdAndTarget(conn.getHostId(), conn.getIqn())).thenReturn(new StorageServerConnectionExtension());
assertThat(validator.isConnectionDoesNotExistForHostAndTarget(conn), failsWith(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_EXTENSION_ALREADY_EXISTS));
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension in project ovirt-engine by oVirt.
the class StorageServerConnectionExtensionValidatorTest method setup.
@Before
public void setup() {
Guid hostId = Guid.newGuid();
doReturn(dbFacade).when(validator).getDbFacade();
doReturn(storageServerConnectionExtensionDao).when(dbFacade).getStorageServerConnectionExtensionDao();
doReturn(vdsDao).when(dbFacade).getVdsDao();
doReturn(new VDS()).when(vdsDao).get(hostId);
conn = new StorageServerConnectionExtension();
conn.setHostId(hostId);
conn.setIqn("iqn1");
conn.setUserName("user1");
conn.setPassword("password1");
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension in project ovirt-engine by oVirt.
the class BackendStorageServerConnectionExtensionsResourceTest method testAdd.
@Test
public void testAdd() throws Exception {
StorageServerConnectionExtension entity = StorageConnectionExtensionResourceTestHelper.getEntity(extensionID, hostID, pass, user, iqn);
setUriInfo(setUpBasicUriExpectations());
setUpCreationExpectations(ActionType.AddStorageServerConnectionExtension, StorageServerConnectionExtensionParameters.class, new String[] { "StorageServerConnectionExtension" }, new Object[] { entity }, true, true, extensionID, QueryType.GetStorageServerConnectionExtensionById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { extensionID }, entity);
Response response = collection.add(StorageConnectionExtensionResourceTestHelper.getModel(extensionID, hostID, pass, user, iqn));
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof StorageConnectionExtension);
assertNotNull(response.getEntity());
assertEquals(((StorageConnectionExtension) response.getEntity()).getId(), entity.getId().toString());
}
use of org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension in project ovirt-engine by oVirt.
the class BackendStorageServerConnectionExtensionsResource method add.
@Override
public Response add(StorageConnectionExtension storageConnectionExtension) {
StorageServerConnectionExtension connExt = StorageServerConnectionExtensionMapper.map(storageConnectionExtension, null);
connExt.setHostId(hostId);
StorageServerConnectionExtensionParameters params = new StorageServerConnectionExtensionParameters(connExt);
return performCreate(ActionType.AddStorageServerConnectionExtension, params, new QueryIdResolver<Guid>(QueryType.GetStorageServerConnectionExtensionById, IdQueryParameters.class));
}
Aggregations