Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2014 Red Hat, Inc. Red Hat 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 io.fabric8.openshift;
 
 import java.util.Map;
 
 
 
 public class OpenShiftUtils {
    
Returns true if the given openshift configuration map has the OpenShiftConstants.PROPERTY_FABRIC_MANAGED flag enabled
 
     public static boolean isFabricManaged(Map<StringStringopenshiftConfiguration) {
         return Maps.booleanValue(openshiftConfiguration.false);
     }
 
     public static void close(IOpenShiftConnection connection) {
         if (connection != null) {
             ExecutorService executorService = connection.getExecutorService();
             if (executorService != null) {
                 executorService.shutdown();
             }
         }
     }
 
         if (options == null) {
             return null;
         }
         String serverUrl = options.getServerUrl();
         String login = options.getLogin();
         String password = options.getPassword();
         return createConnection(serverUrlloginpassword);
     }
 
     public static IOpenShiftConnection createConnection(String serverUrlString loginString password) {
         return new OpenShiftConnectionFactory().getConnection("fabric"loginpasswordserverUrl);
     }
 
     public static IOpenShiftConnection createConnection(Container container) {
         return createConnection(getCreateOptions(container));
     }
 
     public static CreateOpenshiftContainerOptions getCreateOptions(Container container) {
         CreateOpenshiftContainerMetadata metadata = getContainerMetadata(container);
         if (metadata == null) {
             return null;
         }
         return (CreateOpenshiftContainerOptionsmetadata.getCreateOptions();
     }
 
     protected static CreateOpenshiftContainerMetadata getContainerMetadata(Container container) {
         CreateContainerMetadata<?> value = container.getMetadata();
         if (value instanceof CreateOpenshiftContainerMetadata) {
             return (CreateOpenshiftContainerMetadata)value;
         } else {
             return null;
         }
     }
 
     public static IApplication getApplication(Container container) {
         CreateOpenshiftContainerMetadata metadata = getContainerMetadata(container);
         if (metadata == null) {
             return null;
         }
         CreateOpenshiftContainerOptions options = metadata.getCreateOptions();
         IOpenShiftConnection connection = OpenShiftUtils.createConnection(options);
         String containerName = container.getId();
         IDomain domain = connection.getUser().getDomain(metadata.getDomainId());
         return domain.getApplicationByName(containerName);
     }
 
     public static IApplication getApplication(Container container,
                                               IOpenShiftConnection connection) {
         return getApplication(containergetContainerMetadata(container), connection);
    }
    public static IApplication getApplication(Container containerCreateOpenshiftContainerMetadata metadata,
                                              IOpenShiftConnection connection) {
        String containerName = container.getId();
        IDomain domain = connection.getUser().getDomain(metadata.getDomainId());
        return domain.getApplicationByName(containerName);
    }
New to GrepCode? Check out our FAQ X