Search in sources :

Example 1 with StorageServerConnectionExtension

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;
}
Also used : StorageServerConnectionExtension(org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension)

Example 2 with StorageServerConnectionExtension

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));
}
Also used : StorageServerConnectionExtension(org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension) Test(org.junit.Test)

Example 3 with StorageServerConnectionExtension

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");
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) Guid(org.ovirt.engine.core.compat.Guid) StorageServerConnectionExtension(org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension) Before(org.junit.Before)

Example 4 with StorageServerConnectionExtension

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());
}
Also used : Response(javax.ws.rs.core.Response) StorageServerConnectionExtension(org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension) StorageConnectionExtension(org.ovirt.engine.api.model.StorageConnectionExtension) Test(org.junit.Test)

Example 5 with StorageServerConnectionExtension

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));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) StorageServerConnectionExtensionParameters(org.ovirt.engine.core.common.action.StorageServerConnectionExtensionParameters) StorageServerConnectionExtension(org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

StorageServerConnectionExtension (org.ovirt.engine.core.common.businessentities.storage.StorageServerConnectionExtension)14 Test (org.junit.Test)6 Guid (org.ovirt.engine.core.compat.Guid)4 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)3 StorageServerConnectionExtensionParameters (org.ovirt.engine.core.common.action.StorageServerConnectionExtensionParameters)2 Response (javax.ws.rs.core.Response)1 Before (org.junit.Before)1 StorageConnectionExtension (org.ovirt.engine.api.model.StorageConnectionExtension)1 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1