mirror of https://github.com/apache/jclouds.git
Implemented listConfigurationEntries API
This commit is contained in:
parent
3870313e95
commit
de9691cccb
|
@ -21,6 +21,8 @@ package org.jclouds.cloudstack;
|
||||||
import org.jclouds.cloudstack.features.GlobalAccountAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalAccountAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalConfigurationAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalConfigurationClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
|
||||||
|
@ -90,4 +92,11 @@ public interface CloudStackGlobalAsyncClient extends CloudStackDomainAsyncClient
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
GlobalUsageAsyncClient getUsageClient();
|
GlobalUsageAsyncClient getUsageClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to Configuration
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
@Override
|
||||||
|
GlobalConfigurationAsyncClient getConfigurationClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.cloudstack.features.GlobalAccountClient;
|
import org.jclouds.cloudstack.features.GlobalAccountClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalAlertClient;
|
import org.jclouds.cloudstack.features.GlobalAlertClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalCapacityClient;
|
import org.jclouds.cloudstack.features.GlobalCapacityClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalConfigurationClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostClient;
|
import org.jclouds.cloudstack.features.GlobalHostClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
|
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
|
||||||
|
@ -94,4 +95,11 @@ public interface CloudStackGlobalClient extends CloudStackDomainClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
GlobalUsageClient getUsageClient();
|
GlobalUsageClient getUsageClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to Configuration
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
@Override
|
||||||
|
GlobalConfigurationClient getConfigurationClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalAlertClient;
|
import org.jclouds.cloudstack.features.GlobalAlertClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalCapacityClient;
|
import org.jclouds.cloudstack.features.GlobalCapacityClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalConfigurationAsyncClient;
|
||||||
|
import org.jclouds.cloudstack.features.GlobalConfigurationClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalHostClient;
|
import org.jclouds.cloudstack.features.GlobalHostClient;
|
||||||
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
|
||||||
|
@ -138,6 +140,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
||||||
.put(GuestOSClient.class, GuestOSAsyncClient.class)//
|
.put(GuestOSClient.class, GuestOSAsyncClient.class)//
|
||||||
.put(HypervisorClient.class, HypervisorAsyncClient.class)//
|
.put(HypervisorClient.class, HypervisorAsyncClient.class)//
|
||||||
.put(ConfigurationClient.class, ConfigurationAsyncClient.class)//
|
.put(ConfigurationClient.class, ConfigurationAsyncClient.class)//
|
||||||
|
.put(GlobalConfigurationClient.class, GlobalConfigurationAsyncClient.class)//
|
||||||
.put(AccountClient.class, AccountAsyncClient.class)//
|
.put(AccountClient.class, AccountAsyncClient.class)//
|
||||||
.put(DomainAccountClient.class, DomainAccountAsyncClient.class)//
|
.put(DomainAccountClient.class, DomainAccountAsyncClient.class)//
|
||||||
.put(DomainUserClient.class, DomainUserAsyncClient.class)//
|
.put(DomainUserClient.class, DomainUserAsyncClient.class)//
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cloudstack.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representation of the API configuration entry response
|
||||||
|
*
|
||||||
|
* @author Andrei Savu
|
||||||
|
*/
|
||||||
|
public class ConfigurationEntry implements Comparable<ConfigurationEntry> {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String category;
|
||||||
|
private String description;
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public Builder category(String category) {
|
||||||
|
this.category = category;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder value(String value) {
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationEntry build() {
|
||||||
|
return new ConfigurationEntry(category, description, name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for deserialization
|
||||||
|
ConfigurationEntry() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private String category;
|
||||||
|
private String description;
|
||||||
|
private String name;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public ConfigurationEntry(String category, String description, String name, String value) {
|
||||||
|
this.category = category;
|
||||||
|
this.description = description;
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(ConfigurationEntry arg0) {
|
||||||
|
return name.compareTo(arg0.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
ConfigurationEntry that = (ConfigurationEntry) o;
|
||||||
|
|
||||||
|
if (category != null ? !category.equals(that.category) : that.category != null)
|
||||||
|
return false;
|
||||||
|
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||||
|
return false;
|
||||||
|
if (name != null ? !name.equals(that.name) : that.name != null)
|
||||||
|
return false;
|
||||||
|
if (value != null ? !value.equals(that.value) : that.value != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = category != null ? category.hashCode() : 0;
|
||||||
|
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||||
|
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||||
|
result = 31 * result + (value != null ? value.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ConfigurationEntry{" +
|
||||||
|
"category='" + category + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", value='" + value + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||||
|
import org.jclouds.cloudstack.filters.QuerySigner;
|
||||||
|
import org.jclouds.cloudstack.options.ListConfigurationEntriesOptions;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to CloudStack Configuration features available to Global
|
||||||
|
* Admin users.
|
||||||
|
*
|
||||||
|
* @author Andrei Savu
|
||||||
|
* @see <a href=
|
||||||
|
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
@RequestFilters(QuerySigner.class)
|
||||||
|
@QueryParams(keys = "response", values = "json")
|
||||||
|
public interface GlobalConfigurationAsyncClient extends ConfigurationAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see GlobalConfigurationClient#listConfigurationEntries
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@QueryParams(keys = "command", values = "listConfigurations")
|
||||||
|
@SelectJson("configuration")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<ConfigurationEntry>> listConfigurationEntries(ListConfigurationEntriesOptions... options);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
|
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||||
|
import org.jclouds.cloudstack.options.ListConfigurationEntriesOptions;
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to CloudStack Configuration features available to Global
|
||||||
|
* Admin users.
|
||||||
|
*
|
||||||
|
* @author Andrei Savu
|
||||||
|
* @see <a href=
|
||||||
|
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html"
|
||||||
|
* />
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface GlobalConfigurationClient extends ConfigurationClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all configuration entries
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
* result set filtering options
|
||||||
|
* @return
|
||||||
|
* a set of entries or empty
|
||||||
|
*/
|
||||||
|
Set<ConfigurationEntry> listConfigurationEntries(ListConfigurationEntriesOptions... options);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.options;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options used to control what configuration entries are returned
|
||||||
|
*
|
||||||
|
* @see <a href=
|
||||||
|
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/global_admin/listConfigurations.html"
|
||||||
|
* />
|
||||||
|
* @author Andrei Savu
|
||||||
|
*/
|
||||||
|
public class ListConfigurationEntriesOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
|
public static final ListConfigurationEntriesOptions NONE = new ListConfigurationEntriesOptions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param category
|
||||||
|
* list by category name
|
||||||
|
*/
|
||||||
|
public ListConfigurationEntriesOptions category(String category) {
|
||||||
|
this.queryParameters.replaceValues("category", ImmutableSet.of(category));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param keyword
|
||||||
|
* list by keyword
|
||||||
|
*/
|
||||||
|
public ListConfigurationEntriesOptions keyword(String keyword) {
|
||||||
|
this.queryParameters.replaceValues("keyword", ImmutableSet.of(keyword));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* list by entry name
|
||||||
|
*/
|
||||||
|
public ListConfigurationEntriesOptions name(String name) {
|
||||||
|
this.queryParameters.replaceValues("name", ImmutableSet.of(name));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListConfigurationEntriesOptions page(long page) {
|
||||||
|
this.queryParameters.replaceValues("page", ImmutableSet.of(page + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListConfigurationEntriesOptions pageSize(long pageSize) {
|
||||||
|
this.queryParameters.replaceValues("pagesize", ImmutableSet.of(pageSize + ""));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListConfigurationEntriesOptions#category
|
||||||
|
*/
|
||||||
|
public static ListConfigurationEntriesOptions category(String category) {
|
||||||
|
ListConfigurationEntriesOptions options = new ListConfigurationEntriesOptions();
|
||||||
|
return options.category(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListConfigurationEntriesOptions#keyword
|
||||||
|
*/
|
||||||
|
public static ListConfigurationEntriesOptions keyword(String keyword) {
|
||||||
|
ListConfigurationEntriesOptions options = new ListConfigurationEntriesOptions();
|
||||||
|
return options.keyword(keyword);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListConfigurationEntriesOptions#name
|
||||||
|
*/
|
||||||
|
public static ListConfigurationEntriesOptions name(String name) {
|
||||||
|
ListConfigurationEntriesOptions options = new ListConfigurationEntriesOptions();
|
||||||
|
return options.name(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListConfigurationEntriesOptions#page
|
||||||
|
*/
|
||||||
|
public static ListConfigurationEntriesOptions page(long page) {
|
||||||
|
ListConfigurationEntriesOptions options = new ListConfigurationEntriesOptions();
|
||||||
|
return options.page(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListConfigurationEntriesOptions#pageSize
|
||||||
|
*/
|
||||||
|
public static ListConfigurationEntriesOptions pageSize(long pageSize) {
|
||||||
|
ListConfigurationEntriesOptions options = new ListConfigurationEntriesOptions();
|
||||||
|
return options.pageSize(pageSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.CloudStackClient;
|
||||||
|
import org.jclouds.cloudstack.CloudStackGlobalClient;
|
||||||
|
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||||
|
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||||
|
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||||
|
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the CloudStack GlobalConfigurationClient
|
||||||
|
*
|
||||||
|
* @author Andrei Savu
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "GlobalConfigurationClientExpectTest")
|
||||||
|
public class GlobalConfigurationClientExpectTest extends BaseRestClientExpectTest<CloudStackGlobalClient> {
|
||||||
|
|
||||||
|
public GlobalConfigurationClientExpectTest() {
|
||||||
|
provider = "cloudstack";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = false)
|
||||||
|
public void testListConfigurationEntriesWhenResponseIs2xx() {
|
||||||
|
GlobalConfigurationClient client = requestSendsResponse(
|
||||||
|
HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(
|
||||||
|
URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&" +
|
||||||
|
"apiKey=identity&signature=MktZKKH3USVKiC9SlYTSHMCaCcg%3D"))
|
||||||
|
.headers(
|
||||||
|
ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Accept", "application/json")
|
||||||
|
.build())
|
||||||
|
.build(),
|
||||||
|
HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResource("/listconfigurationsresponse.json"))
|
||||||
|
.build())
|
||||||
|
.getConfigurationClient();
|
||||||
|
|
||||||
|
assertEquals(client.listConfigurationEntries(),
|
||||||
|
ImmutableSet.of(
|
||||||
|
ConfigurationEntry.builder().category("Advanced").name("account.cleanup.interval").value("86400")
|
||||||
|
.description("The interval (in seconds) between cleanup for removed accounts").build(),
|
||||||
|
ConfigurationEntry.builder().category("Advanced").name("agent.lb.enabled").value("true")
|
||||||
|
.description("If agent load balancing enabled in cluster setup").build()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.testng.collections.Sets;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code GlobalConfigurationClient}
|
||||||
|
*
|
||||||
|
* @author Andrei Savu
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", singleThreaded = true, testName = "GlobalConfigurationClientLiveTest")
|
||||||
|
public class GlobalConfigurationClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListConfigurationEntries() {
|
||||||
|
assert globalAdminEnabled;
|
||||||
|
|
||||||
|
Set<ConfigurationEntry> entries = globalAdminClient
|
||||||
|
.getConfigurationClient().listConfigurationEntries();
|
||||||
|
|
||||||
|
Set<String> categories = Sets.newHashSet();
|
||||||
|
for(ConfigurationEntry entry : entries) {
|
||||||
|
checkConfigurationEntry(entry);
|
||||||
|
categories.add(entry.getCategory());
|
||||||
|
}
|
||||||
|
|
||||||
|
assert categories.containsAll(ImmutableSet.<Object>of("Network", "Advanced", "Premium",
|
||||||
|
"Storage", "Usage", "Snapshots", "Account Defaults", "Console Proxy", "Alert"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkConfigurationEntry(ConfigurationEntry entry) {
|
||||||
|
assert entry.getCategory() != null : entry;
|
||||||
|
assert entry.getDescription() != null : entry;
|
||||||
|
assert entry.getName() != null : entry;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.cloudstack.parse;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import org.jclouds.cloudstack.config.CloudStackParserModule;
|
||||||
|
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||||
|
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andrei Savu
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class ListConfigurationEntriesResponseTest extends BaseSetParserTest<ConfigurationEntry> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Injector injector() {
|
||||||
|
return Guice.createInjector(new CloudStackParserModule(), new GsonModule() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||||
|
super.configure();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/listconfigurationsresponse.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson("configuration")
|
||||||
|
public Set<ConfigurationEntry> expected() {
|
||||||
|
return ImmutableSet.of(
|
||||||
|
ConfigurationEntry.builder().category("Advanced").name("account.cleanup.interval").value("86400")
|
||||||
|
.description("The interval (in seconds) between cleanup for removed accounts").build(),
|
||||||
|
ConfigurationEntry.builder().category("Advanced").name("agent.lb.enabled").value("true")
|
||||||
|
.description("If agent load balancing enabled in cluster setup").build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{ "listconfigurationsresponse" : { "count":2 ,"configuration" : [
|
||||||
|
{"category":"Advanced","name":"account.cleanup.interval","value":"86400","description":"The interval (in seconds) between cleanup for removed accounts"},
|
||||||
|
{"category":"Advanced","name":"agent.lb.enabled","value":"true","description":"If agent load balancing enabled in cluster setup"}]
|
||||||
|
}}
|
Loading…
Reference in New Issue