aboutsummaryrefslogtreecommitdiffstats
path: root/releases/1.7.1-container.yaml
blob: 99e32c87b18e8d30a714085d35cc8383e4d6e5e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
distribution_type: 'container'
container_release_tag: '1.7.1'
project: 'sdc'
log_dir: 'sdc-maven-docker-stage-master/467/'
ref: b988cb672876b1c129c76d60d3ddf7d129ef4bc2
containers:
  - name: 'sdc-backend'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-backend-init'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-backend-all-plugins'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-cassandra'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-cassandra-init'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-frontend'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-onboard-backend'
    version: '1.7-20200927T184925Z'
  - name: 'sdc-onboard-cassandra-init'
    version: '1.7-20200927T184925Z'
*/ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*-
 * ============LICENSE_START=======================================================
 * guard
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.guard;

import static org.junit.Assert.fail;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

import org.apache.commons.io.IOUtils;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;

public final class Util {
	
	/*
	 * Keys for guard properties
	 */
	public static final String PROP_GUARD_URL         = "guard.url";
	public static final String PROP_GUARD_USER        = "pdpx.username";
	public static final String PROP_GUARD_PASS        = "pdpx.password";
	public static final String PROP_GUARD_CLIENT_USER = "pdpx.client.username";
	public static final String PROP_GUARD_CLIENT_PASS = "pdpx.client.password";
	public static final String PROP_GUARD_ENV         = "pdpx.environment";
	
	/*
	 * Guard responses
	 */
	public static final String INDETERMINATE =  "Indeterminate";
	public static final String PERMIT = "Permit";
	public static final String DENY = "Deny";
	

	private static final Logger logger = LoggerFactory.getLogger(Util.class);
	public static class Pair<A, B> {
		public final A a;
		public final B b;
		
		public Pair(A a, B b) {
			this.a = a;
			this.b = b;
		}
	}
	
	public static Pair<ControlLoopPolicy, String>	loadYaml(String testFile) {
		try (InputStream is = new FileInputStream(new File(testFile))) {
			String contents = IOUtils.toString(is, StandardCharsets.UTF_8);
			//
			// Read the yaml into our Java Object
			//
			Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
			Object obj = yaml.load(contents);
			
			logger.debug(contents);
			
			return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);
		} catch (IOException e) {
			logger.error(e.getLocalizedMessage(), e);
			fail(e.getLocalizedMessage());
		}
		return null;
	}
	
	public static ControlLoopGuard	loadYamlGuard(String testFile) {
		try (InputStream is = new FileInputStream(new File(testFile))) {
			String contents = IOUtils.toString(is, StandardCharsets.UTF_8);
			//
			// Read the yaml into our Java Object
			//
			Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class));
			Object obj = yaml.load(contents);
			return (ControlLoopGuard) obj;
		} catch (IOException e) {
			logger.error(e.getLocalizedMessage(), e);
			fail(e.getLocalizedMessage());
		}
		return null;
	}
	
	/**
	 *  Sets Guard Properties.
	 * 
	 *  @see /guard/src/test/java/org/onap/policy/guard/UtilTest.java 
	 *  for setting test properties
	 */
	public static void setGuardEnvProps(String url, String username, String password, String clientName, String clientPassword, String environment){
		PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL,         url);
		PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER,        username);
		PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS,        password);
		PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_USER, clientName);
		PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_PASS, clientPassword);
		PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_ENV,         environment);
	}
	public static void setGuardEnvProp(String key, String value){
		PolicyEngine.manager.setEnvironmentProperty(key, value);
	}
	public static String getGuardProp(String propName){
		return PolicyEngine.manager.getEnvironmentProperty(propName);
	}

}