get adminOrg

This commit is contained in:
danikov 2012-03-11 20:34:22 +00:00
parent 5817f04463
commit 8e46d9e9ec
16 changed files with 448 additions and 76 deletions

View File

@ -129,7 +129,7 @@ public class VCloudDirectorMediaType {
public static final String ADMIN_CATALOG = "application/vnd.vmware.admin.catalog+xml";
public static final String ADMIN_ORGANIZATION = "application/vnd.vmware.admin.organization+xml";
public static final String ADMIN_ORG = "application/vnd.vmware.admin.organization+xml";
public static final String PUBLISH_CATALOG_PARAMS = "application/vnd.vmware.admin.publishCatalogParams+xml";
@ -149,8 +149,11 @@ public class VCloudDirectorMediaType {
public static final String ORG_SETTINGS = "application/vnd.vmware.admin.orgSettings+xml";
public static final String ADMIN_NETWORK = "application/vnd.vmware.admin.network+xml";
public static final String ADMIN_ORG_NETWORK = "application/vnd.vmware.admin.orgNetwork+xml";
/**
*
* All acceptable media types.
*
* This list must be updated whenever a new media type constant is added.
@ -162,13 +165,14 @@ public class VCloudDirectorMediaType {
MEDIA, OWNER, VDC, ADMIN_USER, V_APP, V_APP_TEMPLATE,
CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_TEMPLATE_PARAMS,
COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS,
UPLOAD_VAPP_TEMPLATE_PARAMS, ADMIN_CATALOG, ADMIN_ORGANIZATION,
UPLOAD_VAPP_TEMPLATE_PARAMS, ADMIN_CATALOG, ADMIN_ORG,
QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS,
CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION,
NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION,
CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE,
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS,
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS, ADMIN_NETWORK,
ADMIN_ORG_NETWORK
);
}

View File

@ -21,6 +21,9 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@ -145,7 +148,8 @@ public class AdminOrg extends Org {
}
public AdminOrg build() {
return new AdminOrg(settings, users, groups, catalogs, vdcs, networks);
return new AdminOrg(href, type, links, description, tasksInProgress, id,
name, fullName, isEnabled, settings, users, groups, catalogs, vdcs, networks);
}
public T fromAdminOrg(AdminOrg in) {
@ -175,8 +179,11 @@ public class AdminOrg extends Org {
// For JAXB
}
protected AdminOrg(OrgSettings settings, UsersList users, GroupsList groups,
protected AdminOrg(URI href, String type, Set<Link> links, String description,
TasksInProgress tasksInProgress, String id, String name, String fullName,
Boolean enabled, OrgSettings settings, UsersList users, GroupsList groups,
CatalogsList catalogs, Vdcs vdcs, Networks networks) {
super(href, type, links, description, tasksInProgress, id, name, fullName, enabled);
this.settings = settings;
this.users = users;
this.groups = groups;

View File

@ -68,6 +68,14 @@ public class CatalogsList {
return this;
}
/**
* @see CatalogsList#getCatalogItems()
*/
public Builder catalog(Reference catalog) {
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
return this;
}
public CatalogsList build() {
return new CatalogsList(catalogReferences);
}
@ -81,7 +89,7 @@ public class CatalogsList {
// for JAXB
}
private CatalogsList(Set<Reference> tasks) {
private CatalogsList(Set<Reference> catalogReferences) {
this.catalogReferences = ImmutableSet.copyOf(checkNotNull(catalogReferences, "catalogReferences"));
}

View File

@ -62,7 +62,7 @@ import com.google.common.collect.ImmutableList;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "GroupsList")
@XmlType(propOrder = {
"groupReference"
"groups"
})
public class GroupsList {
public static Builder builder() {

View File

@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import org.testng.collections.Lists;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
@ -62,7 +64,7 @@ import com.google.common.collect.ImmutableList;
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Networks", propOrder = {
"network"
"networks"
})
public class Networks {
public static Builder builder() {
@ -75,7 +77,7 @@ public class Networks {
public static class Builder {
private List<Reference> networks;
private List<Reference> networks = Lists.newArrayList();
/**
* @see Networks#getNetwork()

View File

@ -59,8 +59,8 @@ public class Org extends EntityType<Org> {
public static abstract class NewBuilder<T extends NewBuilder<T>> extends EntityType.NewBuilder<T> {
private String fullName;
private Boolean isEnabled;
protected String fullName;
protected Boolean isEnabled;
/**
* @see Org#getFullName()
@ -232,8 +232,10 @@ public class Org extends EntityType<Org> {
// for JAXB
}
public Org(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name, String fullName, Boolean enabled) {
super(href, type, links, description, tasks, id, name);
public Org(URI href, String type, Set<Link> links, String description,
TasksInProgress tasksInProgress, String id, String name,
String fullName, Boolean enabled) {
super(href, type, links, description, tasksInProgress, id, name);
this.fullName = fullName;
isEnabled = enabled;
}

View File

@ -97,7 +97,7 @@ public class OrgSettings extends ResourceType<OrgSettings> {
/**
* @see OrgSettings#getGeneralSettings()
*/
public Builder orgGeneralSettings(OrgGeneralSettings generalSettings) {
public Builder generalSettings(OrgGeneralSettings generalSettings) {
this.generalSettings = generalSettings;
return this;
}
@ -121,7 +121,7 @@ public class OrgSettings extends ResourceType<OrgSettings> {
/**
* @see OrgSettings#getLdapSettings()
*/
public Builder orgLdapSettings(OrgLdapSettings ldapSettings) {
public Builder ldapSettings(OrgLdapSettings ldapSettings) {
this.ldapSettings = ldapSettings;
return this;
}
@ -129,7 +129,7 @@ public class OrgSettings extends ResourceType<OrgSettings> {
/**
* @see OrgSettings#getEmailSettings()
*/
public Builder orgEmailSettings(OrgEmailSettings emailSettings) {
public Builder emailSettings(OrgEmailSettings emailSettings) {
this.emailSettings = emailSettings;
return this;
}
@ -191,11 +191,11 @@ public class OrgSettings extends ResourceType<OrgSettings> {
}
public Builder fromOrgSettings(OrgSettings in) {
return fromResourceType(in)
.orgGeneralSettings(in.getGeneralSettings())
.generalSettings(in.getGeneralSettings())
.vAppLeaseSettings(in.getVAppLeaseSettings())
.vAppTemplateLeaseSettings(in.getVAppTemplateLeaseSettings())
.orgLdapSettings(in.getLdapSettings())
.orgEmailSettings(in.getEmailSettings())
.ldapSettings(in.getLdapSettings())
.emailSettings(in.getEmailSettings())
.passwordPolicy(in.getPasswordPolicy());
}
}

View File

@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.testng.collections.Lists;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
@ -62,7 +64,7 @@ import com.google.common.collect.ImmutableList;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "UsersList")
@XmlType(propOrder = {
"userReference"
"users"
})
public class UsersList {
public static Builder builder() {
@ -74,7 +76,7 @@ public class UsersList {
}
public static class Builder {
private List<Reference> users;
private List<Reference> users = Lists.newArrayList();
/**
* @see UsersList#getUsers()

View File

@ -31,6 +31,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.testng.collections.Lists;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
@ -76,7 +78,7 @@ public class Vdcs {
public static class Builder {
private List<Reference> vdcs;
private List<Reference> vdcs = Lists.newArrayList();
/**
* @see Vdcs#getVdc()

View File

@ -33,6 +33,7 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
@ -52,11 +53,15 @@ import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface AdminOrgAsyncClient extends OrgAsyncClient {
// GET /admin/org/{id}
// POST /admin/org/{id}/catalogs
// POST /admin/org/{id}/groups
/**
* @see AdminOrgClient#getOrg(URI)
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<AdminOrg> getOrg(
@EndpointParam URI orgRef);
/**
* @see AdminOrgClient#getSettings(URI)

View File

@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
@ -40,11 +41,19 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface AdminOrgClient extends OrgClient {
// GET /admin/org/{id}
// POST /admin/org/{id}/catalogs
// POST /admin/org/{id}/groups
/**
* Retrieves an admin view of an organization.
* The organization might be enabled or disabled.
* If enabled, the organization allows login and all other operations.
*
* <pre>
* GET /admin/org/{id}
* </pre>
*
* @param orgRef the reference for the admin org
* @return the admin org
*/
AdminOrg getOrg(URI orgRef);
/**
* Gets organizational settings for this organization.

View File

@ -60,7 +60,7 @@ public interface OrgAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Org> getOrg(@EndpointParam URI orgUri);
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgUri);
/**
* @return asynchronous access to {@link Metadata.Readable} features

View File

@ -232,6 +232,46 @@ public class Checks {
checkEntityType(org);
}
public static void checkAdminOrg(AdminOrg org) {
// required
assertNotNull(org.getSettings(), String.format(NOT_NULL_OBJECT_FMT, "settings", "AdminOrg"));
// optional
if (org.getGroups() != null) {
checkGroupsList(org.getGroups());
}
if (org.getCatalogs() != null) {
checkCatalogsList(org.getCatalogs());
}
if (org.getVdcs() != null) {
checkVdcs(org.getVdcs());
}
if (org.getNetworks() != null) {
checkNetworks(org.getNetworks());
}
// Check parent type
checkOrg(org);
}
public static void checkCatalogsList(CatalogsList catalogList) {
for (Reference catalogItem : catalogList.getCatalogItems()) {
checkReferenceType(catalogItem);
}
}
public static void checkVdcs(Vdcs vdcs) {
for (Reference vdc : vdcs.getVdcs()) {
checkReferenceType(vdc);
}
}
public static void checkNetworks(Networks networks) {
for (Reference network : networks.getNetwork()) {
checkReferenceType(network);
}
}
public static void checkAdminCatalog(AdminCatalog catalog) {
// Check parent type
checkCatalogType(catalog);

View File

@ -24,7 +24,11 @@ import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.CatalogsList;
import org.jclouds.vcloud.director.v1_5.domain.GroupsList;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Networks;
import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgGeneralSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings;
@ -34,6 +38,8 @@ import org.jclouds.vcloud.director.v1_5.domain.OrgSettings;
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.SmtpServerSettings;
import org.jclouds.vcloud.director.v1_5.domain.UsersList;
import org.jclouds.vcloud.director.v1_5.domain.Vdcs;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test;
@ -49,13 +55,151 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
.href(URI.create(endpoint + "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build();
// GET /admin/org/{id}
// POST /admin/org/{id}/catalogs
// POST /admin/org/{id}/groups
@Test
public void testGetOrg() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/org/admin/org.xml",
VCloudDirectorMediaType.ADMIN_ORG)
.httpResponseBuilder().build());
AdminOrg expected = adminOrg();
assertEquals(client.getAdminOrgClient().getOrg(orgRef.getURI()), expected);
}
public static final AdminOrg adminOrg() {
return AdminOrg.builder()
.name("JClouds")
.id("urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0")
.type("application/vnd.vmware.admin.organization+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.vcloud.tasksList+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
.build())
.link(Link.builder()
.rel("add")
.type("application/vnd.vmware.admin.catalog+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalogs"))
.build())
.link(Link.builder()
.rel("add")
.type("application/vnd.vmware.admin.user+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/users"))
.build())
.link(Link.builder()
.rel("add")
.type("application/vnd.vmware.admin.group+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/groups"))
.build())
.link(Link.builder()
.rel("add")
.type("application/vnd.vmware.admin.orgNetwork+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/networks"))
.build())
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.admin.organization+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.link(Link.builder()
.rel("remove")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.link(Link.builder()
.rel("alternate")
.type("application/vnd.vmware.vcloud.org+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.description("")
.fullName("JClouds")
.isEnabled(true)
.settings(settings())
.users(UsersList.builder()
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adam.lowe@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/672ebb67-d8ff-4201-9c1b-c1be869e526c"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adrian@jclouds.org")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/8c360b93-ed25-4c9a-8e24-d48cd9966d93"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("qunying.huang@enstratus.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("dan@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/ae75edd2-12de-414c-8e85-e6ea10442c08"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build())
.build())
.groups(GroupsList.builder()
.build())
.catalogs(CatalogsList.builder()
.catalog(Reference.builder()
.type("application/vnd.vmware.admin.catalog+xml")
.name("QunyingTestCatalog")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
.build())
.catalog(Reference.builder()
.type("application/vnd.vmware.admin.catalog+xml")
.name("Public")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"))
.build())
.catalog(Reference.builder()
.type("application/vnd.vmware.admin.catalog+xml")
.name("dantest")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b542aff4-9f97-4f51-a126-4330fbf62f02"))
.build())
.catalog(Reference.builder()
.type("application/vnd.vmware.admin.catalog+xml")
.name("test")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da"))
.build())
.build())
.vdcs(Vdcs.builder()
.vdc(Reference.builder()
.type("application/vnd.vmware.vcloud.vdc+xml")
.name("Cluster01-JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
.build())
.build())
.networks(Networks.builder()
.network(Reference.builder()
.type("application/vnd.vmware.admin.network+xml")
.name("ilsolation01-Jclouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
.build())
.network(Reference.builder()
.type("application/vnd.vmware.admin.network+xml")
.name("internet01-Jclouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
.build())
.build())
.build();
}
@Test(enabled = false)
public void testGetSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
@ -74,18 +218,53 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
public static final OrgSettings settings() {
return OrgSettings.builder()
.type("application/vnd.vmware.admin.organizationSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/"))
.type("application/vnd.vmware.admin.orgSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings"))
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.admin.organizationEmailSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.admin.vAppLeaseSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.admin.organizationGeneralSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.admin.organizationLdapSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap"))
.build())
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.admin.organizationSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/"))
.type("application/vnd.vmware.admin.orgSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings"))
.build())
.generalSettings(generalSettings())
.vAppLeaseSettings(vAppLeaseSettings())
.vAppTemplateLeaseSettings(vAppTemplateLeaseSettings())
.ldapSettings(ldapSettings())
.emailSettings(emailSettings())
.passwordPolicy(passwordPolicy())
.build();
}
@Test
@Test(enabled = false)
public void testUpdateSettings() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
@ -204,7 +383,18 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
public static final OrgGeneralSettings generalSettings() {
return OrgGeneralSettings.builder()
.type("application/vnd.vmware.admin.organizationGeneralSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"))
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.admin.organizationGeneralSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"))
.build())
.canPublishCatalogs(false)
.deployedVMQuota(0)
.storedVmQuota(0)
.useServerBootSequence(false)
.delayAfterPowerOnSeconds(0)
.build();
}
@ -270,12 +460,12 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
VCloudDirectorMediaType.ORG_PASSWORD_POLICY_SETTINGS)
.httpResponseBuilder().build());
OrgPasswordPolicySettings expected = orgPasswordPolicy();
OrgPasswordPolicySettings expected = passwordPolicy();
assertEquals(client.getAdminOrgClient().getPasswordPolicy(orgRef.getURI()), expected);
}
public static final OrgPasswordPolicySettings orgPasswordPolicy() {
public static final OrgPasswordPolicySettings passwordPolicy() {
return OrgPasswordPolicySettings.builder()
.type("application/vnd.vmware.admin.organizationPasswordPolicySettings+xml")
.link(Link.builder()
@ -310,7 +500,7 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
}
public static final OrgPasswordPolicySettings updateOrgPasswordPolicy() {
return orgPasswordPolicy().toBuilder()
return passwordPolicy().toBuilder()
.accountLockoutEnabled(true)
.invalidLoginsBeforeLockout(6)
.accountLockoutIntervalMinutes(11)
@ -329,14 +519,23 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
.httpResponseBuilder().build());
OrgLeaseSettings expected = orgVAppLeaseSettings();
OrgLeaseSettings expected = vAppLeaseSettings();
assertEquals(client.getAdminOrgClient().getVAppLeaseSettings(orgRef.getURI()), expected);
}
public static final OrgLeaseSettings orgVAppLeaseSettings() {
public static final OrgLeaseSettings vAppLeaseSettings() {
return OrgLeaseSettings.builder()
.type("application/vnd.vmware.admin.vAppLeaseSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"))
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.admin.vAppLeaseSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"))
.build())
.deleteOnStorageLeaseExpiration(false)
.deploymentLeaseSeconds(0)
.storageLeaseSeconds(0)
.build();
}
@ -354,13 +553,13 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
.httpResponseBuilder().build());
OrgLeaseSettings expected = updateOrgVAppLeaseSettings();
OrgLeaseSettings expected = updateVAppLeaseSettings();
assertEquals(client.getAdminOrgClient().updateVAppLeaseSettings(orgRef.getURI(), expected), expected);
}
public static final OrgLeaseSettings updateOrgVAppLeaseSettings() {
return orgVAppLeaseSettings().toBuilder()
public static final OrgLeaseSettings updateVAppLeaseSettings() {
return vAppLeaseSettings().toBuilder()
.build();
}
@ -377,14 +576,22 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)
.httpResponseBuilder().build());
OrgVAppTemplateLeaseSettings expected = orgVAppTemplateLeaseSettings();
OrgVAppTemplateLeaseSettings expected = vAppTemplateLeaseSettings();
assertEquals(client.getAdminOrgClient().getVAppTemplateLeaseSettings(orgRef.getURI()), expected);
}
public static final OrgVAppTemplateLeaseSettings orgVAppTemplateLeaseSettings() {
public static final OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings() {
return OrgVAppTemplateLeaseSettings.builder()
.type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"))
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"))
.build())
.deleteOnStorageLeaseExpiration(false)
.storageLeaseSeconds(0)
.build();
}
@ -402,13 +609,13 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
VCloudDirectorMediaType.ORG_VAPP_TEMPLATE_LEASE_SETTINGS)
.httpResponseBuilder().build());
OrgVAppTemplateLeaseSettings expected = updateOrgVAppTemplateLeaseSettings();
OrgVAppTemplateLeaseSettings expected = updateVAppTemplateLeaseSettings();
assertEquals(client.getAdminOrgClient().updateVAppTemplateLeaseSettings(orgRef.getURI(), expected), expected);
}
public static final OrgVAppTemplateLeaseSettings updateOrgVAppTemplateLeaseSettings() {
return orgVAppTemplateLeaseSettings().toBuilder()
public static final OrgVAppTemplateLeaseSettings updateVAppTemplateLeaseSettings() {
return vAppTemplateLeaseSettings().toBuilder()
.build();
}

View File

@ -59,7 +59,6 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
* Shared state between dependant tests.
*/
private ReferenceType<?> orgRef;
private AdminOrg org;
private OrgSettings settings, newSettings;
private OrgEmailSettings emailSettings, newEmailSettings;
private OrgGeneralSettings generalSettings, newGeneralSettings;
@ -76,13 +75,12 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertNotNull(orgRef, String.format(REF_REQ_LIVE, "admin org"));
}
// GET /admin/org/{id}
// POST /admin/org/{id}/catalogs
// POST /admin/org/{id}/groups
@Test(testName = "GET /admin/org/{id}")
public void testGetAdminOrg() {
AdminOrg adminOrg = orgClient.getOrg(orgRef.getURI());
Checks.checkAdminOrg(adminOrg);
}
@Test(testName = "GET /admin/org/{id}/settings/emailSettings")
public void testGetEmailSettings() {
@ -391,11 +389,11 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void testUpdateSettings() {
try {
newSettings = settings.toBuilder()
.orgGeneralSettings(newGeneralSettings)
.generalSettings(newGeneralSettings)
.vAppLeaseSettings(newVAppLeaseSettings)
.vAppTemplateLeaseSettings(newVAppTemplateLeaseSettings)
.orgLdapSettings(newLdapSettings)
.orgEmailSettings(newEmailSettings)
.ldapSettings(newLdapSettings)
.emailSettings(newEmailSettings)
.passwordPolicy(newPasswordPolicy)
.build();
@ -426,11 +424,11 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Checks.checkOrgSettings(settings);
} finally {
settings = settings.toBuilder()
.orgGeneralSettings(generalSettings)
.generalSettings(generalSettings)
.vAppLeaseSettings(vAppLeaseSettings)
.vAppTemplateLeaseSettings(vAppTemplateLeaseSettings)
.orgLdapSettings(ldapSettings)
.orgEmailSettings(emailSettings)
.ldapSettings(ldapSettings)
.emailSettings(emailSettings)
.passwordPolicy(passwordPolicy)
.build();

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<AdminOrg xmlns="http://www.vmware.com/vcloud/v1.5" name="JClouds" id="urn:vcloud:org:6f312e42-cd2b-488d-a2bb-97519cd57ed0" type="application/vnd.vmware.admin.organization+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="down" type="application/vnd.vmware.vcloud.tasksList+xml" href="https://vcloudbeta.bluelock.com/api/tasksList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"/>
<Link rel="add" type="application/vnd.vmware.admin.catalog+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/catalogs"/>
<Link rel="add" type="application/vnd.vmware.admin.user+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/users"/>
<Link rel="add" type="application/vnd.vmware.admin.group+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/groups"/>
<Link rel="add" type="application/vnd.vmware.admin.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/networks"/>
<Link rel="edit" type="application/vnd.vmware.admin.organization+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
<Link rel="remove" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
<Link rel="alternate" type="application/vnd.vmware.vcloud.org+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
<Description/>
<FullName>JClouds</FullName>
<IsEnabled>true</IsEnabled>
<Settings type="application/vnd.vmware.admin.orgSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings">
<Link rel="down" type="application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"/>
<Link rel="down" type="application/vnd.vmware.admin.organizationEmailSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email"/>
<Link rel="down" type="application/vnd.vmware.admin.vAppLeaseSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"/>
<Link rel="down" type="application/vnd.vmware.admin.organizationPasswordPolicySettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy"/>
<Link rel="down" type="application/vnd.vmware.admin.organizationGeneralSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"/>
<Link rel="down" type="application/vnd.vmware.admin.organizationLdapSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap"/>
<Link rel="edit" type="application/vnd.vmware.admin.orgSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings"/>
<OrgGeneralSettings type="application/vnd.vmware.admin.organizationGeneralSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general">
<Link rel="edit" type="application/vnd.vmware.admin.organizationGeneralSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/general"/>
<CanPublishCatalogs>false</CanPublishCatalogs>
<DeployedVMQuota>0</DeployedVMQuota>
<StoredVmQuota>0</StoredVmQuota>
<UseServerBootSequence>false</UseServerBootSequence>
<DelayAfterPowerOnSeconds>0</DelayAfterPowerOnSeconds>
</OrgGeneralSettings>
<VAppLeaseSettings type="application/vnd.vmware.admin.vAppLeaseSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings">
<Link rel="edit" type="application/vnd.vmware.admin.vAppLeaseSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppLeaseSettings"/>
<DeleteOnStorageLeaseExpiration>false</DeleteOnStorageLeaseExpiration>
<DeploymentLeaseSeconds>0</DeploymentLeaseSeconds>
<StorageLeaseSeconds>0</StorageLeaseSeconds>
</VAppLeaseSettings>
<VAppTemplateLeaseSettings type="application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings">
<Link rel="edit" type="application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/vAppTemplateLeaseSettings"/>
<DeleteOnStorageLeaseExpiration>false</DeleteOnStorageLeaseExpiration>
<StorageLeaseSeconds>0</StorageLeaseSeconds>
</VAppTemplateLeaseSettings>
<OrgLdapSettings type="application/vnd.vmware.admin.organizationLdapSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/ldap">
<OrgLdapMode>NONE</OrgLdapMode>
</OrgLdapSettings>
<OrgEmailSettings type="application/vnd.vmware.admin.organizationEmailSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email">
<Link rel="edit" type="application/vnd.vmware.admin.organizationEmailSettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/email"/>
<IsDefaultSmtpServer>true</IsDefaultSmtpServer>
<IsDefaultOrgEmail>true</IsDefaultOrgEmail>
<FromEmailAddress/>
<DefaultSubjectPrefix/>
<IsAlertEmailToAllAdmins>true</IsAlertEmailToAllAdmins>
<SmtpServerSettings>
<IsUseAuthentication>false</IsUseAuthentication>
<Host/>
<Username/>
</SmtpServerSettings>
</OrgEmailSettings>
<OrgPasswordPolicySettings type="application/vnd.vmware.admin.organizationPasswordPolicySettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy">
<Link rel="edit" type="application/vnd.vmware.admin.organizationPasswordPolicySettings+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/settings/passwordPolicy"/>
<AccountLockoutEnabled>false</AccountLockoutEnabled>
<InvalidLoginsBeforeLockout>5</InvalidLoginsBeforeLockout>
<AccountLockoutIntervalMinutes>10</AccountLockoutIntervalMinutes>
</OrgPasswordPolicySettings>
</Settings>
<Users>
<UserReference type="application/vnd.vmware.admin.user+xml" name="adam.lowe@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/672ebb67-d8ff-4201-9c1b-c1be869e526c"/>
<UserReference type="application/vnd.vmware.admin.user+xml" name="adrian@jclouds.org" href="https://vcloudbeta.bluelock.com/api/admin/user/8c360b93-ed25-4c9a-8e24-d48cd9966d93"/>
<UserReference type="application/vnd.vmware.admin.user+xml" name="qunying.huang@enstratus.com" href="https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69"/>
<UserReference type="application/vnd.vmware.admin.user+xml" name="dan@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/ae75edd2-12de-414c-8e85-e6ea10442c08"/>
<UserReference type="application/vnd.vmware.admin.user+xml" name="adk@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"/>
</Users>
<Groups/>
<Catalogs>
<CatalogReference type="application/vnd.vmware.admin.catalog+xml" name="QunyingTestCatalog" href="https://vcloudbeta.bluelock.com/api/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"/>
<CatalogReference type="application/vnd.vmware.admin.catalog+xml" name="Public" href="https://vcloudbeta.bluelock.com/api/admin/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"/>
<CatalogReference type="application/vnd.vmware.admin.catalog+xml" name="dantest" href="https://vcloudbeta.bluelock.com/api/admin/catalog/b542aff4-9f97-4f51-a126-4330fbf62f02"/>
<CatalogReference type="application/vnd.vmware.admin.catalog+xml" name="test" href="https://vcloudbeta.bluelock.com/api/admin/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da"/>
</Catalogs>
<Vdcs>
<Vdc type="application/vnd.vmware.vcloud.vdc+xml" name="Cluster01-JClouds" href="https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"/>
</Vdcs>
<Networks>
<Network type="application/vnd.vmware.admin.network+xml" name="ilsolation01-Jclouds" href="https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"/>
<Network type="application/vnd.vmware.admin.network+xml" name="internet01-Jclouds" href="https://vcloudbeta.bluelock.com/api/admin/network/55a677cf-ab3f-48ae-b880-fab90421980c"/>
</Networks>
</AdminOrg>