Search in sources :

Example 46 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class VMConsoleProxyServlet method availablePublicKeys.

// TODO: implmement key filtering based on input parameters
private List<Map<String, String>> availablePublicKeys(String keyFingerPrint, String keyType, String keyContent) {
    List<Map<String, String>> jsonUsers = new ArrayList<>();
    QueryParametersBase userProfileParams = new QueryParametersBase();
    QueryReturnValue v = backend.runInternalQuery(QueryType.GetAllUserProfiles, userProfileParams);
    if (v != null) {
        List<UserProfile> profiles = v.getReturnValue();
        for (UserProfile profile : profiles) {
            if (StringUtils.isNotEmpty(profile.getSshPublicKey())) {
                for (String publicKey : StringUtils.split(profile.getSshPublicKey(), "\n")) {
                    if (StringUtils.isNotEmpty(publicKey)) {
                        Map<String, String> jsonUser = new HashMap<>();
                        jsonUser.put("entityid", profile.getUserId().toString());
                        jsonUser.put("entity", profile.getLoginName());
                        jsonUser.put("key", publicKey.trim());
                        jsonUsers.add(jsonUser);
                    }
                }
            }
        }
    }
    return jsonUsers;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UserProfile(org.ovirt.engine.core.common.businessentities.UserProfile) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) HashMap(java.util.HashMap) Map(java.util.Map)

Example 47 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class BackendGroupsResource method add.

@Override
public Response add(Group group) {
    List<String> authzProvidersNames = getBackendCollection(String.class, QueryType.GetDomainList, new QueryParametersBase());
    validateParameters(group, "name");
    if (AuthzUtils.getAuthzNameFromEntityName(group.getName(), authzProvidersNames) == null) {
        validateParameters(group, "domain.id|name");
    }
    String directoryName = getAuthzProviderName(group, authzProvidersNames);
    DirectoryGroup directoryGroup = findDirectoryGroup(directoryName, group);
    if (directoryGroup == null) {
        return Response.status(Status.BAD_REQUEST).entity("No such group: " + group.getName() + " in directory " + directoryName).build();
    }
    AddGroupParameters parameters = new AddGroupParameters();
    parameters.setGroupToAdd(new DbGroup(directoryGroup));
    QueryIdResolver<Guid> resolver = new QueryIdResolver<>(QueryType.GetDbGroupById, IdQueryParameters.class);
    return performCreate(ActionType.AddGroup, parameters, resolver, BaseResource.class);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters)

Example 48 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class BackendOpenStackStorageProviderHelper method getStorageDomainId.

/**
 * Finds the identifier of the storage domain corresponding to the given provider.
 *
 * @param resource the resource that will be used to perform the operation
 * @param providerId identifier of the provider
 * @return the identifier of the corresponding storage domain or {@code null} if no such storage domain exists
 */
public static Guid getStorageDomainId(BackendResource resource, String providerId) {
    // The backend doesn't have any mechanism to obtain the images other than listing the images provided by the
    // storage domain that is created for the provider, and the only way to find that provider is to iterate the
    // complete list. This is potentially very slow, so it should be improved in the future.
    Guid storageDomainId = null;
    List<StorageDomain> storageDomains = resource.runQuery(QueryType.GetAllStorageDomains, new QueryParametersBase()).getReturnValue();
    for (StorageDomain storageDomain : storageDomains) {
        String storageId = storageDomain.getStorage();
        if (providerId.equals(storageId)) {
            storageDomainId = storageDomain.getId();
            break;
        }
    }
    return storageDomainId;
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid)

Example 49 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class ClusterModel method initMacPools.

