aboutsummaryrefslogtreecommitdiffstats
path: root/ui-react/src/OnapClamp.js
blob: 506f6e09d916870e1fc4da1e092fefdc5ec2a66a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*-
 * ============LICENSE_START=======================================================
 * ONAP CLAMP
 * ================================================================================
 * Copyright (C) 2019 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============================================
 * ===================================================================
 *
 */

import React from 'react';
import LoopUI from './LoopUI'
import { ThemeProvider } from 'styled-components';
import { DefaultClampTheme } from './theme/globalStyle.js';

export default class OnapClamp extends LoopUI {
	
	render() {
		console.info("Onap Clamp UI starting");
		return (
		<ThemeProvider theme={DefaultClampTheme}>
			{super.render()}
		</ThemeProvider>);
	}
}
/span>setLevel(logging.DEBUG) def is_ready(container_name): log.info( "Checking if " + container_name + " is ready") kubernetes.config.kube_config.KubeConfigLoader(config_dict=get_k8s_config_env()).load_and_set() client = kubernetes.client namespace = get_namespace_env() v1 = client.CoreV1Api() ready = False try: response = v1.list_namespaced_pod(namespace=namespace, watch=False) for i in response.items: for s in i.status.container_statuses: if s.name == container_name: log.debug ( "response %s" % response ) ready = s.ready if not ready: log.info( container_name + " is not ready.") else: log.info( container_name + " is ready!") else: continue return ready except Exception as e: log.error("Exception when calling list_namespaced_pod: %s\n" % e) def get_k8s_config_env(): try: k8s_config_env = os.environ.get("K8S_CONFIG_B64") decoded = base64.b64decode(k8s_config_env) return yaml.load(decoded) except KeyError as ke: raise Exception("K8S_CONFIG_B64 variable is not set.") def get_namespace_env(): try: namespace_env = os.environ.get("NAMESPACE") return namespace_env except KeyError as ke: raise Exception("NAMESPACE variable is not set.") def main(args):#from kubernetes import client, config # args are a list of container names for container_name in args: # 5 min, TODO: make configurable timeout = time.time() + 60 * 10 while True: ready = is_ready(container_name) if ready is True: break elif time.time() > timeout: log.warning( "timed out waiting for '" + container_name + "' to be ready") exit(1) else: time.sleep(5) if __name__ == "__main__": parser = argparse.ArgumentParser(description='Process some names.') parser.add_argument('--container-name', action='append', required=True, help='A container name') args = parser.parse_args() arg_dict = vars(args) for arg in arg_dict.itervalues(): main(arg)