[25/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/component/ComponentLifecycle.java -- diff --git a/utils/src/com/cloud/utils/component/ComponentLifecycle.java b/utils/src/com/cloud/utils/component/ComponentLifecycle.java deleted file mode 100644 index 897ddb1..000 --- a/utils/src/com/cloud/utils/component/ComponentLifecycle.java +++ /dev/null @@ -1,64 +0,0 @@ -// -// 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 com.cloud.utils.component; - -import java.util.Map; - -import javax.naming.ConfigurationException; - -public interface ComponentLifecycle extends Named { -public static final int RUN_LEVEL_SYSTEM_BOOTSTRAP = 0;// for system level bootstrap components -public static final int RUN_LEVEL_SYSTEM = 1;// for system level service components (i.e., DAOs) -public static final int RUN_LEVEL_FRAMEWORK_BOOTSTRAP = 2;// for framework startup checkers (i.e., DB migration check) -public static final int RUN_LEVEL_FRAMEWORK = 3;// for framework bootstrap components(i.e., clustering management components) -public static final int RUN_LEVEL_COMPONENT_BOOTSTRAP = 4;// general manager components -public static final int RUN_LEVEL_COMPONENT = 5;// regular adapters, plugin components -public static final int RUN_LEVEL_APPLICATION_MAINLOOP = 6; -public static final int MAX_RUN_LEVELS = 7; - -@Override -String getName(); - -void setName(String name); - -void setConfigParams(Map params); - -Map getConfigParams(); - -int getRunLevel(); - -void setRunLevel(int level); - -public boolean configure(String name, Map params) throws ConfigurationException; - -/** - * Start any background tasks. - * - * @return true if the tasks were started, false otherwise. - */ -public boolean start(); - -/** - * Stop any background tasks. - * - * @return true background tasks were stopped, false otherwise. - */ -public boolean stop(); -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java -- diff --git a/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java b/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java deleted file mode 100644 index 829dc9b..000 --- a/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java +++ /dev/null @@ -1,87 +0,0 @@ -// -// 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 com.cloud.utils.component; - -import java.util.HashMap; -import java.util.Map; - -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - -public class ComponentLifecycleBase implements ComponentLifecycle { -private static final Logger s_logger = Logger.getLogger(ComponentLifecycleBase.class); - -protected String _name; -protected int _runLevel; -protected Map _configParams = new HashMap(); - -public ComponentLifecycleBase() { -_name = this.getClass().getSimpleName(); -_runLevel = RUN_LEVEL_COMPONENT; -} - -@Override -public String getName() { -return _name; -} - -@Override -public void setName(String name) { -_name = name; -} - -@Override -publi
[44/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Add basic RestClient implentation based on HTTP Components 4.5 - Upgrade version of HTTP Components to 4.5 - Add helper class to create Http clients - Add helper class to build http requests - Add enum with the different Http Methods - Add constants class for HTTP related values Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8a93bb8d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8a93bb8d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8a93bb8d Branch: refs/heads/deploy-from-snapshot Commit: 8a93bb8d2dc85dc6382e373744f8e7c6a9593fb1 Parents: 6e74ef8 Author: Miguel Ferreira Authored: Fri Aug 21 17:44:57 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:13 2015 +0200 -- pom.xml | 2 +- .../com/cloud/utils/rest/BasicRestClient.java | 118 .../com/cloud/utils/rest/HttpClientHelper.java | 71 ++ .../com/cloud/utils/rest/HttpConstants.java | 34 + .../java/com/cloud/utils/rest/HttpMethods.java | 41 ++ .../cloud/utils/rest/HttpUriRequestBuilder.java | 119 .../java/com/cloud/utils/rest/RestClient.java | 31 .../cloud/utils/rest/BasicRestClientTest.java | 106 ++ .../cloud/utils/rest/HttpClientHelperTest.java | 38 + .../cloud/utils/rest/HttpRequestMatcher.java| 141 +++ .../utils/rest/HttpUriRequestBuilderTest.java | 115 +++ .../utils/rest/HttpUriRequestQueryMatcher.java | 48 +++ 12 files changed, 863 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a93bb8d/pom.xml -- diff --git a/pom.xml b/pom.xml index 95b90db..b5e380e 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 18.0 18.0 6.2.0-3.1 -4.3.6 +4.5 4.4 3.1 5.1.34 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a93bb8d/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java -- diff --git a/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java b/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java new file mode 100644 index 000..5c29155 --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/rest/BasicRestClient.java @@ -0,0 +1,118 @@ +// +// 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 com.cloud.utils.rest; + +import java.io.IOException; +import java.net.URI; + +import org.apache.http.HttpHost; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.log4j.Logger; + +public class BasicRestClient implements RestClient { + +private static final Logger s_logger = Logger.getLogger(BasicRestClient.class); + +private static final String HTTPS = HttpConstants.HTTPS; +private static final int HTTPS_PORT = HttpConstants.HTTPS_PORT; + +private final CloseableHttpClient client; +private final HttpClientContext clientContext; + +private BasicRestClient(final Builder builder) { +client = builder.client; +clientContext = builder.clientContext; +clientContext.setTargetHost(buildHttpHost(builder.host)); +} + +protected BasicRestClient(final CloseableHttpClient client, final HttpClientContext clientContex, final String host) { +this.client = client; +clientContext = clientContex; +clientContext.setTargetHost(buildHttpHost(host)); +} + +private static HttpHost buildHttpHost(final String host) { +return new HttpHost(host, HTTPS_PORT, HTTPS); +} + +@SuppressWarnings("rawtypes") +public static Builder create() { +return new Builder(); +} + +@Override +public CloseableHttpResponse execute(final HttpUriRequest req
[43/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Code clean up in cloud-plugin-network-nvp project - Code formatting - Declare final where possible - Remove unused methods - Remove throws declarations where not needed - Remove generated comments (e.g. "TODO Auto-generated method stub") Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6e74ef8e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6e74ef8e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6e74ef8e Branch: refs/heads/deploy-from-snapshot Commit: 6e74ef8e40c408511e4ec247a058c3d27fb3209d Parents: 5fc953e Author: Miguel Ferreira Authored: Sat Aug 22 20:53:28 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:12 2015 +0200 -- plugins/network-elements/nicira-nvp/pom.xml | 3 +- .../network/guru/NiciraNvpGuestNetworkGuru.java | 65 +++--- .../com/cloud/network/nicira/NiciraNvpApi.java | 71 ++ .../network/resource/NiciraNvpResource.java | 36 +-- ...figurePortForwardingRulesCommandWrapper.java | 5 +- ...ciraNvpConfigurePublicIpsCommandWrapper.java | 4 +- ...vpConfigureStaticNatRulesCommandWrapper.java | 2 +- ...aNvpFindLogicalSwitchPortCommandWrapper.java | 2 +- .../resource/NiciraNvpRequestWrapperTest.java | 4 +- .../network/resource/NiciraNvpResourceTest.java | 223 +-- 10 files changed, 190 insertions(+), 225 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e74ef8e/plugins/network-elements/nicira-nvp/pom.xml -- diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml index 8567482..2d20ae2 100644 --- a/plugins/network-elements/nicira-nvp/pom.xml +++ b/plugins/network-elements/nicira-nvp/pom.xml @@ -18,7 +18,8 @@ under the License. --> -http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> 4.0.0 cloud-plugin-network-nvp Apache CloudStack Plugin - Network Nicira NVP http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e74ef8e/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java index 640d8a5..975ebd1 100644 --- a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/guru/NiciraNvpGuestNetworkGuru.java @@ -98,14 +98,14 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru { public NiciraNvpGuestNetworkGuru() { super(); -_isolationMethods = new IsolationMethod[] {IsolationMethod.STT, IsolationMethod.VXLAN}; +_isolationMethods = new IsolationMethod[] { IsolationMethod.STT, IsolationMethod.VXLAN }; } @Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { // This guru handles only Guest Isolated network that supports Source nat service -if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated && -isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Connectivity)) { +if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated +&& isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Service.Connectivity)) { return true; } else { s_logger.trace("We only take care of Guest networks of type " + GuestType.Isolated + " in zone of type " + NetworkType.Advanced); @@ -116,14 +116,14 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru { @Override public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner) { // Check of the isolation type of the related physical network is supported -PhysicalNetw
[38/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SecurityRule.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SecurityRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SecurityRule.java deleted file mode 100644 index e23593c..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SecurityRule.java +++ /dev/null @@ -1,138 +0,0 @@ -// -// 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 com.cloud.network.nicira; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - -@SuppressWarnings("serial") -public class SecurityRule extends AccessRule { - -protected String ipPrefix; - -protected int portRangeMin; - -protected int portRangeMax; - -protected String profileUuid; - - -/** - * Default constructor - */ -public SecurityRule() { -} - -/** - * Fully parameterized constructor - */ -public SecurityRule(final String ethertype, final String ipPrefix, final String profileUuid, -final int portRangeMin, final int portRangeMax, final int protocol) { -this.ethertype = ethertype; -this.ipPrefix = ipPrefix; -this.portRangeMin = portRangeMin; -this.portRangeMax = portRangeMax; -this.profileUuid = profileUuid; -this.protocol = protocol; -} - -@Override -public String getEthertype() { -return ethertype; -} - -@Override -public void setEthertype(final String ethertype) { -this.ethertype = ethertype; -} - -public String getIpPrefix() { -return ipPrefix; -} - -public void setIpPrefix(final String ipPrefix) { -this.ipPrefix = ipPrefix; -} - -public int getPortRangeMin() { -return portRangeMin; -} - -public void setPortRangeMin(final int portRangeMin) { -this.portRangeMin = portRangeMin; -} - -public int getPortRangeMax() { -return portRangeMax; -} - -public void setPortRangeMax(final int portRangeMax) { -this.portRangeMax = portRangeMax; -} - -public String getProfileUuid() { -return profileUuid; -} - -public void setProfileUuid(final String profileUuid) { -this.profileUuid = profileUuid; -} - -@Override -public int getProtocol() { -return protocol; -} - -@Override -public void setProtocol(final int protocol) { -this.protocol = protocol; -} - -@Override -public int hashCode() { -return new HashCodeBuilder(17, 31) -.append(ethertype).append(ipPrefix) -.append(portRangeMin).append(portRangeMax) -.append(profileUuid).append(protocol) -.toHashCode(); -} - -@Override -public boolean equals(final Object obj) { -if (obj == null) { -return false; -} -if (obj == this) { -return true; -} -if (!(obj instanceof SecurityRule)) { -return false; -} -final SecurityRule another = (SecurityRule) obj; -return new EqualsBuilder() -.append(ethertype, another.ethertype) -.append(ipPrefix, another.ipPrefix) -.append(portRangeMin, another.portRangeMin) -.append(portRangeMax, another.portRangeMax) -.append(profileUuid, another.profileUuid) -.append(protocol, another.protocol) -.isEquals(); -} -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java deleted file mode
[34/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java new file mode 100644 index 000..ea5df2c --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SingleDefaultRouteImplicitRoutingConfig.java @@ -0,0 +1,40 @@ +// +// 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 com.cloud.network.nicira; + +/** + * + */ +public class SingleDefaultRouteImplicitRoutingConfig extends RoutingConfig { +public RouterNextHop defaultRouteNextHop; +public final String type = "SingleDefaultRouteImplicitRoutingConfig"; + +public SingleDefaultRouteImplicitRoutingConfig(final RouterNextHop routerNextHop) { +defaultRouteNextHop = routerNextHop; +} + +public RouterNextHop getDefaultRouteNextHop() { +return defaultRouteNextHop; +} + +public void setDefaultRouteNextHop(final RouterNextHop defaultRouteNextHop) { +this.defaultRouteNextHop = defaultRouteNextHop; +} +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SourceNatRule.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SourceNatRule.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SourceNatRule.java new file mode 100644 index 000..b95cb9a --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/SourceNatRule.java @@ -0,0 +1,119 @@ +// +// 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 com.cloud.network.nicira; + +public class SourceNatRule extends NatRule { +private String toSourceIpAddressMax; +private String toSourceIpAddressMin; +private Integer toSourcePort; + +public SourceNatRule() { +setType("SourceNatRule"); +} + +public String getToSourceIpAddressMax() { +return toSourceIpAddressMax; +} + +public void setToSourceIpAddressMax(final String toSourceIpAddressMax) { +this.toSourceIpAddressMax = toSourceIpAddressMax; +} + +public String getToSourceIpAddressMin() { +return toSourceIpAddressMin; +} + +public void setToSourceIpAddressMin(final String toSourceIpAddressMin) { +this.toSourceIpAddressMin = toSourceIpAddressMin; +} + +public Integer getToSourcePort() { +return toSourcePort; +} + +public void setToSourcePort(final Integer toSourcePort) { +this.toSourcePort = toSourcePort; +} + +@Override +public int hashCode() { +final int prime = 31; +int result = super.hashCode(); +result = prime * result + ((toSourceIpAddressMax == null) ? 0 : toSourceIpAddressMax.hashCode()); +result = prime * result + ((toSourceIpAddressMin == null) ? 0 : toSourceIpAddressMin.hashCode()); +result = prime * result + ((toSourcePort == null) ? 0 : toSourcePort.hashCod
[45/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Delegate HTTP protocol activity in RESTServiceConnector to RestClient - All HTTP protocol activities are now handled by RestClient - This service is now only responsible for creating requests, and dispatching them to the client - Provides a Simple API for creating, updating, retrieving and deleting objects Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/de63b94f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/de63b94f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/de63b94f Branch: refs/heads/deploy-from-snapshot Commit: de63b94f2dc571e74ce5eaa68c74ed6a9edf420c Parents: 8a93bb8 Author: Miguel Ferreira Authored: Sun Aug 23 15:11:29 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:14 2015 +0200 -- .../BasicEncodedRESTValidationStrategy.java | 66 --- .../cloud/utils/rest/RESTServiceConnector.java | 391 +++-- .../utils/rest/RESTValidationStrategy.java | 159 -- .../utils/rest/HttpUriRequestMethodMatcher.java | 44 ++ .../rest/HttpUriRequestPayloadMatcher.java | 62 +++ .../utils/rest/RESTServiceConnectorTest.java| 553 --- 6 files changed, 430 insertions(+), 845 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de63b94f/utils/src/main/java/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java -- diff --git a/utils/src/main/java/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java b/utils/src/main/java/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java deleted file mode 100644 index bf001cd..000 --- a/utils/src/main/java/com/cloud/utils/rest/BasicEncodedRESTValidationStrategy.java +++ /dev/null @@ -1,66 +0,0 @@ -// -// 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 com.cloud.utils.rest; - -import java.io.IOException; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpMethodBase; - -/** - * Base 64 encoded authorization strategy. This implementation as opposed to - * {@link RESTValidationStrategy} doesn't do a login after auth error, but instead - * includes the encoded credentials in each request, instead of a cookie. - */ -public class BasicEncodedRESTValidationStrategy extends RESTValidationStrategy { - -public BasicEncodedRESTValidationStrategy(final String host, final String adminuser, final String adminpass) { -super(); -this.host = host; -user = adminuser; -password = adminpass; -} - -public BasicEncodedRESTValidationStrategy() { -} - -@Override -public void executeMethod(final HttpMethodBase method, final HttpClient client, -final String protocol) -throws CloudstackRESTException, HttpException, IOException { -if (host == null || host.isEmpty() || user == null || user.isEmpty() || password == null || password.isEmpty()) { -throw new CloudstackRESTException("Hostname/credentials are null or empty"); -} - -final String encodedCredentials = encodeCredentials(); -method.setRequestHeader("Authorization", "Basic " + encodedCredentials); -client.executeMethod(method); -} - -private String encodeCredentials() { -final String authString = user + ":" + password; -final byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); -final String authStringEnc = new String(authEncBytes); -return authStringEnc; -} - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/de63b94f/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java -- diff --git a/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java b/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java index 01aca89..
[47/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Refactor NSX api implementation (NiciraNvpApi) - Make internal method private - Remove unused methods - Refactor type deserialization adapter classes out Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c6602ee1 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c6602ee1 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c6602ee1 Branch: refs/heads/deploy-from-snapshot Commit: c6602ee151968d266d22553e21f47bbc24de1199 Parents: 18e6b9b Author: Miguel Ferreira Authored: Sat Aug 22 16:12:12 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:16 2015 +0200 -- .../cloud/network/nicira/NatRuleAdapter.java| 49 +++ .../com/cloud/network/nicira/NiciraNvpApi.java | 63 .../network/nicira/RoutingConfigAdapter.java| 52 .../network/nicira/NatRuleAdapterTest.java | 60 +++ .../com/cloud/network/nicira/NatRuleTest.java | 2 +- .../nicira/RoutingConfigAdapterTest.java| 57 ++ 6 files changed, 229 insertions(+), 54 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c6602ee1/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRuleAdapter.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRuleAdapter.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRuleAdapter.java new file mode 100644 index 000..7ea2f5b --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NatRuleAdapter.java @@ -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 com.cloud.network.nicira; + +import java.lang.reflect.Type; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; + +public class NatRuleAdapter implements JsonDeserializer { + +@Override +public NatRule deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException { +final JsonObject jsonObject = jsonElement.getAsJsonObject(); + +if (!jsonObject.has("type")) { +throw new JsonParseException("Deserializing as a NatRule, but no type present in the json object"); +} + +final String natRuleType = jsonObject.get("type").getAsString(); +if ("SourceNatRule".equals(natRuleType)) { +return context.deserialize(jsonElement, SourceNatRule.class); +} else if ("DestinationNatRule".equals(natRuleType)) { +return context.deserialize(jsonElement, DestinationNatRule.class); +} + +throw new JsonParseException("Failed to deserialize type \"" + natRuleType + "\""); +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c6602ee1/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java index 06446a7..39262b6 100644 --- a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java @@ -32,9 +32,6 @@ import com.cloud.utils.rest.RESTServiceConnector; import com.cloud.utils.rest.RESTValidationStrategy; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; import com.google.gson.re
[37/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpUpdateLogicalSwitchPortCommandWrapper.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpUpdateLogicalSwitchPortCommandWrapper.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpUpdateLogicalSwitchPortCommandWrapper.java deleted file mode 100644 index a0d7dc2..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/wrapper/NiciraNvpUpdateLogicalSwitchPortCommandWrapper.java +++ /dev/null @@ -1,68 +0,0 @@ -// -// 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 com.cloud.network.resource.wrapper; - -import static com.cloud.network.resource.NiciraNvpResource.NUM_RETRIES; - -import java.util.ArrayList; -import java.util.List; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.UpdateLogicalSwitchPortAnswer; -import com.cloud.agent.api.UpdateLogicalSwitchPortCommand; -import com.cloud.network.nicira.NiciraNvpApi; -import com.cloud.network.nicira.NiciraNvpApiException; -import com.cloud.network.nicira.NiciraNvpTag; -import com.cloud.network.nicira.VifAttachment; -import com.cloud.network.resource.NiciraNvpResource; -import com.cloud.network.resource.NiciraNvpUtilities; -import com.cloud.network.utils.CommandRetryUtility; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = UpdateLogicalSwitchPortCommand.class) -public final class NiciraNvpUpdateLogicalSwitchPortCommandWrapper extends CommandWrapper { - -@Override -public Answer execute(final UpdateLogicalSwitchPortCommand command, final NiciraNvpResource niciraNvpResource) { -final NiciraNvpUtilities niciraNvpUtilities = niciraNvpResource.getNiciraNvpUtilities(); - -final String logicalSwitchUuid = command.getLogicalSwitchUuid(); -final String logicalSwitchPortUuid = command.getLogicalSwitchPortUuid(); -final String attachmentUuid = command.getAttachmentUuid(); - -final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi(); - -try { -// Tags set to scope cs_account and account name -final List tags = new ArrayList(); -tags.add(new NiciraNvpTag("cs_account", command.getOwnerName())); - -final VifAttachment vifAttachment = niciraNvpUtilities.createVifAttachment(attachmentUuid); - -niciraNvpApi.updateLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, vifAttachment); -return new UpdateLogicalSwitchPortAnswer(command, true, "Attachment for " + logicalSwitchPortUuid + " updated", logicalSwitchPortUuid); -} catch (final NiciraNvpApiException e) { -final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility(); -retryUtility.addRetry(command, NUM_RETRIES); -return retryUtility.retry(command, UpdateLogicalSwitchPortAnswer.class, e); -} -} -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java deleted file mode 100644 index 92c198a..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/utils/CommandRetryUtility.java +++ /dev/null @@ -1,89 +0,0 @@ -// -// 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
[48/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09f71533/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java -- diff --git a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java index 1435cc5..79546a6 100644 --- a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java +++ b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/nicira/NiciraNvpApiTest.java @@ -19,321 +19,180 @@ package com.cloud.network.nicira; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.hasSize; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Matchers.any; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.methods.DeleteMethod; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.PutMethod; -import org.apache.commons.httpclient.params.HttpClientParams; -import org.junit.Before; +import org.apache.http.HttpHost; +import org.apache.http.HttpRequest; +import org.apache.http.ProtocolVersion; +import org.apache.http.StatusLine; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.message.BasicStatusLine; +import org.hamcrest.Matchers; import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import com.google.gson.Gson; -import com.google.gson.JsonParseException; -import com.cloud.utils.rest.RESTServiceConnector; -import com.cloud.utils.rest.RESTValidationStrategy; +import com.cloud.utils.rest.HttpClientHelper; +import com.cloud.utils.rest.HttpUriRequestMethodMatcher; +import com.cloud.utils.rest.HttpUriRequestPathMatcher; +import com.cloud.utils.rest.HttpUriRequestQueryMatcher; public class NiciraNvpApiTest { +private static final StatusLine HTTP_200_REPSONSE = new BasicStatusLine(new ProtocolVersion("HTTPS", 1, 1), HttpStatus.SC_OK, "OK"); +private static final StatusLine HTTP_201_REPSONSE = new BasicStatusLine(new ProtocolVersion("HTTPS", 1, 1), HttpStatus.SC_CREATED, "Created"); + protected static final String UUID = ""; protected static final String UUID2 = ""; -protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/"; +protected static final String UUID_SEC_PROFILE_URI = NiciraConstants.SEC_PROFILE_URI_PREFIX + "/"; protected static final String SCHEMA = "myTestSchema"; protected static final String SCHEMA2 = "myTestSchema2"; protected static final String HREF = "myTestHref"; protected static final String HREF2 = "myTestHref2"; protected static final String SEC_PROFILE_JSON_RESPONSE = -"{\"uuid\" : \"\"," -+ "\"display_name\" : \"myTestName\"," -+ "\"href\" : \"myTestHref\"," -+ "\"schema\" : \"myTestSchema\"}"; +"{\"uuid\" : \"\"," ++ "\"display_name\" : \"myTestName\"," ++ "\"href\" : \"myTestHref\"," ++ "\"schema\" : \"myTestSchema\"}"; protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"\"," -+ "\"display_name\" : \"myTestName\"," -+ "\"href\" : \"myTestHref\"," -+ "\"schema\" : \"myTestSchema\"}," -+ "{ \"uuid\" : \"\"," -+ "\"display_name\" : \"myTestName2\"," -+ "\"href\" : \"myTestHref2\"," -+ "\"schema\" : \"myTestSchema2\"}]," -+ "\"result_count\": 2}"; - -NiciraNvpApi api; -HttpClient client = mock(HttpClient.class); -HttpMethod method; -String type; -String
[31/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java -- diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java deleted file mode 100644 index 36e4643..000 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java +++ /dev/null @@ -1,476 +0,0 @@ -// -// 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 com.cloud.network.guru; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collections; - -import org.junit.Before; -import org.junit.Test; - -import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; - -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.CreateLogicalSwitchAnswer; -import com.cloud.agent.api.DeleteLogicalSwitchAnswer; -import com.cloud.dc.DataCenter; -import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.dao.DataCenterDao; -import com.cloud.deploy.DeployDestination; -import com.cloud.deploy.DeploymentPlan; -import com.cloud.domain.Domain; -import com.cloud.exception.InsufficientVirtualNetworkCapacityException; -import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDao; -import com.cloud.network.Network; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Network.Service; -import com.cloud.network.Network.State; -import com.cloud.network.NetworkModel; -import com.cloud.network.NetworkProfile; -import com.cloud.network.Networks.BroadcastDomainType; -import com.cloud.network.Networks.TrafficType; -import com.cloud.network.NiciraNvpDeviceVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.NiciraNvpDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.user.Account; -import com.cloud.vm.ReservationContext; - -public class NiciraNvpGuestNetworkGuruTest { -private static final long NETWORK_ID = 42L; -PhysicalNetworkDao physnetdao = mock(PhysicalNetworkDao.class); -NiciraNvpDao nvpdao = mock(NiciraNvpDao.class); -DataCenterDao dcdao = mock(DataCenterDao.class); -NetworkOfferingServiceMapDao nosd = mock(NetworkOfferingServiceMapDao.class); -AgentManager agentmgr = mock(AgentManager.class); -NetworkOrchestrationService netmgr = mock(NetworkOrchestrationService.class); -NetworkModel netmodel = mock(NetworkModel.class); - -HostDao hostdao = mock(HostDao.class); -NetworkDao netdao = mock(NetworkDao.class); -NiciraNvpGuestNetworkGuru guru; - -@Before -public void setUp() { -guru = new NiciraNvpGuestNetworkGuru(); -((GuestNetworkGuru)guru)._physicalNetworkDao = physnetdao; -guru.physicalNetworkDao = physnetdao; -guru.niciraNvpDao = nvpdao; -guru._dcDao = dcdao; -guru.ntwkOfferingSrvcDao = nosd; -guru.networkModel = netmodel; -guru.hostDao = hostdao; -guru.agentMgr = agentmgr; -guru.networkDao = netdao; - -final DataCenterVO dc = mock(DataCenterVO.class); -when(dc.getNetworkType()).thenReturn(NetworkType.Advanced); -when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24"); - -when(dcdao.findById((Long)any())).thenReturn(dc); -} - -@Test -public void testCanHandle() { -
[26/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java -- diff --git a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java b/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java deleted file mode 100644 index 447e21b..000 --- a/utils/src/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java +++ /dev/null @@ -1,999 +0,0 @@ -// -// 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 com.cloud.utils.cisco.n1kv.vsm; - -import java.util.List; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.log4j.Logger; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSSerializer; - -import com.cloud.utils.Pair; - -public class VsmCommand { - -private static final Logger s_logger = Logger.getLogger(VsmCommand.class); -private static final String s_namespace = "urn:ietf:params:xml:ns:netconf:base:1.0"; -private static final String s_ciscons = "http://www.cisco.com/nxos:1.0:ppm";; -private static final String s_configuremode = "__XML__MODE__exec_configure"; -private static final String s_portprofmode = "__XML__MODE_port-prof"; -private static final String s_policymapmode = "__XML__MODE_policy-map"; -private static final String s_classtypemode = "__XML__MODE_policy-map_class_type"; -private static final String s_paramvalue = "__XML__PARAM_value"; - -public enum PortProfileType { -none, vethernet, ethernet; -} - -public enum BindingType { -none, portbindingstatic, portbindingdynamic, portbindingephermal; -} - -public enum SwitchPortMode { -none, access, trunk, privatevlanhost, privatevlanpromiscuous -} - -public enum OperationType { -addvlanid, removevlanid -} - -public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid, String vdc, String espName) { -try { -// Create the document and root element. -DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); -DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); -DOMImplementation domImpl = docBuilder.getDOMImplementation(); -Document doc = createDocument(domImpl); - -// Edit configuration command. -Element editConfig = doc.createElement("nf:edit-config"); -doc.getDocumentElement().appendChild(editConfig); - -// Command to get into exec configure mode. -Element target = doc.createElement("nf:target"); -Element running = doc.createElement("nf:running"); -target.appendChild(running); -editConfig.appendChild(target); - -// Command to create the port profile with the desired configuration. -Element config = doc.createElement("nf:config"); -config.appendChild(configPortProfileDetails(doc, name, type, binding, mode, vlanid, vdc, espName)); -editConfig.appendChild(config); - -return serialize(domImpl, doc); -} catch (ParserConfigurationException e) { -s_logger.error("Error while creating add port profile message : " + e.getMessage()); -return null; -} catch (DOMException e) { -s_logger.error("Error while creating add port profile message : " + e.getMessage()); -return null; -} -} - -public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid) { -try { -// Create the document and root element. -DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); -DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); -DOMImplementation domImpl = docBuilder.getDOMIm
[46/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Add NSX specific RestClient implementation - Add -noverify JVM arg to surefire plugin, to allow Powermockito to de-encapsulate private methods - Add dependency on cloud-utils test-jar to use custom HttpRequest matchers Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/18e6b9ba Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/18e6b9ba Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/18e6b9ba Branch: refs/heads/deploy-from-snapshot Commit: 18e6b9ba78600fd01456d18c1f2b4c5333714dd9 Parents: de63b94 Author: Miguel Ferreira Authored: Sat Aug 22 17:05:30 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:15 2015 +0200 -- plugins/network-elements/nicira-nvp/pom.xml | 10 + .../cloud/network/nicira/ExecutionCounter.java | 50 + .../cloud/network/nicira/NiciraRestClient.java | 202 +++ .../network/nicira/ExecutionCounterTest.java| 55 + .../network/nicira/NiciraRestClientTest.java| 172 pom.xml | 2 +- .../cloud/utils/rest/HttpStatusCodeHelper.java | 34 .../utils/rest/HttpStatusCodeHelperTest.java| 59 ++ 8 files changed, 583 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18e6b9ba/plugins/network-elements/nicira-nvp/pom.xml -- diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml index 2d20ae2..e74a5ae 100644 --- a/plugins/network-elements/nicira-nvp/pom.xml +++ b/plugins/network-elements/nicira-nvp/pom.xml @@ -30,6 +30,16 @@ ../../pom.xml + + + org.apache.cloudstack + cloud-utils + 4.6.0-SNAPSHOT + test-jar + test + + + src/main/java src/test/java http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18e6b9ba/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ExecutionCounter.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ExecutionCounter.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ExecutionCounter.java new file mode 100644 index 000..1314498 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/ExecutionCounter.java @@ -0,0 +1,50 @@ +// +// 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 com.cloud.network.nicira; + +import java.util.concurrent.atomic.AtomicInteger; + +public class ExecutionCounter { + +private final int executionLimit; +private final AtomicInteger executionCount = new AtomicInteger(0); + +public ExecutionCounter(final int executionLimit) { +this.executionLimit = executionLimit; +} + +public ExecutionCounter resetExecutionCounter() { +executionCount.set(0); +return this; +} + +public boolean hasReachedExecutionLimit() { +return executionCount.get() >= executionLimit; +} + +public ExecutionCounter incrementExecutionCounter() { +executionCount.incrementAndGet(); +return this; +} + +public int getValue() { +return executionCount.get(); +} +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/18e6b9ba/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java new file mode 100644 index 000..6ade3a5 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraRestClient.java @@ -0,0 +1,202 @@ +// +// Licensed to the Apache Software Foundation (ASF) under
[35/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java new file mode 100644 index 000..8a4c053 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/AclRule.java @@ -0,0 +1,209 @@ +// +// 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 com.cloud.network.nicira; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + +@SuppressWarnings("serial") +public class AclRule extends AccessRule { + +public static final String ETHERTYPE_ARP = "ARP"; + +/** + * @TODO Convert this String into Enum and check the JSON communication still works + */ +protected String action; + +protected String sourceIpPrefix; + +protected String destinationIpPrefix; + +protected String sourceMacAddress; + +protected String destinationMacAddress; + +protected Integer sourcePortRangeMin; + +protected Integer destinationPortRangeMin; + +protected Integer sourcePortRangeMax; + +protected Integer destinationPortRangeMax; + +protected Integer icmpProtocolCode; + +protected Integer icmpProtocolType; + +protected int order; + + +/** + * Default constructor + */ +public AclRule() { +} + +/** + * Fully parameterized constructor + */ +public AclRule(String ethertype, int protocol, String action, String sourceMacAddress, +String destinationMacAddress, String sourceIpPrefix, String destinationIpPrefix, +Integer sourcePortRangeMin, Integer sourcePortRangeMax, +Integer destinationPortRangeMin, Integer destinationPortRangeMax, +int order, Integer icmpProtocolCode, Integer icmpProtocolType) { +this.ethertype = ethertype; +this.protocol = protocol; +this.action = action; +this.sourceMacAddress = sourceMacAddress; +this.destinationMacAddress = destinationMacAddress; +this.sourceIpPrefix = sourceIpPrefix; +this.destinationIpPrefix = destinationIpPrefix; +this.sourcePortRangeMin = sourcePortRangeMin; +this.sourcePortRangeMax = sourcePortRangeMax; +this.destinationPortRangeMin = destinationPortRangeMin; +this.destinationPortRangeMax = destinationPortRangeMax; +this.order = order; +this.icmpProtocolCode = icmpProtocolCode; +this.icmpProtocolType = icmpProtocolType; +} + + +public String getAction() { +return action; +} + +public void setAction(String action) { +this.action = action; +} + +public String getSourceIpPrefix() { +return sourceIpPrefix; +} + +public void setSourceIpPrefix(String sourceIpPrefix) { +this.sourceIpPrefix = sourceIpPrefix; +} + +public String getDestinationIpPrefix() { +return destinationIpPrefix; +} + +public void setDestinationIpPrefix(String destinationIpPrefix) { +this.destinationIpPrefix = destinationIpPrefix; +} + +public String getSourceMacAddress() { +return sourceMacAddress; +} + +public void setSourceMacAddress(String sourceMacAddress) { +this.sourceMacAddress = sourceMacAddress; +} + +public String getDestinationMacAddress() { +return destinationMacAddress; +} + +public void setDestinationMacAddress(String destinationMacAddress) { +this.destinationMacAddress = destinationMacAddress; +} + +public Integer getSourcePortRangeMin() { +return sourcePortRangeMin; +} + +public void setSourcePortRangeMin(Integer sourcePortRangeMin) { +this.sourcePortRangeMin = sourcePortRangeMin; +} + +public Integer getDestinationPortRangeMin() { +return destinationPortRangeMin; +} + +public void setDestinationPortRangeMin(Integer destinationPortRangeMin) {
[30/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java -- diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java deleted file mode 100644 index ddf2993..000 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java +++ /dev/null @@ -1,882 +0,0 @@ -// -// 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 com.cloud.network.resource; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import javax.naming.ConfigurationException; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentMatcher; - -import com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterAnswer; -import com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterCommand; -import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer; -import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand; -import com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterAnswer; -import com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterCommand; -import com.cloud.agent.api.CreateLogicalRouterAnswer; -import com.cloud.agent.api.CreateLogicalRouterCommand; -import com.cloud.agent.api.CreateLogicalSwitchAnswer; -import com.cloud.agent.api.CreateLogicalSwitchCommand; -import com.cloud.agent.api.CreateLogicalSwitchPortAnswer; -import com.cloud.agent.api.CreateLogicalSwitchPortCommand; -import com.cloud.agent.api.DeleteLogicalRouterAnswer; -import com.cloud.agent.api.DeleteLogicalRouterCommand; -import com.cloud.agent.api.DeleteLogicalSwitchAnswer; -import com.cloud.agent.api.DeleteLogicalSwitchCommand; -import com.cloud.agent.api.DeleteLogicalSwitchPortAnswer; -import com.cloud.agent.api.DeleteLogicalSwitchPortCommand; -import com.cloud.agent.api.FindLogicalSwitchPortAnswer; -import com.cloud.agent.api.FindLogicalSwitchPortCommand; -import com.cloud.agent.api.PingCommand; -import com.cloud.agent.api.StartupCommand; -import com.cloud.agent.api.UpdateLogicalSwitchPortAnswer; -import com.cloud.agent.api.UpdateLogicalSwitchPortCommand; -import com.cloud.agent.api.to.PortForwardingRuleTO; -import com.cloud.agent.api.to.StaticNatRuleTO; -import com.cloud.host.Host; -import com.cloud.network.nicira.Attachment; -import com.cloud.network.nicira.ControlClusterStatus; -import com.cloud.network.nicira.DestinationNatRule; -import com.cloud.network.nicira.LogicalRouter; -import com.cloud.network.nicira.LogicalRouterPort; -import com.cloud.network.nicira.LogicalSwitch; -import com.cloud.network.nicira.LogicalSwitchPort; -import com.cloud.network.nicira.NatRule; -import com.cloud.network.nicira.NiciraNvpApi; -import com.cloud.network.nicira.NiciraNvpApiException; -import com.cloud.network.nicira.NiciraNvpList; -import com.cloud.network.nicira.SourceNatRule; -import com.cloud.network.utils.CommandRetryUtility; - -public class NiciraNvpResourceTest { -NiciraNvpApi nvpApi = mock(NiciraNvpApi.class); -NiciraNvpResource resource; -Map parameters; - -private CommandRetryUtility retryUtility; - -@Before -public void setUp() throws ConfigurationException { -resource = new NiciraNvpResource() { -@Override -protected NiciraNvpApi createNiciraNvpApi() { -return nvpApi; -} -
[40/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java b/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java deleted file mode 100644 index 6cc8f5d..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/api/commands/ListNiciraNvpDevicesCmd.java +++ /dev/null @@ -1,108 +0,0 @@ -// -// 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 com.cloud.api.commands; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseListCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.ListResponse; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; - -import com.cloud.api.response.NiciraNvpDeviceResponse; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.NiciraNvpDeviceVO; -import com.cloud.network.element.NiciraNvpElementService; -import com.cloud.utils.exception.CloudRuntimeException; - -@APICommand(name = "listNiciraNvpDevices", responseObject = NiciraNvpDeviceResponse.class, description = "Lists Nicira NVP devices", -requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) -public class ListNiciraNvpDevicesCmd extends BaseListCmd { -private static final String s_name = "listniciranvpdeviceresponse"; - -@Inject -protected NiciraNvpElementService niciraNvpElementService; - -/ - API parameters / -/ - -@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID") -private Long physicalNetworkId; - -@Parameter(name = ApiConstants.NICIRA_NVP_DEVICE_ID, type = CommandType.UUID, entityType = NiciraNvpDeviceResponse.class, description = "nicira nvp device ID") -private Long niciraNvpDeviceId; - -/ -/// Accessors /// -/ - -public Long getNiciraNvpDeviceId() { -return niciraNvpDeviceId; -} - -public Long getPhysicalNetworkId() { -return physicalNetworkId; -} - -/ -/// API Implementation/// -/ - -@Override -public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException { -try { -List niciraDevices = niciraNvpElementService.listNiciraNvpDevices(this); -ListResponse response = new ListResponse(); -List niciraDevicesResponse = new ArrayList(); - -if (niciraDevices != null && !niciraDevices.isEmpty()) { -for (NiciraNvpDeviceVO niciraDeviceVO : niciraDevices) { -NiciraNvpDeviceResponse niciraDeviceResponse = niciraNvpElementService.createNiciraNvpDeviceResponse(niciraDeviceVO); -niciraDevicesResponse.add(niciraDeviceResponse); -} -} - -response.setResponses(niciraDevicesResponse); -response.setResponseName(getCommandName()); -setResponseObject(response); -} catch (InvalidParameterValueException invalidParamExcp) { -throw new ServerApiException(ApiEr
[39/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessRule.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessRule.java deleted file mode 100644 index e614db6..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AccessRule.java +++ /dev/null @@ -1,58 +0,0 @@ -// -// 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 com.cloud.network.nicira; - -import java.io.Serializable; - -import org.apache.commons.lang.builder.ReflectionToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -@SuppressWarnings("serial") -public abstract class AccessRule implements Serializable { - -public static final String ETHERTYPE_IPV4 = "IPv4"; -public static final String ETHERTYPE_IPV6 = "IPv6"; - -protected String ethertype = ETHERTYPE_IPV4; - -protected int protocol; - - -public String getEthertype() { -return ethertype; -} - -public void setEthertype(String ethertype) { -this.ethertype = ethertype; -} - -public int getProtocol() { -return protocol; -} - -public void setProtocol(int protocol) { -this.protocol = protocol; -} - -@Override -public String toString() { -return ReflectionToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE, false); -} -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java deleted file mode 100644 index 870124e..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Acl.java +++ /dev/null @@ -1,23 +0,0 @@ -// -// 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 com.cloud.network.nicira; - -public class Acl extends AccessConfiguration { -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AclRule.java -- diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AclRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AclRule.java deleted file mode 100644 index 8a4c053..000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/AclRule.java +++ /dev/null @@ -1,209 +0,0 @@ -// -// 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, W
[32/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java -- diff --git a/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java new file mode 100644 index 000..7fe6287 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/test/java/com/cloud/network/resource/NiciraNvpRequestWrapperTest.java @@ -0,0 +1,255 @@ +// +// 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 com.cloud.network.resource; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand; +import com.cloud.agent.api.CreateLogicalSwitchCommand; +import com.cloud.agent.api.DeleteLogicalRouterCommand; +import com.cloud.agent.api.DeleteLogicalSwitchCommand; +import com.cloud.agent.api.DeleteLogicalSwitchPortCommand; +import com.cloud.agent.api.MaintainCommand; +import com.cloud.agent.api.ReadyCommand; +import com.cloud.agent.api.UpdateLogicalSwitchPortCommand; +import com.cloud.network.nicira.LogicalRouterPort; +import com.cloud.network.nicira.LogicalSwitch; +import com.cloud.network.nicira.NiciraNvpApi; +import com.cloud.network.nicira.NiciraNvpApiException; +import com.cloud.network.nicira.NiciraNvpList; +import com.cloud.network.nicira.VifAttachment; + +public class NiciraNvpRequestWrapperTest { + +@Mock +private final NiciraNvpResource niciraNvpResource = Mockito.mock(NiciraNvpResource.class); + +@Test +public void testReadyCommandWrapper() { +final ReadyCommand command = new ReadyCommand(); + +final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance(); +assertNotNull(wrapper); + +final Answer answer = wrapper.execute(command, niciraNvpResource); + +assertTrue(answer.getResult()); +} + +@Test +public void testMaintainCommandWrapper() { +final MaintainCommand command = new MaintainCommand(); + +final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance(); +assertNotNull(wrapper); + +final Answer answer = wrapper.execute(command, niciraNvpResource); + +assertTrue(answer.getResult()); +} + +@Test +public void testCreateLogicalSwitchCommandWrapper() { +final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class); +final NiciraNvpUtilities niciraNvpUtilities = Mockito.mock(NiciraNvpUtilities.class); +final LogicalSwitch logicalSwitch = Mockito.mock(LogicalSwitch.class); + +final String transportUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345"; +final String transportType = "stt"; +final String name = "logicalswitch"; +final String ownerName = "owner"; + +final CreateLogicalSwitchCommand command = new CreateLogicalSwitchCommand(transportUuid, transportType, name, ownerName); + +final String truncated = "lswitch-" + command.getName(); + + when(niciraNvpResource.getNiciraNvpUtilities()).thenReturn(niciraNvpUtilities); + when(niciraNvpUtilities.createLogicalSwitch()).thenReturn(logicalSwitch); +when(niciraNvpResource.truncate("lswitch-" + command.getName(), NiciraNvpResource.NAME_MAX_LEN)).thenReturn(truncated); +when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi); + +try { + when(niciraNvpApi.createLogicalSwitch(logicalSwitch)).thenReturn(logicalSwitch); +when(logicalSwitch.getUuid()).thenReturn(transportUuid); +} catch (final NiciraNvpApiException e) { +fail(e.getMessage()); +} + +final Ni
[50/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Merge pull request #737 from miguelaferreira/feature/mferreira/ncx-follow-redirects-gardened-rebase CLOUDSTACK-8758: Handle redirects in communication with NXS controller (a.k.a. Nicira NVP)When an NSX controller node is part of a cluster it will redirect API calls to the master controller. Because the ACS management server does not follow such redirects, if there is a change of master within a NSX cluster, the NSX device (a.k.a. NiciraNvp) needs to be reconfigured (via the management server DB). The goal of this PR is to enable ACS management server to follow HTTP redirects sent by NSX controllers. However, other changes were made to the cloud-utils module that provides the REST client that the NSX plugin uses. Cosmetic changes: * Upgrade maven module structure for cloud-utils and cloud-plugin-netowkr-nvp to comply with maven default * Several refactorings on both modules to consistently format the code, remove unused code, declare final when possible, remove auto generated comments, etc Other changes: * Upgrade HTTP library used in REST client to version 4.5 of Apache HTTP Components * Implement generic REST client that supports HTTP redirects * Implement NSX specific REST client * Simplify NSX api implementation * Previously existing unit tests for both the REST client and NSX api were either maintained in the same test classes, moved to new test classes (because code under tests also moved), or removed (because code under tests was also removed) * New Marvin tests for NSX controllers Testing: * Ran all unit tests present in the project * Ran Java Integration tests for NSX api targeting both a master and a slave controller * Ran new Marvin test for NSX controller * Manual inspection of logs to confirm redirection is taking place * pr/737: Use NSX specific RestClient in API implementation (NiciraNvpApi) Refactor NSX api implementation (NiciraNvpApi) Add NSX specific RestClient implementation Delegate HTTP protocol activity in RESTServiceConnector to RestClient Add basic RestClient implentation based on HTTP Components 4.5 Code clean up in cloud-plugin-network-nvp project Code clean up in cloud-utils project Refactor cloud-plugin-network-nvp project into Maven default structure Refactor cloud-utils project into Maven default structure Fix unit-test library dependencies Add Marvin test for Nicira NVP plugin Create Nicira NVP devices and enable plugin at deploy Signed-off-by: Remi Bergsma Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/44ba14d1 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/44ba14d1 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/44ba14d1 Branch: refs/heads/deploy-from-snapshot Commit: 44ba14d17ba3b8fa00cd05c97eaceed49367816c Parents: 2772e4d 09f7153 Author: Remi Bergsma Authored: Tue Aug 25 20:44:50 2015 +0200 Committer: Remi Bergsma Committed: Tue Aug 25 20:44:52 2015 +0200 -- plugins/network-elements/nicira-nvp/pom.xml | 24 +- .../META-INF/cloudstack/nvp/module.properties | 21 - .../cloudstack/nvp/spring-nvp-context.xml | 42 - ...ortForwardingRulesOnLogicalRouterAnswer.java | 35 - ...rtForwardingRulesOnLogicalRouterCommand.java | 63 - ...ConfigurePublicIpsOnLogicalRouterAnswer.java | 32 - ...onfigurePublicIpsOnLogicalRouterCommand.java | 66 - ...gureStaticNatRulesOnLogicalRouterAnswer.java | 44 - ...ureStaticNatRulesOnLogicalRouterCommand.java | 65 - .../agent/api/CreateLogicalRouterAnswer.java| 42 - .../agent/api/CreateLogicalRouterCommand.java | 116 -- .../agent/api/CreateLogicalSwitchAnswer.java| 38 - .../agent/api/CreateLogicalSwitchCommand.java | 57 - .../api/CreateLogicalSwitchPortAnswer.java | 38 - .../api/CreateLogicalSwitchPortCommand.java | 56 - .../agent/api/DeleteLogicalRouterAnswer.java| 34 - .../agent/api/DeleteLogicalRouterCommand.java | 44 - .../agent/api/DeleteLogicalSwitchAnswer.java| 32 - .../agent/api/DeleteLogicalSwitchCommand.java | 38 - .../api/DeleteLogicalSwitchPortAnswer.java | 32 - .../api/DeleteLogicalSwitchPortCommand.java | 44 - .../agent/api/FindLogicalSwitchPortAnswer.java | 38 - .../agent/api/FindLogicalSwitchPortCommand.java | 44 - .../agent/api/StartupNiciraNvpCommand.java | 30 - .../api/UpdateLogicalSwitchPortAnswer.java | 38 - .../api/UpdateLogicalSwitchPortCommand.java | 63 - .../api/commands/AddNiciraNvpDeviceCmd.java | 154 -- .../api/commands/DeleteNiciraNvpDeviceCmd.java | 112 -- .../ListNiciraNvpDeviceNetworksCmd.java | 111 -- .../api/commands/ListNiciraNvpDevicesCmd.java | 108 -- .../api/response/NiciraNvpDeviceResponse.java | 89 - .../com/cloud/network/NiciraNvpDeviceVO.java| 99 -- .../cloud/network/NiciraNvpNicMappingVO.java| 87 - .
[42/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Code clean up in cloud-utils project - Code formatting - Remove unused methods Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5fc953ed Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5fc953ed Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5fc953ed Branch: refs/heads/deploy-from-snapshot Commit: 5fc953eda2640d1bf69b7ed0f85110b8ac2a4087 Parents: 93b0989 Author: Miguel Ferreira Authored: Sat Aug 22 20:53:12 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:11 2015 +0200 -- .../utils/rest/CloudstackRESTException.java | 8 +- .../cloud/utils/rest/RESTServiceConnector.java | 118 +-- .../utils/rest/RESTValidationStrategy.java | 16 +-- .../utils/rest/RESTServiceConnectorTest.java| 21 ++-- 4 files changed, 73 insertions(+), 90 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5fc953ed/utils/src/main/java/com/cloud/utils/rest/CloudstackRESTException.java -- diff --git a/utils/src/main/java/com/cloud/utils/rest/CloudstackRESTException.java b/utils/src/main/java/com/cloud/utils/rest/CloudstackRESTException.java index 5985fa0..2078d57 100644 --- a/utils/src/main/java/com/cloud/utils/rest/CloudstackRESTException.java +++ b/utils/src/main/java/com/cloud/utils/rest/CloudstackRESTException.java @@ -19,19 +19,13 @@ package com.cloud.utils.rest; +@SuppressWarnings("serial") public class CloudstackRESTException extends Exception { -public CloudstackRESTException() { -} - public CloudstackRESTException(final String message) { super(message); } -public CloudstackRESTException(final Throwable cause) { -super(cause); -} - public CloudstackRESTException(final String message, final Throwable cause) { super(message, cause); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5fc953ed/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java -- diff --git a/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java b/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java index 6ededcb..01aca89 100644 --- a/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java +++ b/utils/src/main/java/com/cloud/utils/rest/RESTServiceConnector.java @@ -19,11 +19,29 @@ package com.cloud.utils.rest; -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializer; -import com.google.gson.reflect.TypeToken; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.MalformedURLException; +import java.net.Socket; +import java.net.URL; +import java.net.UnknownHostException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + import org.apache.cloudstack.utils.security.SSLUtils; import org.apache.cloudstack.utils.security.SecureSSLSocketFactory; import org.apache.commons.httpclient.ConnectTimeoutException; @@ -46,36 +64,18 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.apache.log4j.Logger; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Type; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.MalformedURLException; -import java.net.Socket; -import java.net.URL; -import java.net.UnknownHostException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializer; +import com.google.gson.reflect.TypeToken; /** - * This abstraction encapsulates client side code for REST service communic
[28/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/ProcessUtil.java -- diff --git a/utils/src/com/cloud/utils/ProcessUtil.java b/utils/src/com/cloud/utils/ProcessUtil.java deleted file mode 100644 index 53137c4..000 --- a/utils/src/com/cloud/utils/ProcessUtil.java +++ /dev/null @@ -1,112 +0,0 @@ -// -// 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 com.cloud.utils; - -import java.io.File; -import java.io.IOException; -import java.util.Properties; - -import javax.naming.ConfigurationException; - -import org.apache.commons.io.FileUtils; -import org.apache.log4j.Logger; - -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.utils.script.OutputInterpreter; -import com.cloud.utils.script.Script; - -public class ProcessUtil { -private static final Logger s_logger = Logger.getLogger(ProcessUtil.class.getName()); - -// paths cannot be hardcoded -public static void pidCheck(String pidDir, String run) throws ConfigurationException { - -String dir = pidDir == null ? "/var/run" : pidDir; - -try { -final File propsFile = PropertiesUtil.findConfigFile("environment.properties"); -if (propsFile == null) { -s_logger.debug("environment.properties could not be opened"); -} else { -final Properties props = PropertiesUtil.loadFromFile(propsFile); -dir = props.getProperty("paths.pid"); -if (dir == null) { -dir = pidDir == null ? "/var/run" : pidDir; -} -} -} catch (IOException e) { -s_logger.debug("environment.properties could not be opened"); -} - -final File pidFile = new File(dir + File.separator + run); -try { -if (!pidFile.createNewFile()) { -if (!pidFile.exists()) { -throw new ConfigurationException("Unable to write to " + pidFile.getAbsolutePath() + ". Are you sure you're running as root?"); -} - -final String pidLine = FileUtils.readFileToString(pidFile).trim(); -if (pidLine.isEmpty()) { -throw new ConfigurationException("Java process is being started twice. If this is not true, remove " + pidFile.getAbsolutePath()); -} -try { -final long pid = Long.parseLong(pidLine); -final Script script = new Script("bash", 12, s_logger); -script.add("-c", "ps -p " + pid); -final String result = script.execute(); -if (result == null) { -throw new ConfigurationException("Java process is being started twice. If this is not true, remove " + pidFile.getAbsolutePath()); -} -if (!pidFile.delete()) { -throw new ConfigurationException("Java process is being started twice. If this is not true, remove " + pidFile.getAbsolutePath()); -} -if (!pidFile.createNewFile()) { -throw new ConfigurationException("Java process is being started twice. If this is not true, remove " + pidFile.getAbsolutePath()); -} -} catch (final NumberFormatException e) { -throw new ConfigurationException("Java process is being started twice. If this is not true, remove " + pidFile.getAbsolutePath()); -} -} -pidFile.deleteOnExit(); - -final Script script = new Script("bash", 12, s_logger); -script.add("-c", "echo $PPID"); -final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser(); -script.execute(parser); - -final String pid = parser.getLine(); - -FileUtils.writeStringToFile(pidFile, pid + "\n"); -} catch (final IOException e) { -throw new CloudRuntimeException("Unable to create the " + pidFile.getAbsolutePath() + ". Are you
[41/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Refactor cloud-plugin-network-nvp project into Maven default structure Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/93b0989d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93b0989d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93b0989d Branch: refs/heads/deploy-from-snapshot Commit: 93b0989deaf01ffae3242761174098ca5207b53c Parents: 83fd8f6 Author: Miguel Ferreira Authored: Sat Aug 22 20:48:27 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:10 2015 +0200 -- plugins/network-elements/nicira-nvp/pom.xml | 11 +- .../META-INF/cloudstack/nvp/module.properties | 21 - .../cloudstack/nvp/spring-nvp-context.xml | 42 - ...ortForwardingRulesOnLogicalRouterAnswer.java | 35 - ...rtForwardingRulesOnLogicalRouterCommand.java | 63 -- ...ConfigurePublicIpsOnLogicalRouterAnswer.java | 32 - ...onfigurePublicIpsOnLogicalRouterCommand.java | 66 -- ...gureStaticNatRulesOnLogicalRouterAnswer.java | 44 - ...ureStaticNatRulesOnLogicalRouterCommand.java | 65 -- .../agent/api/CreateLogicalRouterAnswer.java| 42 - .../agent/api/CreateLogicalRouterCommand.java | 116 --- .../agent/api/CreateLogicalSwitchAnswer.java| 38 - .../agent/api/CreateLogicalSwitchCommand.java | 57 -- .../api/CreateLogicalSwitchPortAnswer.java | 38 - .../api/CreateLogicalSwitchPortCommand.java | 56 -- .../agent/api/DeleteLogicalRouterAnswer.java| 34 - .../agent/api/DeleteLogicalRouterCommand.java | 44 - .../agent/api/DeleteLogicalSwitchAnswer.java| 32 - .../agent/api/DeleteLogicalSwitchCommand.java | 38 - .../api/DeleteLogicalSwitchPortAnswer.java | 32 - .../api/DeleteLogicalSwitchPortCommand.java | 44 - .../agent/api/FindLogicalSwitchPortAnswer.java | 38 - .../agent/api/FindLogicalSwitchPortCommand.java | 44 - .../agent/api/StartupNiciraNvpCommand.java | 30 - .../api/UpdateLogicalSwitchPortAnswer.java | 38 - .../api/UpdateLogicalSwitchPortCommand.java | 63 -- .../api/commands/AddNiciraNvpDeviceCmd.java | 154 .../api/commands/DeleteNiciraNvpDeviceCmd.java | 112 --- .../ListNiciraNvpDeviceNetworksCmd.java | 111 --- .../api/commands/ListNiciraNvpDevicesCmd.java | 108 --- .../api/response/NiciraNvpDeviceResponse.java | 89 -- .../com/cloud/network/NiciraNvpDeviceVO.java| 99 --- .../cloud/network/NiciraNvpNicMappingVO.java| 87 -- .../cloud/network/NiciraNvpRouterMappingVO.java | 85 -- .../src/com/cloud/network/dao/NiciraNvpDao.java | 35 - .../com/cloud/network/dao/NiciraNvpDaoImpl.java | 53 -- .../network/dao/NiciraNvpNicMappingDao.java | 32 - .../network/dao/NiciraNvpNicMappingDaoImpl.java | 51 -- .../network/dao/NiciraNvpRouterMappingDao.java | 28 - .../dao/NiciraNvpRouterMappingDaoImpl.java | 51 -- .../cloud/network/element/NiciraNvpElement.java | 849 -- .../element/NiciraNvpElementService.java| 45 - .../network/guru/NiciraNvpGuestNetworkGuru.java | 256 -- .../network/nicira/AccessConfiguration.java | 44 - .../com/cloud/network/nicira/AccessRule.java| 58 -- .../src/com/cloud/network/nicira/Acl.java | 23 - .../src/com/cloud/network/nicira/AclRule.java | 209 - .../com/cloud/network/nicira/Attachment.java| 24 - .../cloud/network/nicira/BaseNiciraEntity.java | 85 -- .../network/nicira/BaseNiciraNamedEntity.java | 44 - .../network/nicira/ControlClusterStatus.java| 87 -- .../network/nicira/DestinationNatRule.java | 113 --- .../network/nicira/L3GatewayAttachment.java | 55 -- .../com/cloud/network/nicira/LogicalRouter.java | 71 -- .../cloud/network/nicira/LogicalRouterPort.java | 62 -- .../com/cloud/network/nicira/LogicalSwitch.java | 60 -- .../cloud/network/nicira/LogicalSwitchPort.java | 82 -- .../src/com/cloud/network/nicira/Match.java | 146 --- .../src/com/cloud/network/nicira/NatRule.java | 130 --- .../com/cloud/network/nicira/NiciraNvpApi.java | 658 -- .../network/nicira/NiciraNvpApiException.java | 39 - .../com/cloud/network/nicira/NiciraNvpList.java | 48 - .../com/cloud/network/nicira/NiciraNvpTag.java | 64 -- .../cloud/network/nicira/PatchAttachment.java | 41 - .../com/cloud/network/nicira/RouterNextHop.java | 40 - .../com/cloud/network/nicira/RoutingConfig.java | 24 - .../nicira/RoutingTableRoutingConfig.java | 30 - .../cloud/network/nicira/SecurityProfile.java | 24 - .../com/cloud/network/nicira/SecurityRule.java | 138 --- ...SingleDefaultRouteImplicitRoutingConfig.java | 40 - .../com/cloud/network/nicira/SourceNatRule.java | 119 --- .../network/nicira/TransportZoneBinding.java| 50 -- .../com/cloud/network/nicira/VifAttachment.java | 78 -- .../resource/NiciraNvpRequestWrapper.java | 77 -- .../network/resource/Nicira
[36/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpDeviceVO.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpDeviceVO.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpDeviceVO.java new file mode 100644 index 000..431e855 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpDeviceVO.java @@ -0,0 +1,99 @@ +// +// 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 com.cloud.network; + +import java.util.UUID; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name = "external_nicira_nvp_devices") +public class NiciraNvpDeviceVO implements InternalIdentity { + +@Id +@GeneratedValue(strategy = GenerationType.IDENTITY) +@Column(name = "id") +private long id; + +@Column(name = "uuid") +private String uuid; + +@Column(name = "host_id") +private long hostId; + +@Column(name = "physical_network_id") +private long physicalNetworkId; + +@Column(name = "provider_name") +private String providerName; + +@Column(name = "device_name") +private String deviceName; + +public NiciraNvpDeviceVO() { +uuid = UUID.randomUUID().toString(); +} + +public NiciraNvpDeviceVO(final long hostId, final long physicalNetworkId, final String providerName, final String deviceName) { +super(); +this.hostId = hostId; +this.physicalNetworkId = physicalNetworkId; +this.providerName = providerName; +this.deviceName = deviceName; +uuid = UUID.randomUUID().toString(); +} + +@Override +public long getId() { +return id; +} + +public String getUuid() { +return uuid; +} + +public void setUuid(String uuid) { +this.uuid = uuid; +} + +public long getPhysicalNetworkId() { +return physicalNetworkId; +} + +public long getHostId() { +return hostId; +} + +public String getProviderName() { +return providerName; +} + +public String getDeviceName() { +return deviceName; +} + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpNicMappingVO.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpNicMappingVO.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpNicMappingVO.java new file mode 100644 index 000..9b13780 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/NiciraNvpNicMappingVO.java @@ -0,0 +1,87 @@ +// +// 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 com.cloud.network; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +impor
[33/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/utils/CommandRetryUtility.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/utils/CommandRetryUtility.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/utils/CommandRetryUtility.java new file mode 100644 index 000..92c198a --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/utils/CommandRetryUtility.java @@ -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 com.cloud.network.utils; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; +import com.cloud.resource.ServerResource; + +public class CommandRetryUtility { + +private static final Logger s_logger = Logger.getLogger(CommandRetryUtility.class); + +private static final int ZERO = 0; +private static CommandRetryUtility instance; + +static { +instance = new CommandRetryUtility(); +} + +private final ConcurrentHashMap commandsToRetry; +private ServerResource serverResource; + +private CommandRetryUtility() { +commandsToRetry = new ConcurrentHashMap(); +} + +public static CommandRetryUtility getInstance() { +return instance; +} + +public void setServerResource(final ServerResource serverResource) { +this.serverResource = serverResource; +} + +public boolean addRetry(final Command command, final int retries) { +if (commandsToRetry.containsKey(command)) { +// A retry already exists for this command, do not add it again. +// Once all retries are executed, the command will be removed from the map. +return false; +} +commandsToRetry.put(command, retries); +return true; +} + +public Answer retry(final Command command, final Class answerClass, final Exception error) { +if (commandsToRetry.containsKey(command)) { +Integer numRetries = commandsToRetry.get(command); + +if (numRetries > ZERO) { +commandsToRetry.put(command, --numRetries); + +s_logger.warn("Retrying " + command.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries); + +return serverResource.executeRequest(command); +} else { +commandsToRetry.remove(command); +} +} +try { +final Constructor answerConstructor = answerClass.getConstructor(Command.class, Exception.class); +return answerConstructor.newInstance(command, error); +} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { +return Answer.createUnsupportedCommandAnswer(command); +} +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93b0989d/plugins/network-elements/nicira-nvp/src/main/resources/META-INF/cloudstack/nvp/module.properties -- diff --git a/plugins/network-elements/nicira-nvp/src/main/resources/META-INF/cloudstack/nvp/module.properties b/plugins/network-elements/nicira-nvp/src/main/resources/META-INF/cloudstack/nvp/module.properties new file mode 100644 index 000..5085fce --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/resources/META-INF/cloudstack/nvp/module.properties @@ -0,0 +1,21 @@ +# +# 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 +# w
[49/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Use NSX specific RestClient in API implementation (NiciraNvpApi) - Simplify public API to return Lists instead of NiciraNvpLists Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/09f71533 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/09f71533 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/09f71533 Branch: refs/heads/deploy-from-snapshot Commit: 09f715337882c432e8731f81bce6490362e1cc2d Parents: c6602ee Author: Miguel Ferreira Authored: Sat Aug 22 17:30:58 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 17:36:17 2015 +0200 -- .../cloud/network/nicira/NiciraConstants.java | 42 ++ .../com/cloud/network/nicira/NiciraNvpApi.java | 323 --- .../network/resource/NiciraNvpResource.java | 26 +- ...figurePortForwardingRulesCommandWrapper.java | 7 +- ...ciraNvpConfigurePublicIpsCommandWrapper.java | 9 +- ...vpConfigureStaticNatRulesCommandWrapper.java | 7 +- ...aNvpFindLogicalSwitchPortCommandWrapper.java | 7 +- .../cloud/network/nicira/NiciraNvpApiIT.java| 202 - .../cloud/network/nicira/NiciraNvpApiTest.java | 411 ++- .../resource/NiciraNvpRequestWrapperTest.java | 7 +- .../network/resource/NiciraNvpResourceTest.java | 72 +--- .../utils/rest/HttpUriRequestPathMatcher.java | 43 ++ 12 files changed, 539 insertions(+), 617 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09f71533/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraConstants.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraConstants.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraConstants.java new file mode 100644 index 000..31adf9d --- /dev/null +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraConstants.java @@ -0,0 +1,42 @@ +// +// 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 com.cloud.network.nicira; + +public class NiciraConstants { + +public static final String SEC_PROFILE_URI_PREFIX = "/ws.v1/security-profile"; +public static final String ACL_URI_PREFIX = "/ws.v1/acl"; +public static final String SWITCH_URI_PREFIX = "/ws.v1/lswitch"; +public static final String ROUTER_URI_PREFIX = "/ws.v1/lrouter"; +public static final String LOGIN_URL = "/ws.v1/login"; +public static final String CONTROL_CLUSTER_STATUS_URL = "/ws.v1/control-cluster/status"; + +public static final String ATTACHMENT_PATH_SEGMENT = "/attachment"; +public static final String NAT_PATH_SEGMENT = "/nat"; +public static final String LPORT_PATH_SEGMENT = "/lport"; + +public static final String ATTACHMENT_VIF_UUID_QUERY_PARAMETER_NAME = "attachment_vif_uuid"; +public static final String ATTACHMENT_VLAN_PARAMETER = "attachment_vlan"; +public static final String ATTACHMENT_GWSVC_UUID_QUERY_PARAMETER = "attachment_gwsvc_uuid"; +public static final String WILDCARD_QUERY_PARAMETER = "*"; +public static final String UUID_QUERY_PARAMETER = "uuid"; +public static final String FIELDS_QUERY_PARAMETER = "fields"; + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09f71533/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java -- diff --git a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java index 39262b6..093d90d 100644 --- a/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java +++ b/plugins/network-elements/nicira-nvp/src/main/java/com/cloud/network/nicira/NiciraNvpApi.java @@ -20,32 +20,39 @@ package com.cloud.network.nicira; import java.lang.reflect.Type; -import java.util.ArrayLi
[21/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/security/CertificateHelper.java -- diff --git a/utils/src/com/cloud/utils/security/CertificateHelper.java b/utils/src/com/cloud/utils/security/CertificateHelper.java deleted file mode 100644 index d43542f..000 --- a/utils/src/com/cloud/utils/security/CertificateHelper.java +++ /dev/null @@ -1,166 +0,0 @@ -// -// 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 com.cloud.utils.security; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.StringReader; -import java.security.Key; -import java.security.KeyFactory; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.ArrayList; -import java.util.List; - -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.commons.codec.binary.Base64; - -import com.cloud.utils.Ternary; -import org.bouncycastle.openssl.PEMReader; - -public class CertificateHelper { -public static byte[] buildAndSaveKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException, -NoSuchAlgorithmException, InvalidKeySpecException, IOException { -KeyStore ks = buildKeystore(alias, cert, privateKey, storePassword); - -ByteArrayOutputStream os = new ByteArrayOutputStream(); -ks.store(os, storePassword != null ? storePassword.toCharArray() : null); -os.close(); -return os.toByteArray(); -} - -public static byte[] buildAndSaveKeystore(List> certs, String storePassword) throws KeyStoreException, NoSuchAlgorithmException, -CertificateException, IOException, InvalidKeySpecException { -KeyStore ks = KeyStore.getInstance("JKS"); -ks.load(null, storePassword != null ? storePassword.toCharArray() : null); - -//name,cert,key -for (Ternary cert : certs) { -if (cert.third() == null) { -Certificate c = buildCertificate(cert.second()); -ks.setCertificateEntry(cert.first(), c); -} else { -Certificate[] c = new Certificate[certs.size()]; -int i = certs.size(); -for (Ternary ct : certs) { -c[i - 1] = buildCertificate(ct.second()); -i--; -} -ks.setKeyEntry(cert.first(), buildPrivateKey(cert.third()), storePassword != null ? storePassword.toCharArray() : null, c); -} -} - -ByteArrayOutputStream os = new ByteArrayOutputStream(); -ks.store(os, storePassword != null ? storePassword.toCharArray() : null); -os.close(); -return os.toByteArray(); -} - -public static KeyStore loadKeystore(byte[] ksData, String storePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { -assert (ksData != null); -KeyStore ks = KeyStore.getInstance("JKS"); -ks.load(new ByteArrayInputStream(ksData), storePassword != null ? storePassword.toCharArray() : null); - -return ks; -} - -public static KeyStore buildKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException, -NoSuchAlgorithmException, InvalidKeySpecException, IOException { - -KeyStore ks = KeyStore.getInstance("JKS"); -ks.load(null, storePassword != null ? storePassword.toCharArray() : null); -Certificate[] certs = new Certificate[1]; -certs[0] = buildCertificate(cert); -ks.setKeyEntry(alias,
[29/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Refactor cloud-utils project into Maven default structure Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/83fd8f60 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/83fd8f60 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/83fd8f60 Branch: refs/heads/deploy-from-snapshot Commit: 83fd8f60f3c503cf6fda7833b0f45c23a215f559 Parents: 3d27e9e Author: Miguel Ferreira Authored: Sun Aug 23 16:03:11 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 14:50:33 2015 +0200 -- utils/certs/cloud.keystore | Bin 1316 -> 0 bytes utils/pom.xml | 44 +- utils/src/com/cloud/maint/Version.java | 77 - utils/src/com/cloud/utils/ActionDelegate.java | 24 - .../src/com/cloud/utils/AutoCloseableUtil.java | 36 - .../com/cloud/utils/CloudResourceBundle.java| 48 - .../com/cloud/utils/ConstantTimeComparator.java | 42 - utils/src/com/cloud/utils/DateUtil.java | 274 utils/src/com/cloud/utils/EncryptionUtil.java | 73 - utils/src/com/cloud/utils/EnumUtils.java| 58 - utils/src/com/cloud/utils/ExecutionResult.java | 46 - utils/src/com/cloud/utils/FileUtil.java | 32 - utils/src/com/cloud/utils/HttpUtils.java| 114 -- utils/src/com/cloud/utils/IteratorUtil.java | 72 - utils/src/com/cloud/utils/Journal.java | 104 -- utils/src/com/cloud/utils/LogUtils.java | 45 - utils/src/com/cloud/utils/MethodCapturer.java | 113 -- utils/src/com/cloud/utils/NumbersUtil.java | 139 -- utils/src/com/cloud/utils/Pair.java | 87 - .../src/com/cloud/utils/PasswordGenerator.java | 90 - utils/src/com/cloud/utils/Predicate.java| 24 - utils/src/com/cloud/utils/ProcessUtil.java | 112 -- utils/src/com/cloud/utils/Profiler.java | 91 - utils/src/com/cloud/utils/PropertiesUtil.java | 196 --- utils/src/com/cloud/utils/ReflectUtil.java | 213 --- utils/src/com/cloud/utils/ReflectionUse.java| 31 - utils/src/com/cloud/utils/S3Utils.java | 603 --- utils/src/com/cloud/utils/SerialVersionUID.java | 69 - utils/src/com/cloud/utils/StringUtils.java | 323 utils/src/com/cloud/utils/SwiftUtil.java| 239 --- utils/src/com/cloud/utils/Ternary.java | 85 - utils/src/com/cloud/utils/UriUtils.java | 394 - .../cloud/utils/UsernamePasswordValidator.java | 49 - utils/src/com/cloud/utils/UuidUtils.java| 34 - .../cloud/utils/backoff/BackoffAlgorithm.java | 38 - .../utils/backoff/impl/ConstantTimeBackoff.java | 102 -- .../backoff/impl/ConstantTimeBackoffMBean.java | 35 - .../utils/cisco/n1kv/vsm/NetconfHelper.java | 355 .../cloud/utils/cisco/n1kv/vsm/PolicyMap.java | 34 - .../cloud/utils/cisco/n1kv/vsm/PortProfile.java | 48 - .../cloud/utils/cisco/n1kv/vsm/VsmCommand.java | 999 --- .../utils/cisco/n1kv/vsm/VsmOkResponse.java | 44 - .../cisco/n1kv/vsm/VsmPolicyMapResponse.java| 84 - .../cisco/n1kv/vsm/VsmPortProfileResponse.java | 166 -- .../cloud/utils/cisco/n1kv/vsm/VsmResponse.java | 222 --- .../src/com/cloud/utils/component/Adapter.java | 27 - .../com/cloud/utils/component/AdapterBase.java | 40 - .../com/cloud/utils/component/AdapterList.java | 37 - .../cloud/utils/component/ComponentContext.java | 282 .../ComponentInstantiationPostProcessor.java| 149 -- .../utils/component/ComponentLifecycle.java | 64 - .../utils/component/ComponentLifecycleBase.java | 87 - .../component/ComponentMethodInterceptable.java | 27 - .../component/ComponentMethodInterceptor.java | 32 - .../utils/component/ComponentNamingPolicy.java | 65 - .../src/com/cloud/utils/component/Manager.java | 27 - .../com/cloud/utils/component/ManagerBase.java | 28 - utils/src/com/cloud/utils/component/Named.java | 26 - .../cloud/utils/component/PluggableService.java | 29 - .../src/com/cloud/utils/component/Registry.java | 51 - .../utils/component/SystemIntegrityChecker.java | 30 - .../utils/concurrency/NamedThreadFactory.java | 38 - .../com/cloud/utils/concurrency/Scheduler.java | 31 - .../utils/concurrency/SynchronizationEvent.java | 89 - .../com/cloud/utils/concurrency/TestClock.java | 161 -- .../com/cloud/utils/crypt/DBEncryptionUtil.java | 87 - .../utils/crypt/EncryptionSecretKeyChecker.java | 146 -- .../utils/crypt/EncryptionSecretKeySender.java | 65 - utils/src/com/cloud/utils/crypt/RSAHelper.java | 90 - utils/src/com/cloud/utils/db/DbProperties.java | 109 -- utils/src/com/cloud/utils/db/EntityManager.java | 84 - utils/src/com/cloud/utils/db/UUIDManager.java | 48 - .../com/cloud/utils/encoding/URLEncoder.java| 113 -- utils/src/com/cloud/utils/events/EventArgs.j
[17/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/component/ComponentLifecycle.java -- diff --git a/utils/src/main/java/com/cloud/utils/component/ComponentLifecycle.java b/utils/src/main/java/com/cloud/utils/component/ComponentLifecycle.java new file mode 100644 index 000..897ddb1 --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/component/ComponentLifecycle.java @@ -0,0 +1,64 @@ +// +// 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 com.cloud.utils.component; + +import java.util.Map; + +import javax.naming.ConfigurationException; + +public interface ComponentLifecycle extends Named { +public static final int RUN_LEVEL_SYSTEM_BOOTSTRAP = 0;// for system level bootstrap components +public static final int RUN_LEVEL_SYSTEM = 1;// for system level service components (i.e., DAOs) +public static final int RUN_LEVEL_FRAMEWORK_BOOTSTRAP = 2;// for framework startup checkers (i.e., DB migration check) +public static final int RUN_LEVEL_FRAMEWORK = 3;// for framework bootstrap components(i.e., clustering management components) +public static final int RUN_LEVEL_COMPONENT_BOOTSTRAP = 4;// general manager components +public static final int RUN_LEVEL_COMPONENT = 5;// regular adapters, plugin components +public static final int RUN_LEVEL_APPLICATION_MAINLOOP = 6; +public static final int MAX_RUN_LEVELS = 7; + +@Override +String getName(); + +void setName(String name); + +void setConfigParams(Map params); + +Map getConfigParams(); + +int getRunLevel(); + +void setRunLevel(int level); + +public boolean configure(String name, Map params) throws ConfigurationException; + +/** + * Start any background tasks. + * + * @return true if the tasks were started, false otherwise. + */ +public boolean start(); + +/** + * Stop any background tasks. + * + * @return true background tasks were stopped, false otherwise. + */ +public boolean stop(); +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java -- diff --git a/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java b/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java new file mode 100644 index 000..829dc9b --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/component/ComponentLifecycleBase.java @@ -0,0 +1,87 @@ +// +// 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 com.cloud.utils.component; + +import java.util.HashMap; +import java.util.Map; + +import javax.naming.ConfigurationException; + +import org.apache.log4j.Logger; + +public class ComponentLifecycleBase implements ComponentLifecycle { +private static final Logger s_logger = Logger.getLogger(ComponentLifecycleBase.class); + +protected String _name; +protected int _runLevel; +protected Map _configParams = new HashMap(); + +public ComponentLifecycleBase() { +_name = this.getClass().getSimpleName(); +_runLevel = RUN_LEVEL_COMPONENT; +} + +@Override +public String getName() { +return _name; +} + +@Override +public void setNam
[15/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/net/NetUtils.java -- diff --git a/utils/src/main/java/com/cloud/utils/net/NetUtils.java b/utils/src/main/java/com/cloud/utils/net/NetUtils.java new file mode 100644 index 000..883129b --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/net/NetUtils.java @@ -0,0 +1,1550 @@ +// +// 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 com.cloud.utils.net; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.math.BigInteger; +import java.net.InetAddress; +import java.net.InterfaceAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.URI; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Formatter; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.SortedSet; +import java.util.StringTokenizer; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang.SystemUtils; +import org.apache.commons.net.util.SubnetUtils; +import org.apache.commons.validator.routines.InetAddressValidator; +import org.apache.log4j.Logger; + +import com.cloud.utils.IteratorUtil; +import com.cloud.utils.Pair; +import com.cloud.utils.script.Script; +import com.googlecode.ipv6.IPv6Address; +import com.googlecode.ipv6.IPv6AddressRange; +import com.googlecode.ipv6.IPv6Network; + +public class NetUtils { +protected final static Logger s_logger = Logger.getLogger(NetUtils.class); + +private static final int MAX_CIDR = 32; +private static final int RFC_3021_31_BIT_CIDR = 31; + +public final static String HTTP_PORT = "80"; +public final static String HTTPS_PORT = "443"; +public final static int VPN_PORT = 500; +public final static int VPN_NATT_PORT = 4500; +public final static int VPN_L2TP_PORT = 1701; +public final static int HAPROXY_STATS_PORT = 8081; + +public final static String UDP_PROTO = "udp"; +public final static String TCP_PROTO = "tcp"; +public final static String ANY_PROTO = "any"; +public final static String ICMP_PROTO = "icmp"; +public final static String ALL_PROTO = "all"; +public final static String HTTP_PROTO = "http"; +public final static String SSL_PROTO = "ssl"; + +public final static String ALL_CIDRS = "0.0.0.0/0"; +public final static int PORT_RANGE_MIN = 0; +public final static int PORT_RANGE_MAX = 65535; + +public final static int DEFAULT_AUTOSCALE_VM_DESTROY_TIME = 2 * 60; // Grace period before Vm is destroyed +public final static int DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME = 30; +public final static int DEFAULT_AUTOSCALE_POLICY_QUIET_TIME = 5 * 60; +private final static Random s_rand = new Random(System.currentTimeMillis()); + +public static long createSequenceBasedMacAddress(final long macAddress) { +return macAddress | 0x0600l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe00l; +} + +public static String getHostName() { +try { +final InetAddress localAddr = InetAddress.getLocalHost(); +if (localAddr != null) { +return localAddr.getHostName(); +} +} catch (final UnknownHostException e) { +s_logger.warn("UnknownHostException when trying to get host name. ", e); +} +return "localhost"; +} + +public static InetAddress getLocalInetAddress() { +try { +return InetAddress.getLocalHost(); +} catch (final UnknownHostException e) { +s_logger.warn("UnknownHostException in getLocalInetAddress().", e); +return null; +} +} + +public static String resolveToIp(final String host) { +try { +final InetAddress addr = InetAddress.getByName(host); +return ipFromInetAddress(addr); +} catch (final UnknownHostException e) { +s_logger.warn("Unable to resolve " + host + " to IP due to UnknownHostException"); +return nul
[16/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/exception/ExceptionUtil.java -- diff --git a/utils/src/main/java/com/cloud/utils/exception/ExceptionUtil.java b/utils/src/main/java/com/cloud/utils/exception/ExceptionUtil.java new file mode 100644 index 000..351d2ab --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/exception/ExceptionUtil.java @@ -0,0 +1,54 @@ +// +// 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 com.cloud.utils.exception; + +import java.io.PrintWriter; +import java.io.StringWriter; + +public class ExceptionUtil { +public static String toString(Throwable th) { +return toString(th, true); +} + +public static String toString(Throwable th, boolean printStack) { +final StringWriter writer = new StringWriter(); +writer.append("Exception: " + th.getClass().getName() + "\n"); +writer.append("Message: "); +writer.append(th.getMessage()).append("\n"); + +if (printStack) { +writer.append("Stack: "); +th.printStackTrace(new PrintWriter(writer)); +} +return writer.toString(); +} + +@SuppressWarnings("unchecked") +public static void rethrow(Throwable t, Class clz) throws T { +if (clz.isAssignableFrom(t.getClass())) +throw (T)t; +} + +public static void rethrowRuntime(Throwable t) { +rethrow(t, RuntimeException.class); +rethrow(t, Error.class); +} + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/exception/ExecutionException.java -- diff --git a/utils/src/main/java/com/cloud/utils/exception/ExecutionException.java b/utils/src/main/java/com/cloud/utils/exception/ExecutionException.java new file mode 100644 index 000..7b3bc61 --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/exception/ExecutionException.java @@ -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 com.cloud.utils.exception; + +import com.cloud.utils.SerialVersionUID; + +/** + * a public method. + * + */ +public class ExecutionException extends Exception { +private static final long serialVersionUID = SerialVersionUID.ExecutionException; + +protected int csErrorCode; + +public ExecutionException(String msg, Throwable cause) { +super(msg, cause); + setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); +} + +public ExecutionException(String msg) { +super(msg); +} + +public void setCSErrorCode(int cserrcode) { +this.csErrorCode = cserrcode; +} + +public int getCSErrorCode() { +return this.csErrorCode; +} +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/exception/HypervisorVersionChangedException.java -- diff --git a/utils/src/main/java/com/cloud/utils/exception/HypervisorVersionChangedException.java b/utils/src/main/java/com/cloud/utils/exception/HypervisorVersionChangedException.java new file mode 100644 index 000..55c273b --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/exception/HypervisorVersionChangedException.java @@ -0,0 +1,35 @@
[09/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/test/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java -- diff --git a/utils/test/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java b/utils/test/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java deleted file mode 100644 index 0f3f058..000 --- a/utils/test/com/cloud/utils/crypto/EncryptionSecretKeyCheckerTest.java +++ /dev/null @@ -1,45 +0,0 @@ -// -// 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 com.cloud.utils.crypto; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; - -import org.junit.Assert; -import org.junit.Test; - -import com.cloud.utils.crypt.EncryptionSecretKeyChecker; -import com.cloud.utils.db.DbProperties; -import com.cloud.utils.exception.CloudRuntimeException; - -public class EncryptionSecretKeyCheckerTest { - - private EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker(); - - @Test(expected = CloudRuntimeException.class) - public void testKeyFileDoesNotExists() throws IOException, URISyntaxException { -Assert.assertNotNull(checker); -Properties properties = DbProperties.getDbProperties(); -properties.setProperty("db.cloud.encryption.type", "file"); -checker.check(properties); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/test/com/cloud/utils/crypto/RSAHelperTest.java -- diff --git a/utils/test/com/cloud/utils/crypto/RSAHelperTest.java b/utils/test/com/cloud/utils/crypto/RSAHelperTest.java deleted file mode 100644 index 27d9d50..000 --- a/utils/test/com/cloud/utils/crypto/RSAHelperTest.java +++ /dev/null @@ -1,54 +0,0 @@ -// -// 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 com.cloud.utils.crypto; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -import com.cloud.utils.crypt.RSAHelper; - -public class RSAHelperTest { -@Test -public void testEncryptWithRSA() { -String rsaKey = -"ssh-rsa B3NzaC1yc2EDAQABAAABAQC2D2Cs0XAEqm+ajJpumIPrMpKp0CWtIW+8ZY2/MJCW" -+ "hge1eY18u9I3PPnkMVJsTOaN0wQojjw4AkKgKjNZXA9wyUq56UyN/stmipu8zifWPgxQGDRkuzzZ6buk" -+ "ef8q2Awjpo8hv5/0SRPJxQLEafESnUP+Uu/LUwk5VVC7PHzywJRUGFuzDl/uT72+6hqpL2YpC6aTl4/P" -+ "2eDvUQhCdL9dBmUSFX8ftT53W1jhsaQl7mPElVgSCtWz3IyRkogobMPrpJW/IPKEiojKIuvNoNv4CDR6" + "ybeVjHOJMb9wi62rXo+CzUsW0Y4jPOX/OykAm5vrNOhQhw0aaBcv5XVv8BRX"; -String encryptedString = RSAHelper.encryptWithSSHPublicKey(rsaKey, "content"); -assertNotNull(encryptedString); -} - -@Test -public void testEncryptWithDSA() { -String dssKey = -"ssh-dss B3NzaC1kc3MAAACBALbaewDnzZ5AcGbZno7VW1m7Si3Q+yEANXZioVupfSwOP0q9aP2iV" -+ "tyqq575JnUVZXMDR2Gr254F/qCJ0TKAvucN0gcd2XslX4jBcu1Z7s7YZf6d7fC58k0NE6/keokJNKhQO" -+ "i56iirRzSA/YFrD64mzfq6rEmai0q7GjGGP0RT1FQDO5++6JonyqnoRkV9Yl1OaEOPjVwAAAIAYA" -+ "tqtKtU/INlTIuL3wt3nyKzwPUnz3fqxP5Ger3OlRZsOahalTFt2OF5jGGmCunyBTRteOetZObr0QhUIF" -+ "4bSDr6UiYYYbH1ES0ws/t1mDIeTh3UUHV1QYACN6c07FKyKLMtB9AthiG2FMLKCEedG3NeXItuNzsuQD" -+ "+n/K1rzMIBi
[23/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/net/NetUtils.java -- diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java deleted file mode 100644 index 883129b..000 --- a/utils/src/com/cloud/utils/net/NetUtils.java +++ /dev/null @@ -1,1550 +0,0 @@ -// -// 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 com.cloud.utils.net; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.math.BigInteger; -import java.net.InetAddress; -import java.net.InterfaceAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.URI; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Formatter; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.SortedSet; -import java.util.StringTokenizer; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.lang.SystemUtils; -import org.apache.commons.net.util.SubnetUtils; -import org.apache.commons.validator.routines.InetAddressValidator; -import org.apache.log4j.Logger; - -import com.cloud.utils.IteratorUtil; -import com.cloud.utils.Pair; -import com.cloud.utils.script.Script; -import com.googlecode.ipv6.IPv6Address; -import com.googlecode.ipv6.IPv6AddressRange; -import com.googlecode.ipv6.IPv6Network; - -public class NetUtils { -protected final static Logger s_logger = Logger.getLogger(NetUtils.class); - -private static final int MAX_CIDR = 32; -private static final int RFC_3021_31_BIT_CIDR = 31; - -public final static String HTTP_PORT = "80"; -public final static String HTTPS_PORT = "443"; -public final static int VPN_PORT = 500; -public final static int VPN_NATT_PORT = 4500; -public final static int VPN_L2TP_PORT = 1701; -public final static int HAPROXY_STATS_PORT = 8081; - -public final static String UDP_PROTO = "udp"; -public final static String TCP_PROTO = "tcp"; -public final static String ANY_PROTO = "any"; -public final static String ICMP_PROTO = "icmp"; -public final static String ALL_PROTO = "all"; -public final static String HTTP_PROTO = "http"; -public final static String SSL_PROTO = "ssl"; - -public final static String ALL_CIDRS = "0.0.0.0/0"; -public final static int PORT_RANGE_MIN = 0; -public final static int PORT_RANGE_MAX = 65535; - -public final static int DEFAULT_AUTOSCALE_VM_DESTROY_TIME = 2 * 60; // Grace period before Vm is destroyed -public final static int DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME = 30; -public final static int DEFAULT_AUTOSCALE_POLICY_QUIET_TIME = 5 * 60; -private final static Random s_rand = new Random(System.currentTimeMillis()); - -public static long createSequenceBasedMacAddress(final long macAddress) { -return macAddress | 0x0600l | (long)s_rand.nextInt(32768) << 25 & 0x00fffe00l; -} - -public static String getHostName() { -try { -final InetAddress localAddr = InetAddress.getLocalHost(); -if (localAddr != null) { -return localAddr.getHostName(); -} -} catch (final UnknownHostException e) { -s_logger.warn("UnknownHostException when trying to get host name. ", e); -} -return "localhost"; -} - -public static InetAddress getLocalInetAddress() { -try { -return InetAddress.getLocalHost(); -} catch (final UnknownHostException e) { -s_logger.warn("UnknownHostException in getLocalInetAddress().", e); -return null; -} -} - -public static String resolveToIp(final String host) { -try { -final InetAddress addr = InetAddress.getByName(host); -return ipFromInetAddress(addr); -} catch (final UnknownHostException e) { -s_logger.warn("Unable to resolve " + host + " to IP due to UnknownHostException"); -return null; -} -} - -public s
[19/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/StringUtils.java -- diff --git a/utils/src/main/java/com/cloud/utils/StringUtils.java b/utils/src/main/java/com/cloud/utils/StringUtils.java new file mode 100644 index 000..c598be8 --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/StringUtils.java @@ -0,0 +1,323 @@ +// +// 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 com.cloud.utils; + +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.owasp.esapi.StringUtilities; + +public class StringUtils { +private static final char[] hexChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + +private static Charset preferredACSCharset; +private static final String UTF8 = "UTF-8"; + +static { +if (isUtf8Supported()) { +preferredACSCharset = Charset.forName(UTF8); +} else { +preferredACSCharset = Charset.defaultCharset(); +} +} + +public static Charset getPreferredCharset() { +return preferredACSCharset; +} + +public static boolean isUtf8Supported() { +return Charset.isSupported(UTF8); +} + +protected static Charset getDefaultCharset() { +return Charset.defaultCharset(); +} + +public static String join(final Iterable iterable, final String delim) { +final StringBuilder sb = new StringBuilder(); +if (iterable != null) { +final Iterator iter = iterable.iterator(); +if (iter.hasNext()) { +final Object next = iter.next(); +sb.append(next.toString()); +} +while (iter.hasNext()) { +final Object next = iter.next(); +sb.append(delim + next.toString()); +} +} +return sb.toString(); +} + +public static String join(final String delimiter, final Object... components) { +return org.apache.commons.lang.StringUtils.join(components, delimiter); +} + +public static boolean isNotBlank(final String str) { +if (str != null && str.trim().length() > 0) { +return true; +} + +return false; +} + +public static String cleanupTags(String tags) { +if (tags != null) { +final String[] tokens = tags.split(","); +final StringBuilder t = new StringBuilder(); +for (int i = 0; i < tokens.length; i++) { +t.append(tokens[i].trim()).append(","); +} +t.delete(t.length() - 1, t.length()); +tags = t.toString(); +} + +return tags; +} + +/** + * @param tags + * @return List of tags + */ +public static List csvTagsToList(final String tags) { +final List tagsList = new ArrayList(); + +if (tags != null) { +final String[] tokens = tags.split(","); +for (int i = 0; i < tokens.length; i++) { +tagsList.add(tokens[i].trim()); +} +} + +return tagsList; +} + +/** + * Converts a List of tags to a comma separated list + * @param tags + * @return String containing a comma separated list of tags + */ + +public static String listToCsvTags(final List tagsList) { +final StringBuilder tags = new StringBuilder(); +if (tagsList.size() > 0) { +for (int i = 0; i < tagsList.size(); i++) { +tags.append(tagsList.get(i)); +if (i != tagsList.size() - 1) { +tags.append(','); +} +} +} + +return tags.toString(); +} + +public static String getExceptionStackInfo(final Throwable e) { +final StringBuffer sb = new StringBuffer(); + +sb.append(e.toString()).append("\n"); +final StackTraceElement[] elemnents = e.getStackTrace(); +for (f
[18/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java -- diff --git a/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java new file mode 100644 index 000..447e21b --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/cisco/n1kv/vsm/VsmCommand.java @@ -0,0 +1,999 @@ +// +// 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 com.cloud.utils.cisco.n1kv.vsm; + +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.log4j.Logger; +import org.w3c.dom.DOMException; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSSerializer; + +import com.cloud.utils.Pair; + +public class VsmCommand { + +private static final Logger s_logger = Logger.getLogger(VsmCommand.class); +private static final String s_namespace = "urn:ietf:params:xml:ns:netconf:base:1.0"; +private static final String s_ciscons = "http://www.cisco.com/nxos:1.0:ppm";; +private static final String s_configuremode = "__XML__MODE__exec_configure"; +private static final String s_portprofmode = "__XML__MODE_port-prof"; +private static final String s_policymapmode = "__XML__MODE_policy-map"; +private static final String s_classtypemode = "__XML__MODE_policy-map_class_type"; +private static final String s_paramvalue = "__XML__PARAM_value"; + +public enum PortProfileType { +none, vethernet, ethernet; +} + +public enum BindingType { +none, portbindingstatic, portbindingdynamic, portbindingephermal; +} + +public enum SwitchPortMode { +none, access, trunk, privatevlanhost, privatevlanpromiscuous +} + +public enum OperationType { +addvlanid, removevlanid +} + +public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid, String vdc, String espName) { +try { +// Create the document and root element. +DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); +DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); +DOMImplementation domImpl = docBuilder.getDOMImplementation(); +Document doc = createDocument(domImpl); + +// Edit configuration command. +Element editConfig = doc.createElement("nf:edit-config"); +doc.getDocumentElement().appendChild(editConfig); + +// Command to get into exec configure mode. +Element target = doc.createElement("nf:target"); +Element running = doc.createElement("nf:running"); +target.appendChild(running); +editConfig.appendChild(target); + +// Command to create the port profile with the desired configuration. +Element config = doc.createElement("nf:config"); +config.appendChild(configPortProfileDetails(doc, name, type, binding, mode, vlanid, vdc, espName)); +editConfig.appendChild(config); + +return serialize(domImpl, doc); +} catch (ParserConfigurationException e) { +s_logger.error("Error while creating add port profile message : " + e.getMessage()); +return null; +} catch (DOMException e) { +s_logger.error("Error while creating add port profile message : " + e.getMessage()); +return null; +} +} + +public static String getAddPortProfile(String name, PortProfileType type, BindingType binding, SwitchPortMode mode, int vlanid) { +try { +// Create the document and root element. +DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); +DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); +DOMImplemen
[24/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/exception/ExceptionUtil.java -- diff --git a/utils/src/com/cloud/utils/exception/ExceptionUtil.java b/utils/src/com/cloud/utils/exception/ExceptionUtil.java deleted file mode 100644 index 351d2ab..000 --- a/utils/src/com/cloud/utils/exception/ExceptionUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -// -// 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 com.cloud.utils.exception; - -import java.io.PrintWriter; -import java.io.StringWriter; - -public class ExceptionUtil { -public static String toString(Throwable th) { -return toString(th, true); -} - -public static String toString(Throwable th, boolean printStack) { -final StringWriter writer = new StringWriter(); -writer.append("Exception: " + th.getClass().getName() + "\n"); -writer.append("Message: "); -writer.append(th.getMessage()).append("\n"); - -if (printStack) { -writer.append("Stack: "); -th.printStackTrace(new PrintWriter(writer)); -} -return writer.toString(); -} - -@SuppressWarnings("unchecked") -public static void rethrow(Throwable t, Class clz) throws T { -if (clz.isAssignableFrom(t.getClass())) -throw (T)t; -} - -public static void rethrowRuntime(Throwable t) { -rethrow(t, RuntimeException.class); -rethrow(t, Error.class); -} - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/exception/ExecutionException.java -- diff --git a/utils/src/com/cloud/utils/exception/ExecutionException.java b/utils/src/com/cloud/utils/exception/ExecutionException.java deleted file mode 100644 index 7b3bc61..000 --- a/utils/src/com/cloud/utils/exception/ExecutionException.java +++ /dev/null @@ -1,49 +0,0 @@ -// -// 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 com.cloud.utils.exception; - -import com.cloud.utils.SerialVersionUID; - -/** - * a public method. - * - */ -public class ExecutionException extends Exception { -private static final long serialVersionUID = SerialVersionUID.ExecutionException; - -protected int csErrorCode; - -public ExecutionException(String msg, Throwable cause) { -super(msg, cause); - setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); -} - -public ExecutionException(String msg) { -super(msg); -} - -public void setCSErrorCode(int cserrcode) { -this.csErrorCode = cserrcode; -} - -public int getCSErrorCode() { -return this.csErrorCode; -} -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java -- diff --git a/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java b/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java deleted file mode 100644 index 55c273b..000 --- a/utils/src/com/cloud/utils/exception/HypervisorVersionChangedException.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements.
[03/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Merge pull request #734 from remibergsma/git-pr-errormsg Git PR merge script improvementsProcessed feedback from @bhaisaab and (a colleague of) @karuturi - make the help message better (I also updated Confluence) - make sure we can use it on other repo's as well (Documentation and such) Tested it and works fine for me. * pr/734: fixed hardcoded merge message location fix bug where the countdown would be on multiple lines make it work with any Apache repository mirrored on GitHub Improve error/help message in case of missing git remote Signed-off-by: Remi Bergsma Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a527d272 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a527d272 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a527d272 Branch: refs/heads/deploy-from-snapshot Commit: a527d27299379aefefb96aeb30c2dd4423877b1f Parents: 82df5b1 1e6df1b Author: Remi Bergsma Authored: Mon Aug 24 22:15:36 2015 +0200 Committer: Remi Bergsma Committed: Mon Aug 24 22:15:36 2015 +0200 -- tools/git/git-pr | 27 --- 1 file changed, 20 insertions(+), 7 deletions(-) --
[08/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Fix unit-test library dependencies - XML formatting - Fix license header - Reorder hamcrest, junit, mockito and powermock dependencies * Since several libraries include a subset of hamcrest classes, hamcrest should be declared first in the pom, inorder for its classes to be loaded first by the JVM - Depdend on hamcrest-all and exclude hamcrest classes from other libraries Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3d27e9ed Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3d27e9ed Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3d27e9ed Branch: refs/heads/deploy-from-snapshot Commit: 3d27e9ed1206e0ff8cef5fa850e7b012427a56ef Parents: 98dd771 Author: Miguel Ferreira Authored: Sun Aug 23 16:11:06 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 14:50:31 2015 +0200 -- pom.xml | 165 ++- 1 file changed, 94 insertions(+), 71 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3d27e9ed/pom.xml -- diff --git a/pom.xml b/pom.xml index f5f4e61..95b90db 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,23 @@ - + http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";> 4.0.0 @@ -32,7 +43,7 @@ jira https://issues.apache.org/jira/browse/CLOUDSTACK - + 3.0.4 @@ -424,14 +435,8 @@ - junit - junit - ${cs.junit.version} - test - - org.hamcrest - hamcrest-library + hamcrest-all ${cs.hamcrest.version} test @@ -440,17 +445,35 @@ mockito-all ${cs.mockito.version} test + + + hamcrest-core + org.hamcrest + + - org.powermock - powermock-module-junit4 - ${cs.powermock.version} + junit + junit + ${cs.junit.version} + test + + + hamcrest-core + org.hamcrest + + + + + org.powermock + powermock-module-junit4 + ${cs.powermock.version} - org.powermock - powermock-api-mockito - ${cs.powermock.version} - test + org.powermock + powermock-api-mockito + ${cs.powermock.version} + test org.springframework @@ -485,13 +508,13 @@ org.apache.maven.plugins maven-checkstyle-plugin - - - cloudstack-checkstyle - none - false - - + + +cloudstack-checkstyle +none +false + + com.mycila @@ -570,9 +593,9 @@ true LICENSE.header - XML_STYLE - Â Â DOUBLESLASH_STYLE - Â Â SEMICOLON_STYLE + XML_STYLE + DOUBLESLASH_STYLE + SEMICOLON_STYLE false @@ -627,8 +650,8 @@ - + org.eclipse.m2e lifecycle-mapping @@ -646,7 +669,7 @@ - + @@ -659,7 +682,7 @@ - + @@ -682,12 +705,12 @@ gmaven-plugin [1.3,) -compile -testCompile + compile + testCompile - + @@ -841,7 +864,7 @@ tools/ngui/static/js/lib/* **/.checkstyle scripts/installer/windows/acs_license.rtf - **/*.md + **/*.md @@ -943,9 +966,9 @@ false - - cloud-pmd.xml - + + cloud-pmd.xml + @@ -986,18 +1009,18 @@ - org.apache.maven.plugins - maven-javadoc-plugin - ${cs.javadoc.version} - - 128m - 1g -
[14/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/nio/NioClient.java -- diff --git a/utils/src/main/java/com/cloud/utils/nio/NioClient.java b/utils/src/main/java/com/cloud/utils/nio/NioClient.java new file mode 100644 index 000..2f742f9 --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/nio/NioClient.java @@ -0,0 +1,125 @@ +// +// 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 com.cloud.utils.nio; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; +import java.security.GeneralSecurityException; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.utils.security.SSLUtils; + +public class NioClient extends NioConnection { +private static final Logger s_logger = Logger.getLogger(NioClient.class); + +protected String _host; +protected String _bindAddress; +protected SocketChannel _clientConnection; + +public NioClient(String name, String host, int port, int workers, HandlerFactory factory) { +super(name, port, workers, factory); +_host = host; +} + +public void setBindAddress(String ipAddress) { +_bindAddress = ipAddress; +} + +@Override +protected void init() throws IOException { +_selector = Selector.open(); +Task task = null; + +try { +_clientConnection = SocketChannel.open(); +_clientConnection.configureBlocking(true); +s_logger.info("Connecting to " + _host + ":" + _port); + +if (_bindAddress != null) { +s_logger.info("Binding outbound interface at " + _bindAddress); + +InetSocketAddress bindAddr = new InetSocketAddress(_bindAddress, 0); +_clientConnection.socket().bind(bindAddr); +} + +InetSocketAddress peerAddr = new InetSocketAddress(_host, _port); +_clientConnection.connect(peerAddr); + +SSLEngine sslEngine = null; +// Begin SSL handshake in BLOCKING mode +_clientConnection.configureBlocking(true); + +SSLContext sslContext = Link.initSSLContext(true); +sslEngine = sslContext.createSSLEngine(_host, _port); +sslEngine.setUseClientMode(true); + sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols())); + +Link.doHandshake(_clientConnection, sslEngine, true); +s_logger.info("SSL: Handshake done"); +s_logger.info("Connected to " + _host + ":" + _port); + +_clientConnection.configureBlocking(false); +Link link = new Link(peerAddr, this); +link.setSSLEngine(sslEngine); +SelectionKey key = _clientConnection.register(_selector, SelectionKey.OP_READ); +link.setKey(key); +key.attach(link); +// Notice we've already connected due to the handshake, so let's get the +// remaining task done +task = _factory.create(Task.Type.CONNECT, link, null); +} catch (GeneralSecurityException e) { +_selector.close(); +throw new IOException("Failed to initialise security", e); +} catch (IOException e) { +_selector.close(); +throw e; +} + +_executor.execute(task); +} + +@Override +protected void registerLink(InetSocketAddress saddr, Link link) { +// don't do anything. +} + +@Override +protected void unregisterLink(InetSocketAddress saddr) { +// don't do anything. +} + +@Override +public void cleanUp() throws IOException { +super.cleanUp(); +if (_clientConnection != null) { +_clientConnection.close(); +} +s_logger.info("NioClient connection closed"); + +} + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/nio/NioConnect
[10/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/test/java/com/cloud/utils/testcase/NioTest.java -- diff --git a/utils/src/test/java/com/cloud/utils/testcase/NioTest.java b/utils/src/test/java/com/cloud/utils/testcase/NioTest.java new file mode 100644 index 000..fc16684 --- /dev/null +++ b/utils/src/test/java/com/cloud/utils/testcase/NioTest.java @@ -0,0 +1,216 @@ +// +// 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 com.cloud.utils.testcase; + +import java.nio.channels.ClosedChannelException; +import java.util.Random; + +import junit.framework.TestCase; + +import org.apache.log4j.Logger; +import org.junit.Assert; + +import com.cloud.utils.nio.HandlerFactory; +import com.cloud.utils.nio.Link; +import com.cloud.utils.nio.NioClient; +import com.cloud.utils.nio.NioServer; +import com.cloud.utils.nio.Task; +import com.cloud.utils.nio.Task.Type; + +/** + * + * + * + * + */ + +public class NioTest extends TestCase { + +private static final Logger s_logger = Logger.getLogger(NioTest.class); + +private NioServer _server; +private NioClient _client; + +private Link _clientLink; + +private int _testCount; +private int _completedCount; + +private boolean isTestsDone() { +boolean result; +synchronized (this) { +result = (_testCount == _completedCount); +} +return result; +} + +private void getOneMoreTest() { +synchronized (this) { +_testCount++; +} +} + +private void oneMoreTestDone() { +synchronized (this) { +_completedCount++; +} +} + +@Override +public void setUp() { +s_logger.info("Test"); + +_testCount = 0; +_completedCount = 0; + +_server = new NioServer("NioTestServer", , 5, new NioTestServer()); +_server.start(); + +_client = new NioClient("NioTestServer", "127.0.0.1", , 5, new NioTestClient()); +_client.start(); + +while (_clientLink == null) { +try { +s_logger.debug("Link is not up! Waiting ..."); +Thread.sleep(1000); +} catch (InterruptedException e) { +// TODO Auto-generated catch block +e.printStackTrace(); +} +} +} + +@Override +public void tearDown() { +while (!isTestsDone()) { +try { +s_logger.debug(this._completedCount + "/" + this._testCount + " tests done. Waiting for completion"); +Thread.sleep(1000); +} catch (InterruptedException e) { +// TODO Auto-generated catch block +e.printStackTrace(); +} +} +stopClient(); +stopServer(); +} + +protected void stopClient() { +_client.stop(); +s_logger.info("Client stopped."); +} + +protected void stopServer() { +_server.stop(); +s_logger.info("Server stopped."); +} + +protected void setClientLink(Link link) { +_clientLink = link; +} + +Random randomGenerator = new Random(); + +byte[] _testBytes; + +public void testConnection() { +_testBytes = new byte[100]; +randomGenerator.nextBytes(_testBytes); +try { +getOneMoreTest(); +_clientLink.send(_testBytes); +s_logger.info("Client: Data sent"); +getOneMoreTest(); +_clientLink.send(_testBytes); +s_logger.info("Client: Data sent"); +} catch (ClosedChannelException e) { +// TODO Auto-generated catch block +e.printStackTrace(); +} +} + +protected void doServerProcess(byte[] data) { +oneMoreTestDone(); +Assert.assertArrayEquals(_testBytes, data); +s_logger.info("Verify done."); +} + +public class NioTestClient implements HandlerFactory { + +@Override +public Task create(Type type, Link link, byte[] data) { +return new NioTestClientHandler(type, link, data); +} + +public class NioTestCli
[22/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/nio/NioClient.java -- diff --git a/utils/src/com/cloud/utils/nio/NioClient.java b/utils/src/com/cloud/utils/nio/NioClient.java deleted file mode 100644 index 2f742f9..000 --- a/utils/src/com/cloud/utils/nio/NioClient.java +++ /dev/null @@ -1,125 +0,0 @@ -// -// 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 com.cloud.utils.nio; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.nio.channels.SelectionKey; -import java.nio.channels.Selector; -import java.nio.channels.SocketChannel; -import java.security.GeneralSecurityException; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.utils.security.SSLUtils; - -public class NioClient extends NioConnection { -private static final Logger s_logger = Logger.getLogger(NioClient.class); - -protected String _host; -protected String _bindAddress; -protected SocketChannel _clientConnection; - -public NioClient(String name, String host, int port, int workers, HandlerFactory factory) { -super(name, port, workers, factory); -_host = host; -} - -public void setBindAddress(String ipAddress) { -_bindAddress = ipAddress; -} - -@Override -protected void init() throws IOException { -_selector = Selector.open(); -Task task = null; - -try { -_clientConnection = SocketChannel.open(); -_clientConnection.configureBlocking(true); -s_logger.info("Connecting to " + _host + ":" + _port); - -if (_bindAddress != null) { -s_logger.info("Binding outbound interface at " + _bindAddress); - -InetSocketAddress bindAddr = new InetSocketAddress(_bindAddress, 0); -_clientConnection.socket().bind(bindAddr); -} - -InetSocketAddress peerAddr = new InetSocketAddress(_host, _port); -_clientConnection.connect(peerAddr); - -SSLEngine sslEngine = null; -// Begin SSL handshake in BLOCKING mode -_clientConnection.configureBlocking(true); - -SSLContext sslContext = Link.initSSLContext(true); -sslEngine = sslContext.createSSLEngine(_host, _port); -sslEngine.setUseClientMode(true); - sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols())); - -Link.doHandshake(_clientConnection, sslEngine, true); -s_logger.info("SSL: Handshake done"); -s_logger.info("Connected to " + _host + ":" + _port); - -_clientConnection.configureBlocking(false); -Link link = new Link(peerAddr, this); -link.setSSLEngine(sslEngine); -SelectionKey key = _clientConnection.register(_selector, SelectionKey.OP_READ); -link.setKey(key); -key.attach(link); -// Notice we've already connected due to the handshake, so let's get the -// remaining task done -task = _factory.create(Task.Type.CONNECT, link, null); -} catch (GeneralSecurityException e) { -_selector.close(); -throw new IOException("Failed to initialise security", e); -} catch (IOException e) { -_selector.close(); -throw e; -} - -_executor.execute(task); -} - -@Override -protected void registerLink(InetSocketAddress saddr, Link link) { -// don't do anything. -} - -@Override -protected void unregisterLink(InetSocketAddress saddr) { -// don't do anything. -} - -@Override -public void cleanUp() throws IOException { -super.cleanUp(); -if (_clientConnection != null) { -_clientConnection.close(); -} -s_logger.info("NioClient connection closed"); - -} - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/nio/NioConnection.java -
[27/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/com/cloud/utils/UriUtils.java -- diff --git a/utils/src/com/cloud/utils/UriUtils.java b/utils/src/com/cloud/utils/UriUtils.java deleted file mode 100644 index 631c629..000 --- a/utils/src/com/cloud/utils/UriUtils.java +++ /dev/null @@ -1,394 +0,0 @@ -// -// 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 com.cloud.utils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import java.util.StringTokenizer; - -import javax.net.ssl.HttpsURLConnection; - -import org.apache.commons.httpclient.Credentials; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.HeadMethod; -import org.apache.commons.httpclient.util.URIUtil; -import org.apache.http.NameValuePair; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.client.utils.URLEncodedUtils; - -import org.apache.http.message.BasicNameValuePair; -import org.apache.log4j.Logger; - -import com.cloud.utils.crypt.DBEncryptionUtil; -import com.cloud.utils.exception.CloudRuntimeException; - -public class UriUtils { - -public static final Logger s_logger = Logger.getLogger(UriUtils.class.getName()); - -public static String formNfsUri(String host, String path) { -try { -URI uri = new URI("nfs", host, path, null); -return uri.toString(); -} catch (URISyntaxException e) { -throw new CloudRuntimeException("Unable to form nfs URI: " + host + " - " + path); -} -} - -public static String formIscsiUri(String host, String iqn, Integer lun) { -try { -String path = iqn; -if (lun != null) { -path += "/" + lun.toString(); -} -URI uri = new URI("iscsi", host, path, null); -return uri.toString(); -} catch (URISyntaxException e) { -throw new CloudRuntimeException("Unable to form iscsi URI: " + host + " - " + iqn + " - " + lun); -} -} - -public static String formFileUri(String path) { -File file = new File(path); - -return file.toURI().toString(); -} - -// a simple URI component helper (Note: it does not deal with URI paramemeter area) -public static String encodeURIComponent(String url) { -int schemeTail = url.indexOf("://"); - -int pathStart = 0; -if (schemeTail > 0) -pathStart = url.indexOf('/', schemeTail + 3); -else -pathStart = url.indexOf('/'); - -if (pathStart > 0) { -String[] tokens = url.substring(pathStart + 1).split("/"); -StringBuilder sb = new StringBuilder(url.substring(0, pathStart)); -for (String token : tokens) { -sb.append("/").append(URLEncoder.encode(token)); -} - -return sb.toString(); -} - -// no need to do URL component encoding -return url; -} - -public static String getCifsUriParametersProblems(URI uri) { -if (!UriUtils.hostAndPathPresent(uri)) { -String errMsg = "cifs URI missing host and/or path. Make sure it's of the format cifs://hostname/path"; -s_logger.warn(errMsg); -return errMsg; -} -return null; -} - -public static boolean hostAndPathPresent(URI uri) { -return !(uri.getHost() == null || uri.getHost().trim().isEmpty() || uri.getPath
[04/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Merge pull request #731 from remibergsma/centos7-kvm CLOUDSTACK-8443: Support CentOS 7 as KVM hypervisorThis adds support for CentOS 7 as a KVM hypervisor. As discussed in the Jira issue, the root cause of the issue was the `cloudstack-setup-agent` script that added this line to `/etc/libvirt/qemu.conf`: `cgroup_controllers=["cpu"]` On CentOS 6 this 'works', but since by default no cgroups are mounted, this setting is ignored by `libvirtd`. On CentOS 7 is does not work, because the `cpu` and `cpuacct` are 'co-mounted'. This simpy means you cannot use one without the order. The config line above instructs `libvirtd` to only use the `cpu` cgroup, which it can't. There was code added to make sure the `cpu` cgroup was not co-mounted. It did this with a shell script, but after a reboot it was gone. It wasn't reliable and not even a solution at all. I went ahead and removed the code, because the co-mounted cgroups work fine. The real issue was the config line we put in `/etc/libvirt/qemu.conf` so much better to fix that instead. The default for `libvirtd` is to use only cgroups that are mounted. When you remove the 'cgroup_controllers' line, the default kicks in. According to the `qemu.conf` file, the default is: `cgroup_controllers = ["cpu", "devices", "memory", "blkio", "cpuacct", "net_cls"]` Then again, if it's not mounted, it's not used. So, that's a nice way to control it. This works just fine for both RHEL/CentOS 6 and RHEL/CentOS 7. Along the debugging, I came across some small issues here and there which I also fixed in this PR. If you test this, be sure to build RPMs from this branch and install those on the KVM hypervisor. At Schuberg Philis we run KVM hypervisors on CentOS 7 for months with these fixes. Now I took the time to fix the issues in CloudStack, rather than work around them. @bhaisaab @karuturi could you please review this? Thanks! Please note: The next step is to fix CLOUDSTACK-8625 (Systemd profile for KVM Agent) as currently a sysvinit script is still used. Although it works, we do not have any systemd benefits. As it is a separate issue, I'll try to address it in a separate PR. * pr/731: CLOUDSTACK-8443: detect CentOS 7.x as RHEL 7 alike CLOUDSTACK-8443: mention the correct logfile CLOUDSTACK-8443: display the right hypervisor type CLOUDSTACK-8443: don't try to fix co-mounted cgroups Signed-off-by: Remi Bergsma Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c0fde9a1 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c0fde9a1 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c0fde9a1 Branch: refs/heads/deploy-from-snapshot Commit: c0fde9a12bf32d0d4009792d05b1648f7c6ea419 Parents: a527d27 0a320c1 Author: Remi Bergsma Authored: Tue Aug 25 10:32:27 2015 +0200 Committer: Remi Bergsma Committed: Tue Aug 25 10:32:27 2015 +0200 -- agent/bindir/cloud-setup-agent.in | 2 +- .../kvm/resource/LibvirtComputingResource.java | 23 - python/lib/cloud_utils.py | 19 --- python/lib/cloudutils/serviceConfig.py | 7 ++- python/lib/cloudutils/utilities.py | 2 +- scripts/vm/hypervisor/kvm/setup-cgroups.sh | 52 6 files changed, 5 insertions(+), 100 deletions(-) --
[06/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Create Nicira NVP devices and enable plugin at deploy Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/abb824e3 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/abb824e3 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/abb824e3 Branch: refs/heads/deploy-from-snapshot Commit: abb824e3db0625b435fa55b49496e41efbcbc894 Parents: 2772e4d Author: Miguel Ferreira Authored: Wed Aug 5 16:03:28 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 14:50:29 2015 +0200 -- tools/marvin/marvin/deployDataCenter.py | 112 +++ 1 file changed, 62 insertions(+), 50 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/abb824e3/tools/marvin/marvin/deployDataCenter.py -- diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index 4fcd696..3dd5667 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -534,7 +534,7 @@ class DeployDataCenters(object): netprov.physicalnetworkid = phynetwrk.id result = self.__apiClient.addNetworkServiceProvider(netprov) self.enableProvider(result.id) -elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp']: +elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp', 'NiciraNvp']: netprov = addNetworkServiceProvider.\ addNetworkServiceProviderCmd() netprov.name = provider.name @@ -548,55 +548,67 @@ class DeployDataCenters(object): self.__addToCleanUp( "NetworkServiceProvider", result.id) -for device in provider.devices: -if provider.name == 'Netscaler': -dev = addNetscalerLoadBalancer.\ -addNetscalerLoadBalancerCmd() -dev.username = device.username -dev.password = device.password -dev.networkdevicetype = device.networkdevicetype -dev.url = configGenerator.getDeviceUrl(device) -dev.physicalnetworkid = phynetwrk.id -ret = self.__apiClient.addNetscalerLoadBalancer( -dev) -if ret.id: +if provider.devices is not None: +for device in provider.devices: +if provider.name == 'Netscaler': +dev = addNetscalerLoadBalancer.\ +addNetscalerLoadBalancerCmd() +dev.username = device.username +dev.password = device.password +dev.networkdevicetype = device.networkdevicetype +dev.url = configGenerator.getDeviceUrl(device) +dev.physicalnetworkid = phynetwrk.id +ret = self.__apiClient.addNetscalerLoadBalancer( +dev) +if ret.id: +self.__tcRunLogger.\ +debug(" AddNetScalerLB " + "Successful=") +self.__addToCleanUp( +"NetscalerLoadBalancer", +ret.id) +elif provider.name == 'JuniperSRX': +dev = addSrxFirewall.addSrxFirewallCmd() +dev.username = device.username +dev.password = device.password +dev.networkdevicetype = device.networkdevicetype +dev.url = configGenerator.getDeviceUrl(device) +dev.physicalnetworkid = phynetwrk.id +ret = self.__apiClient.addSrxFirewall(dev) +if ret.id: +self.__tcRunLogger.\ +debug(" AddSrx " + "Successful=") +self.__addToCleanUp("SrxFirewall", ret.id) +elif provider.name == 'F5BigIp': +dev = addF5LoadBalancer.addF5LoadBalancerCmd() +
[13/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java -- diff --git a/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java b/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java new file mode 100644 index 000..d43542f --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/security/CertificateHelper.java @@ -0,0 +1,166 @@ +// +// 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 com.cloud.utils.security; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.StringReader; +import java.security.Key; +import java.security.KeyFactory; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.cert.Certificate; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.ArrayList; +import java.util.List; + +import com.cloud.utils.exception.CloudRuntimeException; +import org.apache.commons.codec.binary.Base64; + +import com.cloud.utils.Ternary; +import org.bouncycastle.openssl.PEMReader; + +public class CertificateHelper { +public static byte[] buildAndSaveKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException, +NoSuchAlgorithmException, InvalidKeySpecException, IOException { +KeyStore ks = buildKeystore(alias, cert, privateKey, storePassword); + +ByteArrayOutputStream os = new ByteArrayOutputStream(); +ks.store(os, storePassword != null ? storePassword.toCharArray() : null); +os.close(); +return os.toByteArray(); +} + +public static byte[] buildAndSaveKeystore(List> certs, String storePassword) throws KeyStoreException, NoSuchAlgorithmException, +CertificateException, IOException, InvalidKeySpecException { +KeyStore ks = KeyStore.getInstance("JKS"); +ks.load(null, storePassword != null ? storePassword.toCharArray() : null); + +//name,cert,key +for (Ternary cert : certs) { +if (cert.third() == null) { +Certificate c = buildCertificate(cert.second()); +ks.setCertificateEntry(cert.first(), c); +} else { +Certificate[] c = new Certificate[certs.size()]; +int i = certs.size(); +for (Ternary ct : certs) { +c[i - 1] = buildCertificate(ct.second()); +i--; +} +ks.setKeyEntry(cert.first(), buildPrivateKey(cert.third()), storePassword != null ? storePassword.toCharArray() : null, c); +} +} + +ByteArrayOutputStream os = new ByteArrayOutputStream(); +ks.store(os, storePassword != null ? storePassword.toCharArray() : null); +os.close(); +return os.toByteArray(); +} + +public static KeyStore loadKeystore(byte[] ksData, String storePassword) throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { +assert (ksData != null); +KeyStore ks = KeyStore.getInstance("JKS"); +ks.load(new ByteArrayInputStream(ksData), storePassword != null ? storePassword.toCharArray() : null); + +return ks; +} + +public static KeyStore buildKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException, +NoSuchAlgorithmException, InvalidKeySpecException, IOException { + +KeyStore ks = KeyStore.getInstance("JKS"); +ks.load(null, storePassword != null ? storePassword.toCharArray() : null); +Certificate[] certs = new Certificate[1]; +certs[0] = buildCertificate(
[07/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Add Marvin test for Nicira NVP plugin Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/98dd7717 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/98dd7717 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/98dd7717 Branch: refs/heads/deploy-from-snapshot Commit: 98dd7717026d3da6c034140fbadb06eb88eaf41d Parents: abb824e Author: Miguel Ferreira Authored: Fri Aug 21 17:39:02 2015 +0200 Committer: Miguel Ferreira Committed: Tue Aug 25 14:50:30 2015 +0200 -- .../integration/smoke/test_nicira_controller.py | 310 +++ tools/marvin/marvin/cloudstackTestCase.py | 4 + tools/marvin/marvin/lib/base.py | 46 +++ 3 files changed, 360 insertions(+) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/98dd7717/test/integration/smoke/test_nicira_controller.py -- diff --git a/test/integration/smoke/test_nicira_controller.py b/test/integration/smoke/test_nicira_controller.py new file mode 100644 index 000..229612d --- /dev/null +++ b/test/integration/smoke/test_nicira_controller.py @@ -0,0 +1,310 @@ +#!/usr/bin/env python +# 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. + +import requests +from marvin.cloudstackTestCase import cloudstackTestCase +from marvin.lib.utils import cleanup_resources +from marvin.lib.base import ( +PhysicalNetwork, +NetworkOffering, +NiciraNvp, +ServiceOffering, +Network, +VirtualMachine +) +from marvin.lib.common import (get_domain, get_zone, get_template) +from nose.plugins.attrib import attr +from marvin.codes import (FAILED, PASS) +import time + +class TestNiciraContoller(cloudstackTestCase): + +@classmethod +def setUpClass(cls): +test_case = super(TestNiciraContoller, cls) + +test_client= test_case.getClsTestClient() +cls.config = test_case.getClsConfig() +cls.api_client = test_client.getApiClient() + +cls.physical_networks = cls.config.zones[0].physical_networks +cls.nicira_hosts = cls.config.niciraNvp.hosts + +cls.physical_network_id = cls.get_nicira_enabled_physical_network_id(cls.physical_networks) + +cls.network_offerring_services = { +'name': 'NiciraEnabledNetwork', +'displaytext': 'NiciraEnabledNetwork', +'guestiptype': 'Isolated', +'supportedservices': 'SourceNat,Firewall,PortForwarding,Connectivity', +'traffictype': 'GUEST', +'availability': 'Optional', +'serviceProviderList': { +'SourceNat': 'VirtualRouter', +'Firewall': 'VirtualRouter', +'PortForwarding': 'VirtualRouter', +'Connectivity': 'NiciraNvp' +} +} + +cls.network_offering = NetworkOffering.create(cls.api_client, cls.network_offerring_services) +cls.network_offering.update(cls.api_client, state='Enabled') + +cls.nicira_credentials = { +'username': 'admin', +'password': 'admin' +} + +cls.nicira_master_controller = cls.determine_master_controller( +cls.nicira_hosts, +cls.nicira_credentials +) + +cls.transport_zone_uuid = cls.get_transport_zone_from_controller( +cls.nicira_master_controller, +cls.nicira_credentials +) + +cls.domain = get_domain(cls.api_client) +cls.zone = get_zone(cls.api_client, test_client.getZoneForTests()) + +template = get_template( +cls.api_client, +cls.zone.id +) +if template == FAILED: +raise Exception("get_template() failed to return template with description %s" % cls.services['ostype']) + +cls.vm_services = { +'mode': cls.zone.networktype, +'small': { +'zoneid': cls.zone.id, +'template':
[11/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/test/java/com/cloud/utils/StringUtilsTest.java -- diff --git a/utils/src/test/java/com/cloud/utils/StringUtilsTest.java b/utils/src/test/java/com/cloud/utils/StringUtilsTest.java new file mode 100644 index 000..3619ede --- /dev/null +++ b/utils/src/test/java/com/cloud/utils/StringUtilsTest.java @@ -0,0 +1,253 @@ +// +// 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 com.cloud.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; + +import org.junit.Test; + +public class StringUtilsTest { + +@Test +public void testGetPreferredCharset() { +final boolean ifUtf8Supported = StringUtils.isUtf8Supported(); +if (ifUtf8Supported) { +assertEquals(StringUtils.getPreferredCharset(), Charset.forName("UTF-8")); +} else { +assertNotEquals(StringUtils.getPreferredCharset(), Charset.forName("UTF-8")); +} +} + +@Test +public void testGetDefaultCharset() { +// Is this test irrelevant? Is wrapping the Charset.defaultCharset() too much? +// This test was added in order to cover the new StringUtils.getDefaultCharset(). +// One cannot be sure that StringUtils.getPreferredCharset() will always be +// equals to Charset.defaultCharset() +assertEquals(StringUtils.getDefaultCharset(), Charset.defaultCharset()); +} + +@Test +public void testCleanPasswordFromJsonObjectAtEnd() { +final String input = "{\"foo\":\"bar\",\"password\":\"test\"}"; +//TODO: It would be nice to clean up the regex in question to not +//have to return the trailing comma in the expected string below +final String expected = "{\"foo\":\"bar\",}"; +final String result = StringUtils.cleanString(input); +assertEquals(result, expected); +} + +@Test +public void testCleanPasswordFromJsonObjectInMiddle() { +final String input = "{\"foo\":\"bar\",\"password\":\"test\",\"test\":\"blah\"}"; +final String expected = "{\"foo\":\"bar\",\"test\":\"blah\"}"; +final String result = StringUtils.cleanString(input); +assertEquals(result, expected); +} + +@Test +public void testCleanPasswordFromJsonObjectAlone() { +final String input = "{\"password\":\"test\"}"; +final String expected = "{}"; +final String result = StringUtils.cleanString(input); +assertEquals(result, expected); +} + +@Test +public void testCleanPasswordFromJsonObjectAtStart() { +final String input = "{\"password\":\"test\",\"test\":\"blah\"}"; +final String expected = "{\"test\":\"blah\"}"; +final String result = StringUtils.cleanString(input); +assertEquals(result, expected); +} + +@Test +public void testCleanPasswordFromJsonObjectWithMultiplePasswords() { +final String input = "{\"description\":\"foo\"}],\"password\":\"bar\",\"nic\":[{\"password\":\"bar2\",\"id\":\"1\"}]}"; +final String expected = "{\"description\":\"foo\"}],\"nic\":[{\"id\":\"1\"}]}"; +final String result = StringUtils.cleanString(input); +assertEquals(result, expected); +} + +@Test +public void testCleanPasswordFromRequestString() { +final String input = "username=foo&password=bar&url=foobar"; +final String expected = "username=foo&url=foobar"; +final String result = StringUtils.cleanString(input); +assertEquals(result, expected); +} + +@Test +public void testCleanPasswordFromEncodedRequestString() { +final String input = "name=SS1&provider=SMB&zoneid=5a60af2b-3025-4f2a-9ecc-8e33bf2b94e3&url=cifs%3A%2F%2F10.102.192.150%2FSMB-Share%2Fsowmya%2Fsecondary%3Fuser%3Dsowmya%26password%3DX%40123%26domain%3DBLR"; +final String expected = "name=SS1&provider=SMB&zoneid=5a60af2b-3025-4f2a-9ecc-8e33bf2b94e3&url=cifs%3A%2F%2F10.102.192.150%2FSMB-Share%2Fsowmya%2Fsecondary%3Fuser
[20/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/com/cloud/utils/HttpUtils.java -- diff --git a/utils/src/main/java/com/cloud/utils/HttpUtils.java b/utils/src/main/java/com/cloud/utils/HttpUtils.java new file mode 100644 index 000..d2e844a --- /dev/null +++ b/utils/src/main/java/com/cloud/utils/HttpUtils.java @@ -0,0 +1,114 @@ +// +// 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 com.cloud.utils; + +import org.apache.log4j.Logger; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; +import java.util.Map; + +public class HttpUtils { + +public static final Logger s_logger = Logger.getLogger(HttpUtils.class); + +public static final String UTF_8 = "UTF-8"; +public static final String RESPONSE_TYPE_JSON = "json"; +public static final String RESPONSE_TYPE_XML = "xml"; +public static final String JSON_CONTENT_TYPE = "application/json; charset=UTF-8"; +public static final String XML_CONTENT_TYPE = "text/xml; charset=UTF-8"; + +public static void addSecurityHeaders(final HttpServletResponse resp) { +if (resp.containsHeader("X-Content-Type-Options")) { +resp.setHeader("X-Content-Type-Options", "nosniff"); +} +else { +resp.addHeader("X-Content-Type-Options", "nosniff"); +} +if (resp.containsHeader("X-XSS-Protection")) { +resp.setHeader("X-XSS-Protection", "1;mode=block"); +} +else { +resp.addHeader("X-XSS-Protection", "1;mode=block"); +} +} + +public static void writeHttpResponse(final HttpServletResponse resp, final String response, + final Integer responseCode, final String responseType, final String jsonContentType) { +try { +if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { +if (jsonContentType != null && !jsonContentType.isEmpty()) { +resp.setContentType(jsonContentType); +} else { +resp.setContentType(JSON_CONTENT_TYPE); +} +} else if (RESPONSE_TYPE_XML.equalsIgnoreCase(responseType)){ +resp.setContentType(XML_CONTENT_TYPE); +} +if (responseCode != null) { +resp.setStatus(responseCode); +} +addSecurityHeaders(resp); +resp.getWriter().print(response); +} catch (final IOException ioex) { +if (s_logger.isTraceEnabled()) { +s_logger.trace("Exception writing http response: " + ioex); +} +} catch (final Exception ex) { +if (!(ex instanceof IllegalStateException)) { +s_logger.error("Unknown exception writing http response", ex); +} +} +} + +public static String findCookie(final Cookie[] cookies, final String key) { +if (cookies == null || key == null || key.isEmpty()) { +return null; +} +for (Cookie cookie: cookies) { +if (cookie != null && cookie.getName().equals(key)) { +return cookie.getValue(); +} +} +return null; +} + +public static boolean validateSessionKey(final HttpSession session, final Map params, final Cookie[] cookies, final String sessionKeyString) { +if (session == null || sessionKeyString == null) { +return false; +} +final String sessionKey = (String) session.getAttribute(sessionKeyString); +final String sessionKeyFromCookie = HttpUtils.findCookie(cookies, sessionKeyString); +String[] sessionKeyFromParams = null; +if (params != null) { +sessionKeyFromParams = (String[]) params.get(sessionKeyString); +} +if ((sessionKey == null) +|| (sessionKeyFromParams == null && sessionKeyFromCookie == null) +|| (sessionKeyFromParams != null && !sessionKey.equals(sessionKeyFromParams[0])) +|| (
[05/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Merge pull request #738 from michaelandersen/vpc_defaultroute_fix CLOUDSTACK-8685: Fix for missing defaultroute on VPC router https://issues.apache.org/jira/browse/CLOUDSTACK-8685 Refactored CsRoute and CsAddress to: - add methods to add and verify the defaultroute - renamed methods flush, add, and routeTable to flush_table, add_route, add_table respectively. Added some suboptimal unit tests to TestCsRoutes * pr/738: Fixed defaultroute on VPC routers in CsRoute and CsAddress Refactored CsRoute pep8 cleanup Signed-off-by: Remi Bergsma Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2772e4da Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2772e4da Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2772e4da Branch: refs/heads/deploy-from-snapshot Commit: 2772e4da82fb36a10d401fa5b072bfefeb5c0913 Parents: c0fde9a a9eb4ba Author: Remi Bergsma Authored: Tue Aug 25 10:37:26 2015 +0200 Committer: Remi Bergsma Committed: Tue Aug 25 10:37:27 2015 +0200 -- .../debian/config/opt/cloud/bin/cs/CsAddress.py | 178 +-- .../config/opt/cloud/bin/cs/CsRedundant.py | 59 +++--- .../debian/config/opt/cloud/bin/cs/CsRoute.py | 64 +-- .../debian/config/opt/cloud/bin/master.py | 2 +- systemvm/test/python/TestCsRoute.py | 17 +- 5 files changed, 229 insertions(+), 91 deletions(-) --
[02/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
fixed hardcoded merge message location This would be empty if run from another directory, resulting in a merge message with only a 'signed-off by' line. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1e6df1b7 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1e6df1b7 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1e6df1b7 Branch: refs/heads/deploy-from-snapshot Commit: 1e6df1b77500dff40c24245227658f7c85c1835c Parents: 9a24109 Author: Remi Bergsma Authored: Mon Aug 24 16:16:16 2015 +0200 Committer: Remi Bergsma Committed: Mon Aug 24 16:16:16 2015 +0200 -- tools/git/git-pr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1e6df1b7/tools/git/git-pr -- diff --git a/tools/git/git-pr b/tools/git/git-pr index 2e0b275..2bd58f6 100755 --- a/tools/git/git-pr +++ b/tools/git/git-pr @@ -217,7 +217,7 @@ echo "INFO: # Do the actual merge git fetch ${github_remote} pull/${prId}/head:pr/${prId} -git merge --no-ff --log -m "$(cat .git-tmp-message.txt)" pr/${prId} +git merge --no-ff --log -m "$(cat ${tmpMessageFile})" pr/${prId} if [ $? -eq 0 ]; then git commit --amend -s --allow-empty-message -m '' else
[01/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
Repository: cloudstack Updated Branches: refs/heads/deploy-from-snapshot 6c3c9ea91 -> 44ba14d17 fix bug where the countdown would be on multiple lines Example of problem: ATTENTION: Merging pull request #731 from remibergsma/centos7-kvm into 'master' branch in 5 seconds. CTRL+c to abort.. -n 5 -n 4 -n 3 -n 2 -n 1 -n 0 Should be compatible with more environments if printf is used instead. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9a24109f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9a24109f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9a24109f Branch: refs/heads/deploy-from-snapshot Commit: 9a24109f9545b024e916b297a403bdd299ecba11 Parents: fed5c2b Author: Remi Bergsma Authored: Mon Aug 24 13:42:48 2015 +0200 Committer: Remi Bergsma Committed: Mon Aug 24 16:00:48 2015 +0200 -- tools/git/git-pr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a24109f/tools/git/git-pr -- diff --git a/tools/git/git-pr b/tools/git/git-pr index 49eee79..2e0b275 100755 --- a/tools/git/git-pr +++ b/tools/git/git-pr @@ -207,10 +207,11 @@ echo "${prTitle}${prBody}" >> ${tmpMessageFile} echo "ATTENTION: Merging pull request #${prId} from ${prOriginBranch} into '${currentBranch}' branch in 5 seconds. CTRL+c to abort.." sec=5 while [ $sec -ge 0 ]; do - echo -n "${sec} " + printf "${sec} " sec=$((sec-1)) sleep 1 done +echo echo "INFO: Executing the merge now.. Git output below:" echo "INFO: ***"
[12/50] [abbrv] git commit: updated refs/heads/deploy-from-snapshot to 44ba14d
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/83fd8f60/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java -- diff --git a/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java b/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java new file mode 100644 index 000..5ff5819 --- /dev/null +++ b/utils/src/main/java/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java @@ -0,0 +1,210 @@ +// +// 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.apache.commons.httpclient.contrib.ssl; + +import org.apache.cloudstack.utils.security.SSLUtils; +import org.apache.commons.httpclient.ConnectTimeoutException; +import org.apache.commons.httpclient.HttpClientError; +import org.apache.commons.httpclient.params.HttpConnectionParams; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.TrustManager; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.UnknownHostException; + +/** + * + * EasySSLProtocolSocketFactory can be used to create SSL {@link Socket}s + * that accept self-signed certificates. + * + * + * This socket factory SHOULD NOT be used for productive systems + * due to security reasons, unless it is a concious decision and + * you are perfectly aware of security implications of accepting + * self-signed certificates + * + * + * + * Example of using custom protocol socket factory for a specific host: + * + * Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443); + * + * URI uri = new URI("https://localhost/";, true); + * // use relative url only + * GetMethod httpget = new GetMethod(uri.getPathQuery()); + * HostConfiguration hc = new HostConfiguration(); + * hc.setHost(uri.getHost(), uri.getPort(), easyhttps); + * HttpClient client = new HttpClient(); + * client.executeMethod(hc, httpget); + * + * + * + * Example of using custom protocol socket factory per default instead of the standard one: + * + * Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443); + * Protocol.registerProtocol("https", easyhttps); + * + * HttpClient client = new HttpClient(); + * GetMethod httpget = new GetMethod("https://localhost/";); + * client.executeMethod(httpget); + * + * + * + * @author mailto:oleg -at- ural.ru">Oleg Kalnichevski + * + * + * DISCLAIMER: HttpClient developers DO NOT actively support this component. + * The component is provided as a reference material, which may be inappropriate + * for use without additional customization. + * + */ + +public class EasySSLProtocolSocketFactory implements ProtocolSocketFactory { + +/** Log object for this class. */ +private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class); + +private SSLContext sslcontext = null; + +/** + * Constructor for EasySSLProtocolSocketFactory. + */ +public EasySSLProtocolSocketFactory() { +super(); +} + +private static SSLContext createEasySSLContext() { +try { +SSLContext context = SSLUtils.getSSLContext(); +context.init(null, new TrustManager[] {new EasyX509TrustManager(null)}, null); +return context; +} catch (Exception e) { +LOG.error(e.getMessage(), e); +throw new HttpClientError(e.toString()); +} +} + +private SSLContext getSSLContext() { +if (sslcontext == null) { +sslcontext = createEasySSLContext(); +} +return sslcontext; +} + +/** + * @see ProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) + */ +@Override +public Socke