private void initMacPools() {
    setMacPoolListModel(new SortedListModel<>(Linq.SharedMacPoolComparator));
    setMacPoolModel(new MacPoolModel());
    getMacPoolModel().setIsChangeable(false);
    getMacPoolListModel().getItemsChangedEvent().addListener(this);
    getMacPoolListModel().getSelectedItemChangedEvent().addListener(this);
    startProgress();
    Frontend.getInstance().runQuery(QueryType.GetAllMacPools, new QueryParametersBase(), new AsyncQuery<QueryReturnValue>(returnValue -> {
        getMacPoolListModel().setItems(returnValue.getReturnValue());
        stopProgress();
    }));
}
Also used : MacPoolModel(org.ovirt.engine.ui.uicommonweb.models.macpool.MacPoolModel) Arrays(java.util.Arrays) Provider(org.ovirt.engine.core.common.businessentities.Provider) Event(org.ovirt.engine.ui.uicompat.Event) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) SwitchType(org.ovirt.engine.core.common.network.SwitchType) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) Version(org.ovirt.engine.core.compat.Version) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SortedListModel(org.ovirt.engine.ui.uicommonweb.models.SortedListModel) ClusterPolicy(org.ovirt.engine.core.common.scheduling.ClusterPolicy) AdditionalFeature(org.ovirt.engine.core.common.businessentities.AdditionalFeature) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) MigrationBandwidthLimitType(org.ovirt.engine.core.common.businessentities.MigrationBandwidthLimitType) HasValidatedTabs(org.ovirt.engine.ui.uicommonweb.models.HasValidatedTabs) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation) StringHelper(org.ovirt.engine.core.compat.StringHelper) SerialNumberPolicyModel(org.ovirt.engine.ui.uicommonweb.models.vms.SerialNumberPolicyModel) Objects(java.util.Objects) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) List(java.util.List) MigrateOnErrorOptions(org.ovirt.engine.core.common.businessentities.MigrateOnErrorOptions) VmRngDevice(org.ovirt.engine.core.common.businessentities.VmRngDevice) ValidationCompleteEvent(org.ovirt.engine.ui.uicommonweb.models.ValidationCompleteEvent) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ProviderType(org.ovirt.engine.core.common.businessentities.ProviderType) FilteredListModel(org.ovirt.engine.ui.uicommonweb.models.FilteredListModel) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) HostWithProtocolAndPortAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostWithProtocolAndPortAddressValidation) Guid(org.ovirt.engine.core.compat.Guid) ServerCpu(org.ovirt.engine.core.common.businessentities.ServerCpu) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) NoMigrationPolicy(org.ovirt.engine.core.common.migration.NoMigrationPolicy) Frontend(org.ovirt.engine.ui.frontend.Frontend) NotNullIntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.NotNullIntegerValidation) Network(org.ovirt.engine.core.common.businessentities.network.Network) MigrationPolicy(org.ovirt.engine.core.common.migration.MigrationPolicy) Pair(org.ovirt.engine.core.common.utils.Pair) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Linq(org.ovirt.engine.ui.uicommonweb.Linq) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) SerialNumberPolicy(org.ovirt.engine.core.common.businessentities.SerialNumberPolicy) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) SupportedAdditionalClusterFeature(org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature) MacPool(org.ovirt.engine.core.common.businessentities.MacPool) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) FirewallType(org.ovirt.engine.core.common.network.FirewallType) Comparator(java.util.Comparator) Collections(java.util.Collections) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) IdAndNameQueryParameters(org.ovirt.engine.core.common.queries.IdAndNameQueryParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) MacPoolModel(org.ovirt.engine.ui.uicommonweb.models.macpool.MacPoolModel)

Example 50 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase in project ovirt-engine by oVirt.

the class BackendAssignedPermissionsResource method lookupUsers.

private List<DbUser> lookupUsers() {
    QueryParametersBase queryParams = new QueryParametersBase();
    queryParams.setFiltered(isFiltered());
    return getBackendCollection(DbUser.class, QueryType.GetAllDbUsers, queryParams);
}
Also used : QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase)

Aggregations

QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)89 ArrayList (java.util.ArrayList)41 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)40 QueryType (org.ovirt.engine.core.common.queries.QueryType)37 Test (org.junit.Test)33 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)22 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)18 List (java.util.List)15 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)13 HashMap (java.util.HashMap)11 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 HashSet (java.util.HashSet)7 Map (java.util.Map)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Frontend (org.ovirt.engine.ui.frontend.Frontend)6 Collection (java.util.Collection)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)5 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5