Migrating Kubernetes API client to Fabric8
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3414e7ce Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3414e7ce Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3414e7ce Branch: refs/heads/master Commit: 3414e7cee8d907e6f8fc66d9118402574a691f89 Parents: 7db006b Author: Imesh Gunaratne <[email protected]> Authored: Mon Jun 15 18:11:09 2015 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Mon Jun 15 18:12:59 2015 +0530 ---------------------------------------------------------------------- .../org.apache.stratos.activation/pom.xml | 96 - .../internal/ActivationServiceComponent.java | 152 - .../activation/module/ActivationHandler.java | 161 - .../activation/module/ActivationModule.java | 65 - .../activation/service/ActivationService.java | 85 - .../activation/utils/ActivationManager.java | 96 - .../apache/stratos/activation/utils/Util.java | 138 - .../src/main/resources/META-INF/module.xml | 34 - .../src/main/resources/META-INF/services.xml | 30 - .../org.apache.stratos.cloud.controller/pom.xml | 7 + .../iaases/kubernetes/KubernetesIaas.java | 33 +- .../iaases/kubernetes/KubernetesIaasUtil.java | 30 +- components/org.apache.stratos.common/pom.xml | 1 + .../pom.xml | 28 +- .../kubernetes/client/KubernetesApiClient.java | 676 +-- .../kubernetes/client/KubernetesConstants.java | 11 +- .../KubernetesAPIClientInterface.java | 75 +- .../kubernetes/client/model/Container.java | 143 - .../client/model/EnvironmentVariable.java | 48 - .../stratos/kubernetes/client/model/Labels.java | 46 - .../kubernetes/client/model/Manifest.java | 80 - .../stratos/kubernetes/client/model/Pod.java | 175 - .../kubernetes/client/model/PodList.java | 65 - .../stratos/kubernetes/client/model/Policy.java | 39 - .../stratos/kubernetes/client/model/Port.java | 70 - .../client/model/ReplicationController.java | 114 - .../client/model/ReplicationControllerList.java | 65 - .../kubernetes/client/model/Selector.java | 43 - .../kubernetes/client/model/Service.java | 160 - .../kubernetes/client/model/ServiceList.java | 65 - .../stratos/kubernetes/client/model/State.java | 124 - .../stratos/kubernetes/client/model/Volume.java | 41 - .../kubernetes/client/model/VolumeMount.java | 60 - .../kubernetes/client/rest/HttpResponse.java | 68 - .../client/rest/KubernetesResponse.java | 89 - .../client/rest/KubernetesResponseHandler.java | 99 - .../kubernetes/client/rest/RestClient.java | 118 - .../client/live/AbstractLiveTest.java | 58 +- .../live/KubernetesApiClientLiveTest.java | 20 +- .../client/live/KubernetesClusterCleanTest.java | 12 +- .../kubernetes/client/unit/PodUnitTest.java | 106 - components/org.apache.stratos.messaging/pom.xml | 8 +- components/pom.xml | 1 - dependencies/fabric8/kubernetes-api/README.md | 7 + dependencies/fabric8/kubernetes-api/pom.xml | 214 + .../fabric8/kubernetes/api/AbstractWatcher.java | 61 + .../io/fabric8/kubernetes/api/Controller.java | 850 ++++ .../java/io/fabric8/kubernetes/api/Entity.java | 28 + .../kubernetes/api/ExceptionResponseMapper.java | 69 + .../io/fabric8/kubernetes/api/Kubernetes.java | 283 ++ .../kubernetes/api/KubernetesApiException.java | 11 + .../kubernetes/api/KubernetesClient.java | 1618 ++++++ .../kubernetes/api/KubernetesExtensions.java | 226 + .../kubernetes/api/KubernetesFactory.java | 384 ++ .../api/KubernetesGlobalExtensions.java | 56 + .../kubernetes/api/KubernetesHelper.java | 1724 +++++++ .../fabric8/kubernetes/api/PodStatusType.java | 25 + .../io/fabric8/kubernetes/api/ServiceNames.java | 58 + .../api/UserConfigurationCompare.java | 201 + .../java/io/fabric8/kubernetes/api/Watcher.java | 13 + .../api/builders/ListEnvVarBuilder.java | 43 + .../api/builds/BuildFinishedEvent.java | 64 + .../kubernetes/api/builds/BuildListener.java | 30 + .../kubernetes/api/builds/BuildWatcher.java | 121 + .../fabric8/kubernetes/api/builds/Builds.java | 199 + .../io/fabric8/kubernetes/api/builds/Links.java | 35 + .../kubernetes/api/extensions/Configs.java | 117 + .../kubernetes/api/extensions/Templates.java | 225 + .../api/support/KindToClassMapping.java | 264 + .../src/main/kubernetes/api/Dockerfile | 5 + .../api/examples/controller-list.json | 35 + .../kubernetes/api/examples/controller.json | 24 + .../api/examples/external-service.json | 13 + .../src/main/kubernetes/api/examples/list.json | 98 + .../api/examples/pod-list-empty-results.json | 19 + .../main/kubernetes/api/examples/pod-list.json | 93 + .../src/main/kubernetes/api/examples/pod.json | 34 + .../kubernetes/api/examples/service-list.json | 28 + .../main/kubernetes/api/examples/service.json | 33 + .../main/kubernetes/api/examples/template.json | 146 + .../src/main/kubernetes/api/kubernetes.html | 1636 ++++++ .../src/main/kubernetes/api/kubernetes.raml | 185 + .../src/main/resources/log4j.properties | 8 + .../java/io/fabric8/kubernetes/api/Apply.java | 48 + .../kubernetes/api/ConfigComparePodTest.java | 243 + .../ConfigCompareReplicationControllerTest.java | 530 ++ .../api/ConfigCompareServiceTest.java | 235 + .../kubernetes/api/ConfigFileParseTest.java | 58 + .../java/io/fabric8/kubernetes/api/Example.java | 134 + .../api/FindOpenShiftNamespaceTest.java | 41 + .../kubernetes/api/KubernetesHelperTest.java | 71 + .../kubernetes/api/ParseDateTimeTest.java | 36 + .../kubernetes/api/ParseExamplesTest.java | 128 + .../kubernetes/api/ParseServiceTest.java | 65 + .../io/fabric8/kubernetes/api/ParseTest.java | 157 + .../PodIdToReplicationControllerIDExample.java | 42 + .../api/ProcessTemplateLocallyTest.java | 54 + .../fabric8/kubernetes/api/TemplatesTest.java | 50 + .../io/fabric8/kubernetes/api/TriggerBuild.java | 45 + .../kubernetes/api/UsingBadAddressTest.java | 47 + .../fabric8/kubernetes/api/ViewEndpoints.java | 88 + .../io/fabric8/kubernetes/api/ViewNodes.java | 61 + .../fabric8/kubernetes/api/ViewServiceIPs.java | 45 + .../io/fabric8/kubernetes/api/WatchBuilds.java | 52 + .../kubernetes/api/WatchBuildsExample.java | 23 + .../kubernetes/api/WatchPodsExample.java | 23 + .../kubernetes/api/WatchServicesExample.java | 23 + .../src/test/resources/config.yml | 52 + .../src/test/resources/errorexample.json | 77 + .../src/test/resources/fmq-service.json | 20 + .../src/test/resources/glance-api-service.yaml | 7 + .../src/test/resources/log4j.properties | 25 + dependencies/fabric8/kubernetes-model/README.md | 7 + dependencies/fabric8/kubernetes-model/pom.xml | 176 + .../io/fabric8/config/KubernetesBaseConfig.java | 14 + .../io/fabric8/config/KubernetesConfig.java | 81 + .../java/io/fabric8/config/OpenshiftConfig.java | 67 + .../kubernetes/api/model/HasMetadata.java | 7 + .../kubernetes/api/model/KubernetesKind.java | 71 + .../kubernetes/api/model/KubernetesList.java | 49 + .../api/model/KubernetesResource.java | 8 + .../kubernetes/api/model/resource/Quantity.java | 135 + .../kubernetes/api/model/util/IntOrString.java | 195 + .../internal/HasMetadataComparator.java | 30 + .../kubernetes/internal/HasMetadataSet.java | 25 + .../internal/KubernetesDeserializer.java | 33 + .../openshift/api/model/template/Template.java | 306 ++ .../src/main/resources/log4j.properties | 8 + .../src/main/resources/schema/kube-schema.json | 4692 ++++++++++++++++++ .../kubernetes/api/model/InlineTest.java | 18 + .../api/model/KubernetesListTest.java | 85 + .../kubernetes/api/model/UnmarshallTest.java | 66 + .../src/test/resources/service-list.json | 239 + .../src/test/resources/simple-list.json | 64 + .../src/test/resources/simple-template.json | 45 + .../src/test/resources/valid-pod.json | 22 + dependencies/fabric8/pom.xml | 55 + dependencies/pom.xml | 3 +- .../pom.xml | 14 +- .../pom.xml | 6 - features/manager/pom.xml | 5 - .../distribution/src/main/license/LICENSE | 1 - 142 files changed, 18497 insertions(+), 3428 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/pom.xml b/components/org.apache.stratos.activation/pom.xml deleted file mode 100644 index 1c422d5..0000000 --- a/components/org.apache.stratos.activation/pom.xml +++ /dev/null @@ -1,96 +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. - --> -<project xmlns="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"> - - <parent> - <groupId>org.apache.stratos</groupId> - <artifactId>stratos-components-parent</artifactId> - <version>4.1.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.activation</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Activation</name> - - <build> - - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-scr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Axis2Module>${project.artifactId}-${project.version}</Axis2Module> - <Bundle-Name>${project.artifactId}</Bundle-Name> - <Export-Package> - org.apache.stratos.activation.*, - </Export-Package> - <Import-Package> - org.apache.stratos.common.*, - org.wso2.carbon.registry.core.*;version=1.0.1, - org.wso2.carbon.registry.resource.*, - !javax.xml.namespace, - javax.xml.namespace; version=0.0.0, - javax.servlet;version="${imp.pkg.version.javax.servlet}", - javax.servlet.http;version="${imp.pkg.version.javax.servlet}", - org.apache.axiom.*; version="${axiom.osgi.version.range}", - *;resolution:=optional - </Import-Package> - <DynamicImport-Package>*</DynamicImport-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.utils</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.apache.axis2.wso2</groupId> - <artifactId>axis2</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/internal/ActivationServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/internal/ActivationServiceComponent.java b/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/internal/ActivationServiceComponent.java deleted file mode 100644 index 69c5210..0000000 --- a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/internal/ActivationServiceComponent.java +++ /dev/null @@ -1,152 +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 org.apache.stratos.activation.internal; - -import org.apache.axis2.AxisFault; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.utils.ConfigurationContextService; -import org.apache.stratos.activation.service.ActivationService; -import org.apache.stratos.activation.utils.ActivationManager; -import org.apache.stratos.activation.utils.Util; - -/** - * The Declarative Service Component for the Service Activation Module for Tenants. - * - * @scr.component name="org.wso2.carbon.metering" immediate="true" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" - * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" - * @scr.reference name="user.realmservice.default" - * interface="org.wso2.carbon.user.core.service.RealmService" - * cardinality="1..1" policy="dynamic" bind="setRealmService" unbind="unsetRealmService" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" policy="dynamic" bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ -@SuppressWarnings({"JavaDoc", "unused"}) -public class ActivationServiceComponent { - - private static final Log log = LogFactory.getLog(ActivationServiceComponent.class); - - private static ServiceRegistration registration = null; - - /** - * Activates the Registry Kernel bundle. - * - * @param context the OSGi component context. - */ - protected void activate(ComponentContext context) { - try { - ActivationManager.startCacheCleaner(); - if (registration == null) { - registration = context.getBundleContext().registerService( - ActivationService.class.getName(), new ActivationService(), null); - } - log.debug("******* Stratos Activation bundle is activated ******* "); - } catch (Exception e) { - log.error("******* Stratos Activation bundle failed activating ****", e); - } - } - - /** - * Deactivates the Registry Kernel bundle. - * - * @param context the OSGi component context. - */ - protected void deactivate(ComponentContext context) { - registration.unregister(); - registration = null; - ActivationManager.stopCacheCleaner(); - log.debug("******* Stratos Activation bundle is deactivated ******* "); - } - - /** - * Method to set the registry service used. This will be used when accessing the registry. This - * method is called when the OSGi Registry Service is available. - * - * @param registryService the registry service. - */ - protected void setRegistryService(RegistryService registryService) { - Util.setRegistryService(registryService); - } - - /** - * This method is called when the current registry service becomes un-available. - * - * @param registryService the current registry service instance, to be used for any - * cleaning-up. - */ - protected void unsetRegistryService(RegistryService registryService) { - Util.setRegistryService(null); - } - - /** - * Method to set the realm service used. This will be used when accessing the user realm. This - * method is called when the OSGi Realm Service is available. - * - * @param realmService the realm service. - */ - protected void setRealmService(RealmService realmService) { - Util.setRealmService(realmService); - } - - /** - * This method is called when the current realm service becomes un-available. - * - * @param realmService the current realm service instance, to be used for any cleaning-up. - */ - protected void unsetRealmService(RealmService realmService) { - Util.setRealmService(null); - } - - /** - * Method to set the configuration context service used. This method is called when the OSGi - * ConfigurationContext Service is available. - * - * @param contextService the configuration context service. - */ - protected void setConfigurationContextService(ConfigurationContextService contextService) { - try { - if (contextService.getServerConfigContext() != null && - contextService.getServerConfigContext().getAxisConfiguration() != null) { - contextService.getServerConfigContext().getAxisConfiguration().engageModule( - "activation"); - } else { - log.error("Failed to engage Activation Module."); - } - } catch (AxisFault e) { - log.error("Failed to engage Activation Module", e); - } - } - - /** - * This method is called when the current configuration context service becomes un-available. - * - * @param contextService the current configuration context service instance, to be used for any - * cleaning-up. - */ - protected void unsetConfigurationContextService(ConfigurationContextService contextService) { - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationHandler.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationHandler.java b/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationHandler.java deleted file mode 100644 index f355af1..0000000 --- a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationHandler.java +++ /dev/null @@ -1,161 +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 org.apache.stratos.activation.module; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMElement; -import org.apache.axiom.soap.SOAPBody; -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.MessageContext; -import org.apache.axis2.description.AxisService; -import org.apache.axis2.engine.Handler; -import org.apache.axis2.handlers.AbstractHandler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.activation.utils.ActivationManager; -import org.apache.stratos.activation.utils.Util; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils; -import org.apache.stratos.common.util.CloudServicesUtil; -import org.wso2.carbon.utils.ServerConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantUtils; - -public class ActivationHandler extends AbstractHandler implements Handler { - - private static final Log log = LogFactory.getLog(ActivationHandler.class); - - private String name = "ActivationHandler"; - - /** - * {@inheritDoc} - */ - public InvocationResponse invoke(MessageContext messageContext) throws AxisFault { - String serviceName = Util.getServiceName(); - //TODO - tenant id and domain should retrieve from thread local carbon context - //If service is api manager then we will pass activation handler check - if(serviceName.equalsIgnoreCase("WSO2 API Manager")) { - return InvocationResponse.CONTINUE; - } - if(log.isDebugEnabled()){ - log.debug("Starting Activation Handler invocation. Incoming Message: " + - messageContext.getEnvelope().toString()); - } - - AxisService service = messageContext.getAxisService(); - int tenantId = getTenantId(messageContext); - if (service != null && "ActivationService".equals(service.getName())) { - log.debug("Granted access to the Activation Service"); - if (tenantId > 0) { - TenantAxisUtils.getTenantAxisConfiguration(getTenantDomain(messageContext), - messageContext.getConfigurationContext()); - log.debug("Loaded Tenant Configuration"); - } - return InvocationResponse.CONTINUE; - } - if (tenantId == MultitenantConstants.SUPER_TENANT_ID) { - log.debug("Granted access for super tenant"); - return InvocationResponse.CONTINUE; - } - if (ActivationManager.activationRecorded(tenantId)) { - if (ActivationManager.getActivation(tenantId)) { - TenantAxisUtils.getTenantAxisConfiguration(getTenantDomain(messageContext), - messageContext.getConfigurationContext()); - log.debug("Loaded Tenant Configuration"); - return InvocationResponse.CONTINUE; - } else { - if (log.isWarnEnabled()) { - log.warn("Failed attempt to access " + serviceName + " by tenant " + tenantId); - } - return InvocationResponse.ABORT; - } - } - - try { - if (CloudServicesUtil.isCloudServiceActive(serviceName, tenantId)) { - log.debug("Successful attempt to access " + serviceName + " by tenant " + tenantId); - ActivationManager.setActivation(tenantId, true); - TenantAxisUtils.getTenantAxisConfiguration(getTenantDomain(messageContext), - messageContext.getConfigurationContext()); - log.debug("Loaded Tenant Configuration"); - return InvocationResponse.CONTINUE; - } - } catch (Exception e) { - throw new AxisFault("Failed to determine Activation status.", e); - } - log.warn("Failed attempt to access " + serviceName + " by tenant " + tenantId); - ActivationManager.setActivation(tenantId, false); - return InvocationResponse.ABORT; - } - - /** - * {@inheritDoc} - */ - public String getName() { - return name; - } - - /** - * Method to set the name of the activation handler. - * - * @param name the name. - */ - @SuppressWarnings("unused") - public void setName(String name) { - this.name = name; - } - - private String getTenantDomain(MessageContext messageContext) { - //Ideally this should take from thread local carbon context change this temporary - return PrivilegedCarbonContext.getCurrentContext(messageContext).getTenantDomain(); - } - - private int getTenantId(MessageContext messageContext) { - //Ideally this should take from thread local carbon context change this temporary - PrivilegedCarbonContext carbonContext = - PrivilegedCarbonContext.getCurrentContext(messageContext); - int tenantId = carbonContext.getTenantId(); - if (tenantId > -1 || tenantId == MultitenantConstants.SUPER_TENANT_ID) { - return tenantId; - } - String domain = carbonContext.getTenantDomain(); - if (domain == null) { - SOAPBody soapBody = messageContext.getEnvelope().getBody(); - if (soapBody != null && soapBody.getFirstElement() != null) { - OMElement usernameElem = soapBody.getFirstElement().getFirstChildWithName( - new QName(ServerConstants.AUTHENTICATION_SERVICE_NS, - ServerConstants.AUTHENTICATION_SERVICE_USERNAME)); - if (usernameElem != null) { - String userName = usernameElem.getText(); - domain = MultitenantUtils.getTenantDomain(userName); - } - } - } - if (domain != null) { - try { - tenantId = Util.getRealmService().getTenantManager().getTenantId(domain); - } catch (org.wso2.carbon.user.api.UserStoreException e) { - log.error("An error occurred while obtaining the tenant id.", e); - } - } - return tenantId; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationModule.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationModule.java b/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationModule.java deleted file mode 100644 index a5eae10..0000000 --- a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/module/ActivationModule.java +++ /dev/null @@ -1,65 +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 org.apache.stratos.activation.module; - -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.description.AxisDescription; -import org.apache.axis2.description.AxisModule; -import org.apache.axis2.modules.Module; -import org.apache.neethi.Assertion; -import org.apache.neethi.Policy; - -/** - * Module used to engage the activation handler. - */ -public class ActivationModule implements Module { - - /** - * {@inheritDoc} - */ - public void init(ConfigurationContext configurationContext, AxisModule axisModule) - throws AxisFault { - } - - /** - * {@inheritDoc} - */ - public void engageNotify(AxisDescription axisDescription) throws AxisFault { - } - - /** - * {@inheritDoc} - */ - public boolean canSupportAssertion(Assertion assertion) { - return true; - } - - /** - * {@inheritDoc} - */ - public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault { - } - - /** - * {@inheritDoc} - */ - public void shutdown(ConfigurationContext configurationContext) throws AxisFault { - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/service/ActivationService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/service/ActivationService.java b/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/service/ActivationService.java deleted file mode 100644 index 4ad5455..0000000 --- a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/service/ActivationService.java +++ /dev/null @@ -1,85 +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 org.apache.stratos.activation.service; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.activation.utils.ActivationManager; -import org.apache.stratos.activation.utils.Util; -import org.apache.stratos.common.config.CloudServiceConfigParser; -import org.apache.stratos.common.config.CloudServicesDescConfig; -import org.apache.stratos.common.util.CloudServicesUtil; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -/** - * Admin Service to handle activation of cloud services used by tenants. - */ -public class ActivationService { - - private static final Log log = LogFactory.getLog(ActivationService.class); - - /** - * Method to update an activation record. - * - * @param tenantId the tenant identifier. - * - * @throws Exception if the operation failed. - */ - public static void updateActivation(int tenantId) throws Exception { - if (tenantId != 0) { - String serviceName = Util.getServiceName(); - boolean isActive = CloudServicesUtil.isCloudServiceActive(serviceName, tenantId); - CloudServicesDescConfig cloudServicesDesc = - CloudServiceConfigParser.loadCloudServicesConfiguration(); - CloudServicesUtil.setCloudServiceActive(!isActive, - serviceName, - tenantId, - cloudServicesDesc.getCloudServiceConfigs() - .get(serviceName)); - ActivationManager.setActivation(tenantId, !isActive); - } - } - - /** - * Method to determine whether a service is active for the given tenant. - * - * @param tenantId tenantId the tenant identifier. - * - * @return whether the service is active. - * @throws Exception if the operation failed. - */ - public boolean isActive(int tenantId) throws Exception { - if (tenantId == MultitenantConstants.SUPER_TENANT_ID) { - return true; - } - if (ActivationManager.activationRecorded(tenantId)) { - return ActivationManager.getActivation(tenantId); - } - String serviceName = Util.getServiceName(); - if (CloudServicesUtil.isCloudServiceActive(serviceName, tenantId)) { - log.debug("Successful attempt to access " + serviceName + " by tenant " + tenantId); - ActivationManager.setActivation(tenantId, true); - return true; - } - log.warn("Failed attempt to access " + serviceName + " by tenant " + tenantId); - ActivationManager.setActivation(tenantId, false); - return false; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/ActivationManager.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/ActivationManager.java b/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/ActivationManager.java deleted file mode 100644 index 11f00e1..0000000 --- a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/ActivationManager.java +++ /dev/null @@ -1,96 +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 org.apache.stratos.activation.utils; - -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Manages Activations of Services for Tenants. - */ -public class ActivationManager { - - private static final ConcurrentHashMap<Integer, Boolean> activations = - new ConcurrentHashMap<Integer, Boolean>(); - private static Timer timer = null; - - /** - * Starts cleaning up cached activation records at periodic intervals. - */ - public static void startCacheCleaner() { - TimerTask faultyServiceRectifier = new CacheCleaner(); - timer = new Timer(); - // Retry in 1 minute - long retryIn = 1000 * 60; - timer.schedule(faultyServiceRectifier, 0, retryIn); - } - - /** - * Stops cleaning up cached activation records. - */ - public static void stopCacheCleaner() { - timer.cancel(); - timer = null; - } - - /** - * Method to set an activation record. - * - * @param tenantId the tenant identifier. - * @param status true if the service is active or false if not. - */ - public static void setActivation(int tenantId, boolean status) { - ActivationManager.activations.put(tenantId, status); - } - - /** - * Method to check whether an activation record exists for the given tenant. - * - * @param tenantId the tenant identifier. - * - * @return true if a record exists. - */ - public static boolean activationRecorded(int tenantId) { - return ActivationManager.activations.get(tenantId) != null; - } - - /** - * Method to retrieve an activation record. - * - * @param tenantId the tenant identifier. - * - * @return true if the service is active or false if not. - */ - public static boolean getActivation(int tenantId) { - return ActivationManager.activations.get(tenantId) != null && - ActivationManager.activations.get(tenantId); - } - - private static class CacheCleaner extends TimerTask { - - /** - * {@inheritDoc} - */ - public void run() { - ActivationManager.activations.clear(); - } - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/Util.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/Util.java b/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/Util.java deleted file mode 100644 index c6dedfa..0000000 --- a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/utils/Util.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 org.apache.stratos.activation.utils; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.base.ServerConfiguration; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.wso2.carbon.user.core.service.RealmService; - -/** - * Utilities for the Service Activation Module for Tenants. - */ -public class Util { - - private static RegistryService registryService = null; - private static RealmService realmService = null; - private static String serviceName = null; - private static final Log log = LogFactory.getLog(Util.class); - - private static boolean cloudServiceInfoPathSanityChecked = false; - - /** - * Stores an instance of the Registry Service that can be used to access the registry. - * - * @param service the Registry Service instance. - */ - public static synchronized void setRegistryService(RegistryService service) { - if (registryService == null) { - registryService = service; - } - } - - /** - * Method to retrieve the Registry Service instance. - * - * @return the Registry Service instance if it has been stored or null if not. - */ - @SuppressWarnings("unused") - public static RegistryService getRegistryService() { - return registryService; - } - - /** - * Stores an instance of the Realm Service that can be used to access the user realm. - * - * @param service the Realm Service instance. - */ - public static synchronized void setRealmService(RealmService service) { - if (realmService == null) { - realmService = service; - } - } - - /** - * Method to retrieve the Realm Service instance. - * - * @return the Realm Service instance if it has been stored or null if not. - */ - public static RealmService getRealmService() { - return realmService; - } - - private static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException { - return registryService.getGovernanceSystemRegistry(); - } - -// /** -// * Method to determine whether the given cloud service is active. -// * -// * @param cloudServiceName the name of the cloud service. -// * @param tenantId the tenant identifier. -// * @param systemRegistry the super tenant's governance system registry -// * -// * @return true if the service is active or false if not. -// * @throws Exception if the operation failed. -// */ -// public static boolean isCloudServiceActive(String cloudServiceName, -// int tenantId, UserRegistry systemRegistry) -// throws Exception { -// // The cloud manager is always active -// if (StratosConstants.CLOUD_MANAGER_SERVICE.equals(cloudServiceName)) { -// return true; -// } -// -// if(!cloudServiceInfoPathSanityChecked) { -// if(!systemRegistry.resourceExists(StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH)) { -// throw new RuntimeException("Cloud services list resource " + -// StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH + " does not exist"); -// } -// cloudServiceInfoPathSanityChecked = true; -// } -// -// String cloudServiceInfoPath = StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH + -// RegistryConstants.PATH_SEPARATOR + tenantId + -// RegistryConstants.PATH_SEPARATOR + cloudServiceName; -// Resource cloudServiceInfoResource; -// if (systemRegistry.resourceExists(cloudServiceInfoPath)) { -// cloudServiceInfoResource = systemRegistry.get(cloudServiceInfoPath); -// String isActiveStr = -// cloudServiceInfoResource.getProperty(StratosConstants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY); -// return Boolean.toString(true).equals(isActiveStr); -// } -// return false; -// } -// - - /** - * Method to obtain the name of the cloud service in which this module is running. - * - * @return the name of the service as defined in the server configuration. - */ - public static String getServiceName() { - if (serviceName == null) { - serviceName = ServerConfiguration.getInstance().getFirstProperty("Name"); - } - return serviceName; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/resources/META-INF/module.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/resources/META-INF/module.xml b/components/org.apache.stratos.activation/src/main/resources/META-INF/module.xml deleted file mode 100644 index 1558e64..0000000 --- a/components/org.apache.stratos.activation/src/main/resources/META-INF/module.xml +++ /dev/null @@ -1,34 +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. - --> -<module name="activation" class="org.apache.stratos.activation.module.ActivationModule"> - <InFlow> - <handler name="InFlowActivationHandler" - class="org.apache.stratos.activation.module.ActivationHandler"> - <order phase="Validation" phaseFirst="true"/> - </handler> - </InFlow> - - <InFaultFlow> - <handler name="FaultInFlowActivationHandler" - class="org.apache.stratos.activation.module.ActivationHandler"> - <order phase="Validation" phaseFirst="true"/> - </handler> - </InFaultFlow> - <parameter name="adminModule" locked="true">true</parameter> -</module> http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.activation/src/main/resources/META-INF/services.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.activation/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.activation/src/main/resources/META-INF/services.xml deleted file mode 100644 index 0ac1d65..0000000 --- a/components/org.apache.stratos.activation/src/main/resources/META-INF/services.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - # 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. - --> -<serviceGroup> - <service name="ActivationService" scope="transportsession"> - <transports> - <transport>https</transport> - </transports> - <parameter name="ServiceClass" locked="false"> - org.apache.stratos.activation.service.ActivationService - </parameter> - </service> - <parameter name="hiddenService" locked="true">true</parameter> -</serviceGroup> http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.cloud.controller/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml index 06cb256..1e5ff3f 100644 --- a/components/org.apache.stratos.cloud.controller/pom.xml +++ b/components/org.apache.stratos.cloud.controller/pom.xml @@ -60,6 +60,8 @@ org.apache.commons.logging; version=0.0.0, org.apache.commons.io.*, org.wso2.carbon.utils.*, + org.apache.stratos.kubernetes.client, + org.apache.stratos.kubernetes.client.exceptions, <!--org.jclouds.compute*;version="${jclouds.version}";resolution:=optional, org.jclouds*;version="${jclouds.version}",--> *; resolution:=optional @@ -312,6 +314,11 @@ <artifactId>org.apache.stratos.mock.iaas.client</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>kubernetes-api</artifactId> + <version>2.1.11-stratosv1</version> + </dependency> </dependencies> <properties> <gson2.version>2.2</gson2.version> http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java index 71c38a3..423eb23 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java @@ -19,6 +19,10 @@ package org.apache.stratos.cloud.controller.iaases.kubernetes; +import io.fabric8.kubernetes.api.model.ContainerPort; +import io.fabric8.kubernetes.api.model.EnvVar; +import io.fabric8.kubernetes.api.model.Pod; +import io.fabric8.kubernetes.api.model.Service; import org.apache.commons.lang.NotImplementedException; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -39,10 +43,6 @@ import org.apache.stratos.common.domain.NameValuePair; import org.apache.stratos.kubernetes.client.KubernetesApiClient; import org.apache.stratos.kubernetes.client.KubernetesConstants; import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException; -import org.apache.stratos.kubernetes.client.model.EnvironmentVariable; -import org.apache.stratos.kubernetes.client.model.Pod; -import org.apache.stratos.kubernetes.client.model.Port; -import org.apache.stratos.kubernetes.client.model.Service; import org.apache.stratos.messaging.domain.topology.KubernetesService; import java.util.ArrayList; @@ -250,8 +250,8 @@ public class KubernetesIaas extends Iaas { private void updateMemberContext(MemberContext memberContext, Pod pod, KubernetesCluster kubernetesCluster) { - String memberPrivateIPAddress = pod.getCurrentState().getPodIP(); - String podHostIPAddress = pod.getCurrentState().getHost(); + String memberPrivateIPAddress = pod.getStatus().getPodIP(); + String podHostIPAddress = pod.getStatus().getHostIP(); String memberPublicIPAddress = podHostIPAddress; String kubernetesHostPublicIP = findKubernetesHostPublicIPAddress(kubernetesCluster, podHostIPAddress); @@ -263,7 +263,7 @@ public class KubernetesIaas extends Iaas { } } - memberContext.setInstanceId(pod.getId()); + memberContext.setInstanceId(pod.getMetadata().getName()); memberContext.setDefaultPrivateIP(memberPrivateIPAddress); memberContext.setPrivateIPs(new String[]{memberPrivateIPAddress}); memberContext.setDefaultPublicIP(memberPublicIPAddress); @@ -297,15 +297,15 @@ public class KubernetesIaas extends Iaas { pod = kubernetesApi.getPod(memberContext.getKubernetesPodId()); if (pod != null) { podCreated = true; - if (pod.getCurrentState().getStatus().equals(KubernetesConstants.POD_STATUS_RUNNING)) { + if (pod.getStatus().getPhase().equals(KubernetesConstants.POD_STATUS_RUNNING)) { log.info(String.format("Pod status changed to running: [application] %s [cartridge] %s [member] %s " + "[pod] %s", memberContext.getApplicationId(), memberContext.getCartridgeType(), - memberContext.getMemberId(), pod.getId())); + memberContext.getMemberId(), pod.getMetadata().getName())); return pod; } else { log.info(String.format("Waiting pod status to be changed to running: [application] %s " + "[cartridge] %s [member] %s [pod] %s", memberContext.getApplicationId(), - memberContext.getCartridgeType(), memberContext.getMemberId(), pod.getId())); + memberContext.getCartridgeType(), memberContext.getMemberId(), pod.getMetadata().getName())); } } else { log.info(String.format("Waiting for pod to be created: [application] %s " + @@ -407,10 +407,10 @@ public class KubernetesIaas extends Iaas { String podId = "pod" + "-" + podSeqNo; String podLabel = KubernetesIaasUtil.fixSpecialCharacters(clusterId); String dockerImage = iaasProvider.getImage(); - EnvironmentVariable[] environmentVariables = KubernetesIaasUtil.prepareEnvironmentVariables( + List<EnvVar> environmentVariables = KubernetesIaasUtil.prepareEnvironmentVariables( clusterContext, memberContext); - List<Port> ports = KubernetesIaasUtil.convertPortMappings(Arrays.asList(cartridge.getPortMappings())); + List<ContainerPort> ports = KubernetesIaasUtil.convertPortMappings(Arrays.asList(cartridge.getPortMappings())); log.info(String.format("Starting pod: [application] %s [cartridge] %s [member] %s " + "[cpu] %d [memory] %d MB", @@ -521,9 +521,8 @@ public class KubernetesIaas extends Iaas { try { // Services need to use minions private IP addresses for creating iptable rules - String[] minionPrivateIPArray = minionPrivateIPList.toArray(new String[minionPrivateIPList.size()]); kubernetesApi.createService(serviceId, serviceLabel, servicePort, containerPortName, - minionPrivateIPArray, sessionAffinity); + containerPort, minionPrivateIPList, sessionAffinity); } finally { // Persist kubernetes service sequence no CloudControllerContext.getInstance().persist(); @@ -537,13 +536,13 @@ public class KubernetesIaas extends Iaas { Service service = kubernetesApi.getService(serviceId); KubernetesService kubernetesService = new KubernetesService(); - kubernetesService.setId(service.getId()); - kubernetesService.setPortalIP(service.getPortalIP()); + kubernetesService.setId(service.getMetadata().getName()); + kubernetesService.setPortalIP(service.getSpec().getPortalIP()); // Expose minions public IP addresses as they need to be accessed by external networks String[] minionPublicIPArray = minionPublicIPList.toArray(new String[minionPublicIPList.size()]); kubernetesService.setPublicIPs(minionPublicIPArray); kubernetesService.setProtocol(portMapping.getProtocol()); - kubernetesService.setPort(service.getPort()); + kubernetesService.setPort(service.getSpec().getPorts().get(0).getPort()); kubernetesService.setContainerPort(containerPort); kubernetesServices.add(kubernetesService); http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java index f4116cc..cbf28ae 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java @@ -19,6 +19,8 @@ package org.apache.stratos.cloud.controller.iaases.kubernetes; +import io.fabric8.kubernetes.api.model.ContainerPort; +import io.fabric8.kubernetes.api.model.EnvVar; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.domain.ClusterContext; @@ -28,8 +30,6 @@ import org.apache.stratos.common.Properties; import org.apache.stratos.common.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.common.domain.NameValuePair; -import org.apache.stratos.kubernetes.client.model.EnvironmentVariable; -import org.apache.stratos.kubernetes.client.model.Port; import java.util.ArrayList; import java.util.List; @@ -58,11 +58,10 @@ public class KubernetesIaasUtil { * @param memberContext * @return */ - public static EnvironmentVariable[] prepareEnvironmentVariables(ClusterContext clusterContext, - MemberContext memberContext) { + public static List<EnvVar> prepareEnvironmentVariables(ClusterContext clusterContext, MemberContext memberContext) { String kubernetesClusterId = clusterContext.getKubernetesClusterId(); - List<EnvironmentVariable> environmentVariables = new ArrayList<EnvironmentVariable>(); + List<EnvVar> environmentVariables = new ArrayList<EnvVar>(); // Set dynamic payload NameValuePair[] payload = memberContext.getDynamicPayload(); @@ -90,8 +89,7 @@ public class KubernetesIaasUtil { memberContext.getClusterId(), memberContext.getMemberId(), environmentVariables.toString())); } - EnvironmentVariable[] array = new EnvironmentVariable[environmentVariables.size()]; - return environmentVariables.toArray(array); + return environmentVariables; } /** @@ -101,26 +99,26 @@ public class KubernetesIaasUtil { * @param name * @param value */ - private static void addToEnvironmentVariables(List<EnvironmentVariable> environmentVariables, String name, String value) { - EnvironmentVariable environmentVariable = new EnvironmentVariable(); + private static void addToEnvironmentVariables(List<EnvVar> environmentVariables, String name, String value) { + EnvVar environmentVariable = new EnvVar(); environmentVariable.setName(name); environmentVariable.setValue(value); environmentVariables.add(environmentVariable); } /** - * Convert stratos port mappings to kubernetes ports + * Convert stratos port mappings to kubernetes container ports * * @param portMappings * @return */ - public static List<Port> convertPortMappings(List<PortMapping> portMappings) { - List<Port> ports = new ArrayList<Port>(); + public static List<ContainerPort> convertPortMappings(List<PortMapping> portMappings) { + List<ContainerPort> ports = new ArrayList<ContainerPort>(); for (PortMapping portMapping : portMappings) { - Port port = new Port(); - port.setName(preparePortNameFromPortMapping(portMapping)); - port.setContainerPort(portMapping.getPort()); - ports.add(port); + ContainerPort containerPort = new ContainerPort(); + containerPort.setName(preparePortNameFromPortMapping(portMapping)); + containerPort.setContainerPort(portMapping.getPort()); + ports.add(containerPort); } return ports; } http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.common/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.common/pom.xml b/components/org.apache.stratos.common/pom.xml index d43a39a..316aef1 100644 --- a/components/org.apache.stratos.common/pom.xml +++ b/components/org.apache.stratos.common/pom.xml @@ -47,6 +47,7 @@ <Bundle-Name>${project.artifactId}</Bundle-Name> <Export-Package> org.apache.stratos.common.*, + org.apache.stratos.common.domain.*, org.apache.stratos.common.client.*, org.apache.stratos.common.services.*, org.apache.stratos.common.statistics.publisher.*, http://git-wip-us.apache.org/repos/asf/stratos/blob/3414e7ce/components/org.apache.stratos.kubernetes.client/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.kubernetes.client/pom.xml b/components/org.apache.stratos.kubernetes.client/pom.xml index 921c717..4f5cd8e 100644 --- a/components/org.apache.stratos.kubernetes.client/pom.xml +++ b/components/org.apache.stratos.kubernetes.client/pom.xml @@ -41,21 +41,6 @@ <version>3.1</version> </dependency> <dependency> - <groupId>org.apache.httpcomponents.wso2</groupId> - <artifactId>httpcore</artifactId> - <version>4.3.0.wso2v1</version> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents.wso2</groupId> - <artifactId>httpclient</artifactId> - <version>4.2.5.wso2v1</version> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.2.4</version> - </dependency> - <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </dependency> @@ -64,6 +49,11 @@ <artifactId>junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>kubernetes-api</artifactId> + <version>2.1.11-stratosv1</version> + </dependency> </dependencies> <build> @@ -76,6 +66,14 @@ <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> <Bundle-Name>${project.artifactId}</Bundle-Name> + <Export-Package> + org.apache.stratos.kubernetes.client, + org.apache.stratos.kubernetes.client.exceptions, + </Export-Package> + <Import-Package> + io.fabric8.kubernetes.api.*;version=2.1.11-stratosv1, + *;resolution:=optional + </Import-Package> <DynamicImport-Package>*</DynamicImport-Package> </instructions> </configuration>
