mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of https://github.com/kedardave/jclouds
* 'master' of https://github.com/kedardave/jclouds: added implementation and test files for savvis integration
This commit is contained in:
commit
b929a9cbcf
|
@ -28,9 +28,11 @@ import org.jclouds.http.annotation.ServerError;
|
|||
import org.jclouds.savvis.SymphonyVPDCAsyncClient;
|
||||
import org.jclouds.savvis.SymphonyVPDCClient;
|
||||
import org.jclouds.savvis.handlers.SymphonyVPDCErrorHandler;
|
||||
import org.jclouds.savvis.xml.SymphonyVPDCOrgListHandler;
|
||||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudExpressClient;
|
||||
import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule;
|
||||
import org.jclouds.vcloud.xml.OrgListHandler;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
|
@ -53,6 +55,14 @@ public class SymphonyVPDCRestClientModule extends
|
|||
return in;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(OrgListHandler.class).to(SymphonyVPDCOrgListHandler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(SymphonyVPDCErrorHandler.class);
|
||||
|
|
|
@ -21,8 +21,10 @@ package org.jclouds.savvis;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.jclouds.vcloud.VCloudExpressClientLiveTest;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
||||
|
@ -47,9 +49,18 @@ public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest {
|
|||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
||||
"org.jclouds.savvis.SymphonyVPDCPropertiesBuilder");
|
||||
|
||||
context = new ComputeServiceContextFactory(restProperties).createContext(provider,
|
||||
context = new ComputeServiceContextFactory(restProperties).createContext(provider, "kedar.dave", "gravSavvis1!",
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
|
||||
System.out.println(context);
|
||||
|
||||
/*Properties overrides1 = new Properties();
|
||||
ComputeServiceContext context1 =
|
||||
new ComputeServiceContextFactory(restProperties).createContext(provider,"kedar.dave" ,"gravSavvis1!",ImmutableSet.<Module> of(new JschSshClientModule()), overrides1);
|
||||
System.out.println(context1.getComputeService().listImages());
|
||||
System.out.println(context1.getComputeService().listHardwareProfiles());*/
|
||||
|
||||
connection = context.getApi();
|
||||
System.out.println(connection);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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 org.jclouds.savvis.xml;
|
||||
|
||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.xml.OrgListHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SymphonyVPDCOrgListHandler extends OrgListHandler {
|
||||
|
||||
private Map<String, ReferenceType> org = Maps.newHashMap();
|
||||
|
||||
public Map<String, ReferenceType> getResult() {
|
||||
return org;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (qName.contains("vApp:Org")) {
|
||||
String type = attributes.get("type");
|
||||
if (type != null) {
|
||||
if (type.indexOf("org+xml") != -1) {
|
||||
putReferenceType(org, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* 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 org.jclouds.savvis.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code OrgListHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "OrgListHandlerTest")
|
||||
public class SymphonyVPDCOrgListHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/orglist.xml");
|
||||
|
||||
Map<String, ReferenceType> result = factory.create(injector.getInstance(SymphonyVPDCOrgListHandler.class)).parse(is);
|
||||
assertEquals(result, ImmutableMap.of("SAVVISStation Integration Testing", new ReferenceTypeImpl("SAVVISStation Integration Testing",
|
||||
VCloudExpressMediaType.ORG_XML, URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"))));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<!--
|
||||
|
||||
|
||||
Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
|
||||
====================================================================
|
||||
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.
|
||||
====================================================================
|
||||
|
||||
-->
|
||||
|
||||
<!--
|
||||
<OrgList xmlns="http://www.vmware.com/vcloud/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<Org href="https://services.vcloudexpress.terremark.com/api/v0.8/org/48" type="application/vnd.vmware.vcloud.org+xml" name="adrian@jclouds.org"/>
|
||||
</OrgList>
|
||||
-->
|
||||
|
||||
<vApp:OrgList xmlns:vApp="http://www.vmware.com/vcloud/v0.8">
|
||||
<vApp:Org name="SAVVISStation Integration Testing" type="application/vnd.vmware.vcloud.org+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"/>
|
||||
</vApp:OrgList>
|
Loading…
Reference in New Issue