This repository has been archived by the owner on May 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for multiple providers, ensure ec2-aws jclouds provider i…
…s fully functional, isolate inventory dependency
Showing
50 changed files
with
2,355 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
node.environment=test | ||
discovery.uri=http://localhost:8080 | ||
http-server.http.port=8888 | ||
|
||
cloud-management.manager=InMemory | ||
|
||
cloud-management.providers=devstack,aws | ||
#Configured with a locally running devstack | ||
jclouds.location=http://localhost:5000 | ||
jclouds.user=admin:admin | ||
jclouds.secret=admin | ||
jclouds.default-image-id=cirros-0.3.0-x86_64-uec | ||
jclouds.default-location-id=RegionOne | ||
inventory.base-uri=http://localhost/inv_api/v1/ | ||
inventory.user=user | ||
inventory.password=pass | ||
cloud-management.devstack.api=openstack-nova | ||
cloud-management.devstack.name=DevStack edition of OpenStack | ||
cloud-management.devstack.location=http://192.168.56.2:5000 | ||
cloud-management.devstack.user=admin:admin | ||
cloud-management.devstack.secret=admin | ||
cloud-management.devstack.default-image-id=005dbf05-9e1c-4773-9fbc-48f7eea99aca | ||
|
||
cloud-management.aws.api=aws-ec2 | ||
cloud-management.aws.name=Amazon Web Services | ||
cloud-management.aws.user= | ||
cloud-management.aws.secret= | ||
cloud-management.aws.default-image-id=ami-a29943cb | ||
cloud-management.aws.aws-vpc-subnet-id=subnet-e9ac9581 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/com/proofpoint/cloudmanagement/service/ConditionalModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2010 Proofpoint, Inc. | ||
* | ||
* Licensed 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 com.proofpoint.cloudmanagement.service; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.inject.Binder; | ||
import com.google.inject.Module; | ||
import com.proofpoint.configuration.ConfigurationAwareModule; | ||
import com.proofpoint.configuration.ConfigurationFactory; | ||
|
||
public class ConditionalModule implements ConfigurationAwareModule | ||
{ | ||
public static ConfigurationAwareModule installIfPropertyEquals(Module module, String property, String expectedValue) | ||
{ | ||
return new ConditionalModule(module, property, expectedValue); | ||
} | ||
|
||
private final Module module; | ||
private final String property; | ||
private final String expectedValue; | ||
private ConfigurationFactory configurationFactory; | ||
|
||
private ConditionalModule(Module module, String property, String expectedValue) | ||
{ | ||
Preconditions.checkNotNull(module, "module is null"); | ||
Preconditions.checkNotNull(property, "property is null"); | ||
|
||
this.module = module; | ||
this.property = property; | ||
this.expectedValue = expectedValue; | ||
} | ||
|
||
@Override | ||
public void setConfigurationFactory(ConfigurationFactory configurationFactory) | ||
{ | ||
this.configurationFactory = configurationFactory; | ||
configurationFactory.consumeProperty(property); | ||
|
||
// consume properties if we are not going to install the module | ||
if (!shouldInstall()) { | ||
configurationFactory.registerConfigurationClasses(module); | ||
} | ||
} | ||
|
||
@Override | ||
public void configure(Binder binder) | ||
{ | ||
Preconditions.checkNotNull(configurationFactory, "configurationFactory is null"); | ||
if (shouldInstall()) { | ||
binder.install(module); | ||
} | ||
} | ||
|
||
private boolean shouldInstall() | ||
{ | ||
if (expectedValue != null) { | ||
return expectedValue.equals(configurationFactory.getProperties().get(property)); | ||
} | ||
else { | ||
return configurationFactory.getProperties().containsKey(property); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/proofpoint/cloudmanagement/service/DnsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2010 Proofpoint, Inc. | ||
* | ||
* Licensed 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 com.proofpoint.cloudmanagement.service; | ||
|
||
public interface DnsManager | ||
{ | ||
public String getFullyQualifiedDomainName(Instance instance); | ||
} |
84 changes: 84 additions & 0 deletions
84
src/main/java/com/proofpoint/cloudmanagement/service/InMemoryManagerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2010 Proofpoint, Inc. | ||
* | ||
* Licensed 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 com.proofpoint.cloudmanagement.service; | ||
|
||
import com.google.common.cache.CacheBuilder; | ||
import com.google.common.cache.CacheLoader; | ||
import com.google.common.cache.LoadingCache; | ||
import com.google.inject.Binder; | ||
import com.google.inject.Module; | ||
import com.google.inject.Scopes; | ||
import org.eclipse.jetty.util.ConcurrentHashSet; | ||
|
||
import java.util.Set; | ||
|
||
public class InMemoryManagerModule | ||
implements Module | ||
{ | ||
public void configure(Binder binder) | ||
{ | ||
binder.requireExplicitBindings(); | ||
binder.disableCircularProxies(); | ||
|
||
binder.bind(DnsManager.class).to(NoOpDnsManager.class).in(Scopes.SINGLETON); | ||
binder.bind(TagManager.class).to(InMemoryTagManager.class).in(Scopes.SINGLETON); | ||
} | ||
|
||
public static class NoOpDnsManager implements DnsManager | ||
{ | ||
@Override | ||
public String getFullyQualifiedDomainName(Instance instance) | ||
{ | ||
return instance.getHostname(); | ||
} | ||
} | ||
|
||
public static class InMemoryTagManager implements TagManager | ||
{ | ||
private final LoadingCache<String, Set<String>> tagCache = | ||
CacheBuilder.newBuilder() | ||
.build(new CacheLoader<String, Set<String>>() | ||
{ | ||
|
||
@Override | ||
public Set<String> load(String key) | ||
throws Exception | ||
{ | ||
return new ConcurrentHashSet<String>(); | ||
} | ||
}); | ||
|
||
@Override | ||
public TagUpdateStatus addTag(Instance instance, String tag) | ||
{ | ||
tagCache.getUnchecked(instance.getId()).add(tag); | ||
return TagUpdateStatus.UPDATED; | ||
} | ||
|
||
@Override | ||
public TagUpdateStatus deleteTag(Instance instance, String tag) | ||
{ | ||
tagCache.getUnchecked(instance.getId()).remove(tag); | ||
return TagUpdateStatus.UPDATED; | ||
} | ||
|
||
@Override | ||
public Iterable<String> getTags(Instance instance) | ||
{ | ||
return tagCache.getUnchecked(instance.getId()); | ||
} | ||
} | ||
} |
Oops, something went wrong.