JCLOUDS-699: Properly deprecate OpenStack Nova zonescoped package

This commit is contained in:
Jeremy Daggett 2014-09-02 10:36:17 -07:00 committed by Jeremy Daggett
parent 58438d7d1e
commit 15d8166701
33 changed files with 564 additions and 59 deletions

View File

@ -27,7 +27,7 @@
</parent>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-nova</artifactId>
<name>jclouds openstack-nova api</name>
<name>Apache jclouds :: OpenStack :: Nova API</name>
<description>jclouds components to access an implementation of OpenStack Nova</description>
<packaging>bundle</packaging>

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.compute;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
@ -61,8 +62,8 @@ import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates;

View File

@ -71,11 +71,11 @@ import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.FlavorInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ImageInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
import com.google.common.annotations.VisibleForTesting;
@ -108,9 +108,9 @@ public class NovaComputeServiceContextModule extends
super.configure();
bind(new TypeLiteral<ComputeServiceAdapter<ServerInRegion, FlavorInRegion, ImageInRegion, Location>>() {
}).to(NovaComputeServiceAdapter.class);
bind(ComputeService.class).to(NovaComputeService.class);
bind(new TypeLiteral<Function<ServerInRegion, NodeMetadata>>() {
}).to(ServerInRegionToNodeMetadata.class);
@ -154,7 +154,7 @@ public class NovaComputeServiceContextModule extends
bind(new TypeLiteral<CacheLoader<RegionAndName, KeyPair>>() {
}).to(CreateUniqueKeyPair.class);
bind(new TypeLiteral<ImageExtension>() {
}).to(NovaImageExtension.class);
@ -185,7 +185,7 @@ public class NovaComputeServiceContextModule extends
CacheLoader<RegionAndName, SecurityGroupInRegion> in) {
return CacheBuilder.newBuilder().build(in);
}
@Override
protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
return ImmutableMap.of(OsFamily.WINDOWS, LoginCredentials.builder().user("Administrator").build(),
@ -264,7 +264,7 @@ public class NovaComputeServiceContextModule extends
protected Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus() {
return toPortableNodeStatus;
}
@VisibleForTesting
public static final Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus = ImmutableMap
.<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> builder()
@ -280,7 +280,7 @@ public class NovaComputeServiceContextModule extends
protected Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus() {
return toPortableImageStatus;
}
@Override
protected Optional<ImageExtension> provideImageExtension(Injector i) {
return Optional.of(i.getInstance(ImageExtension.class));

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.compute.functions;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;

View File

@ -32,8 +32,8 @@ import org.jclouds.net.domain.IpProtocol;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.Ingress;
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import com.google.common.base.Function;

View File

@ -36,7 +36,6 @@ import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.inject.Inject;
/**
* A function for transforming a Nova-specific SecurityGroup into a generic
* SecurityGroup object.

View File

@ -32,7 +32,6 @@ import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
import com.google.common.base.Function;
import com.google.inject.Inject;
/**
* A function for transforming a Nova-specific SecurityGroup into a generic
* SecurityGroup object.
@ -44,7 +43,7 @@ public class NovaSecurityGroupToSecurityGroup implements Function<org.jclouds.op
protected Logger logger = Logger.NULL;
protected Function<SecurityGroupRule, IpPermission> ruleToPermission;
@Inject
public NovaSecurityGroupToSecurityGroup(Function<SecurityGroupRule, IpPermission> ruleToPermission) {
this.ruleToPermission = ruleToPermission;
@ -53,7 +52,7 @@ public class NovaSecurityGroupToSecurityGroup implements Function<org.jclouds.op
@Override
public SecurityGroup apply(org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group) {
SecurityGroupBuilder builder = new SecurityGroupBuilder();
builder.id(group.getId());
builder.providerId(group.getId());
builder.ownerId(group.getTenantId());

View File

@ -32,8 +32,8 @@ import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
import org.jclouds.net.domain.IpPermission;
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
@ -41,7 +41,6 @@ import com.google.common.base.Supplier;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.Atomics;
/**
* A function for transforming a nova-specific SecurityGroupRule into a generic
* IpPermission object.

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.compute.loaders;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
@ -23,9 +24,9 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import com.google.common.base.Function;
import com.google.common.base.Predicate;

View File

@ -45,9 +45,9 @@ import org.jclouds.openstack.nova.v2_0.compute.functions.AllocateAndAddFloatingI
import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions;
import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import com.google.common.base.Function;
import com.google.common.base.Throwables;

View File

@ -20,24 +20,32 @@ import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
public class FlavorInRegion extends RegionAndId {
protected final Flavor image;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
public FlavorInRegion(Flavor image, String regionId) {
super(regionId, checkNotNull(image, "image").getId());
this.image = image;
public class FlavorInRegion extends RegionAndId {
protected final Flavor flavor;
public FlavorInRegion(Flavor flavor, String regionId) {
super(regionId, checkNotNull(flavor, "flavor").getId());
this.flavor = flavor;
}
public Flavor getFlavor() {
return image;
return flavor;
}
// superclass hashCode/equals are good enough, and help us use RegionAndId and FlavorInRegion
// interchangeably as Map keys
@Override
protected ToStringHelper string() {
return super.string().add("flavor", flavor);
}
@Override
public String toString() {
return "[image=" + image + ", regionId=" + regionId + "]";
return string().toString();
}
}

View File

@ -20,6 +20,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.Image;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
public class ImageInRegion extends RegionAndId {
protected final Image image;
@ -35,9 +38,14 @@ public class ImageInRegion extends RegionAndId {
// superclass hashCode/equals are good enough, and help us use RegionAndId and ImageInRegion
// interchangeably as Map keys
@Override
protected ToStringHelper string() {
return super.string().add("image", image);
}
@Override
public String toString() {
return "[image=" + image + ", regionId=" + regionId + "]";
return string().toString();
}
}

View File

@ -19,11 +19,14 @@ package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Objects;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
public class RegionAndId {
public static RegionAndId fromSlashEncoded(String id) {
Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id");
@ -50,6 +53,14 @@ public class RegionAndId {
this.id = checkNotNull(id, "id");
}
public String getRegion() {
return regionId;
}
public String getId() {
return id;
}
@Override
public int hashCode() {
return Objects.hashCode(regionId, id);
@ -67,17 +78,13 @@ public class RegionAndId {
return Objects.equal(regionId, other.regionId) && Objects.equal(id, other.id);
}
public String getRegion() {
return regionId;
}
public String getId() {
return id;
protected ToStringHelper string() {
return MoreObjects.toStringHelper(this).add("regionId", regionId).add("id", id);
}
@Override
public String toString() {
return "[regionId=" + regionId + ", id=" + id + "]";
return string().toString();
}
}

View File

@ -33,21 +33,17 @@ import com.google.common.collect.Iterables;
public class RegionAndName {
public static final Function<RegionAndName, String> NAME_FUNCTION = new Function<RegionAndName, String>() {
@Override
public String apply(RegionAndName input) {
return input.getName();
}
};
public static final Function<RegionAndName, String> REGION_FUNCTION = new Function<RegionAndName, String>() {
@Override
public String apply(RegionAndName input) {
return input.getRegion();
}
};
public static RegionAndName fromSlashEncoded(String name) {
@ -99,12 +95,13 @@ public class RegionAndName {
return Objects.hashCode(regionId, name);
}
protected ToStringHelper string() {
return MoreObjects.toStringHelper(this).add("regionId", regionId).add("name", name);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return MoreObjects.toStringHelper("").add("regionId", regionId).add("name", name);
}
}

View File

@ -21,8 +21,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
public class RegionSecurityGroupNameAndPorts extends RegionAndName {
@ -53,7 +53,13 @@ public class RegionSecurityGroupNameAndPorts extends RegionAndName {
}
@Override
public ToStringHelper string() {
protected ToStringHelper string() {
return super.string().add("ports", ports);
}
@Override
public String toString() {
return string().toString();
}
}

View File

@ -20,6 +20,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
import com.google.common.base.MoreObjects.ToStringHelper;
public class SecurityGroupInRegion extends RegionAndName {
protected final SecurityGroup securityGroup;
@ -32,12 +34,17 @@ public class SecurityGroupInRegion extends RegionAndName {
return securityGroup;
}
// superclass hashCode/equals are good enough, and help us use RegionAndName and ServerInRegion
// superclass hashCode/equals are good enough, and help us use RegionAndName and SecurityGroupInRegion
// interchangeably as Map keys
@Override
protected ToStringHelper string() {
return super.string().add("securityGroup", securityGroup);
}
@Override
public String toString() {
return "[securityGroup=" + securityGroup + ", regionId=" + regionId + "]";
return string().toString();
}
}

View File

@ -20,6 +20,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import com.google.common.base.MoreObjects.ToStringHelper;
public class ServerInRegion extends RegionAndId {
protected final Server server;
@ -35,9 +37,14 @@ public class ServerInRegion extends RegionAndId {
// superclass hashCode/equals are good enough, and help us use RegionAndId and ServerInRegion
// interchangeably as Map keys
@Override
protected ToStringHelper string() {
return super.string().add("server", server);
}
@Override
public String toString() {
return "[server=" + server + ", regionId=" + regionId + "]";
return string().toString();
}
}

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
/**
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.FlavorInRegion FlavorInRegion},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class FlavorInRegion extends RegionAndId {
protected final Flavor flavor;
public FlavorInRegion(Flavor flavor, String regionId) {
super(regionId, checkNotNull(flavor, "image").getId());
this.flavor = flavor;
}
public Flavor getFlavor() {
return flavor;
}
// superclass hashCode/equals are good enough, and help us use RegionAndId and FlavorInRegion
// interchangeably as Map keys
@Override
public String toString() {
return "[flavor=" + flavor + ", regionId=" + regionId + "]";
}
}

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.Image;
/**
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.ImageInRegion ImageInRegion},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class ImageInRegion extends RegionAndId {
protected final Image image;
public ImageInRegion(Image image, String regionId) {
super(regionId, checkNotNull(image, "image").getId());
this.image = image;
}
public Image getImage() {
return image;
}
// superclass hashCode/equals are good enough, and help us use RegionAndId and ImageInRegion
// interchangeably as Map keys
@Override
public String toString() {
return "[image=" + image + ", regionId=" + regionId + "]";
}
}

View File

@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Objects;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
/**
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndId RegionAndId},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class RegionAndId {
public static RegionAndId fromSlashEncoded(String id) {
Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id");
return new RegionAndId(Iterables.get(parts, 0), Iterables.get(parts, 1));
}
public static RegionAndId fromRegionAndId(String regionId, String id) {
return new RegionAndId(regionId, id);
}
private static String slashEncodeRegionAndId(String regionId, String id) {
return checkNotNull(regionId, "regionId") + "/" + checkNotNull(id, "id");
}
public String slashEncode() {
return slashEncodeRegionAndId(regionId, id);
}
protected final String regionId;
protected final String id;
protected RegionAndId(String regionId, String id) {
this.regionId = checkNotNull(regionId, "regionId");
this.id = checkNotNull(id, "id");
}
@Override
public int hashCode() {
return Objects.hashCode(regionId, id);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RegionAndId other = (RegionAndId) obj;
return Objects.equal(regionId, other.regionId) && Objects.equal(id, other.id);
}
public String getRegion() {
return regionId;
}
public String getId() {
return id;
}
@Override
public String toString() {
return "[regionId=" + regionId + ", id=" + id + "]";
}
}

View File

@ -0,0 +1,115 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Objects;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
/**
* Helpful when looking for resources by region and name
*
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName RegionAndName},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class RegionAndName {
public static final Function<RegionAndName, String> NAME_FUNCTION = new Function<RegionAndName, String>() {
@Override
public String apply(RegionAndName input) {
return input.getName();
}
};
public static final Function<RegionAndName, String> REGION_FUNCTION = new Function<RegionAndName, String>() {
@Override
public String apply(RegionAndName input) {
return input.getRegion();
}
};
public static RegionAndName fromSlashEncoded(String name) {
Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name"));
checkArgument(Iterables.size(parts) == 2, "name must be in format regionId/name");
return new RegionAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
}
public static RegionAndName fromRegionAndName(String regionId, String name) {
return new RegionAndName(regionId, name);
}
private static String slashEncodeRegionAndName(String regionId, String name) {
return checkNotNull(regionId, "regionId") + "/" + checkNotNull(name, "name");
}
public String slashEncode() {
return slashEncodeRegionAndName(regionId, name);
}
protected final String regionId;
protected final String name;
protected RegionAndName(String regionId, String name) {
this.regionId = checkNotNull(regionId, "regionId");
this.name = checkNotNull(name, "name");
}
public String getRegion() {
return regionId;
}
public String getName() {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
RegionAndName that = RegionAndName.class.cast(o);
return equal(this.regionId, that.regionId) && equal(this.name, that.name);
}
@Override
public int hashCode() {
return Objects.hashCode(regionId, name);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return MoreObjects.toStringHelper("").add("regionId", regionId).add("name", name);
}
}

View File

@ -0,0 +1,65 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableSet;
/**
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts RegionSecurityGroupNameAndPorts},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class RegionSecurityGroupNameAndPorts extends RegionAndName {
protected final Set<Integer> ports;
public RegionSecurityGroupNameAndPorts(String regionId, String name, Iterable<Integer> ports) {
super(regionId, name);
this.ports = ImmutableSet.<Integer> copyOf(checkNotNull(ports, "ports"));
}
public Set<Integer> getPorts() {
return ports;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
RegionSecurityGroupNameAndPorts that = RegionSecurityGroupNameAndPorts.class.cast(o);
return super.equals(that) && equal(this.ports, that.ports);
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), ports);
}
@Override
public ToStringHelper string() {
return super.string().add("ports", ports);
}
}

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
/**
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion SecurityGroupInRegion},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class SecurityGroupInRegion extends RegionAndName {
protected final SecurityGroup securityGroup;
public SecurityGroupInRegion(SecurityGroup securityGroup, String regionId) {
super(regionId, checkNotNull(securityGroup, "securityGroup").getName());
this.securityGroup = securityGroup;
}
public SecurityGroup getSecurityGroup() {
return securityGroup;
}
// superclass hashCode/equals are good enough, and help us use RegionAndName and ServerInRegion
// interchangeably as Map keys
@Override
public String toString() {
return "[securityGroup=" + securityGroup + ", regionId=" + regionId + "]";
}
}

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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.openstack.nova.v2_0.domain.zonescoped;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.openstack.nova.v2_0.domain.Server;
/**
* @deprecated This package has been replaced with {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped}.
* Please use {@link org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion ServerInRegion},
* as this class will be removed in jclouds 2.1.0.
*/
@Deprecated
public class ServerInRegion extends RegionAndId {
protected final Server server;
public ServerInRegion(Server server, String regionId) {
super(regionId, checkNotNull(server, "server").getId());
this.server = server;
}
public Server getServer() {
return server;
}
// superclass hashCode/equals are good enough, and help us use RegionAndId and ServerInRegion
// interchangeably as Map keys
@Override
public String toString() {
return "[server=" + server + ", regionId=" + regionId + "]";
}
}

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.nova.v2_0.domain.regionscoped;
package org.jclouds.openstack.nova.v2_0.domain.zonescoped;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

View File

@ -24,7 +24,7 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.openstack.v2_0.services.Extension;
import org.jclouds.rest.annotations.Fallback;

View File

@ -28,8 +28,8 @@ import javax.inject.Singleton;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
import org.jclouds.rest.ResourceNotFoundException;

View File

@ -35,8 +35,8 @@ import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
import org.jclouds.openstack.nova.v2_0.domain.Network;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceContextExpectTest;
import org.testng.annotations.Test;

View File

@ -29,8 +29,8 @@ import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.ServerInRegion;
import org.jclouds.openstack.nova.v2_0.parse.ParseServerTest;
import org.testng.annotations.Test;

View File

@ -22,9 +22,9 @@ import static org.testng.Assert.fail;
import java.util.concurrent.atomic.AtomicReference;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionAndName;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.RegionSecurityGroupNameAndPorts;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.SecurityGroupInRegion;
import org.testng.annotations.Test;
import com.google.common.base.Function;

View File

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
import org.testng.annotations.Test;

View File

@ -16,15 +16,15 @@
*/
package org.jclouds.openstack.nova.v2_0.extensions;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import org.jclouds.openstack.nova.v2_0.domain.regionscoped.AvailabilityZone;
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
@Test(groups = "live", testName = "AvailabilityZonesApiLiveTest")
public class AvailabilityZonesApiLiveTest extends BaseNovaApiLiveTest {