aboutsummaryrefslogtreecommitdiffstats
path: root/lib/oom
blob: 91df0a9a875dac161c5a59d76354605648da0018 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash

source /var/onap/functions

oom_delay=30

# _pull_images_from_yaml() - Function that parses a yaml file and pull their images
function _pull_images_from_yaml_file {
    local values_file=$1
    local prefix=$2
    local s='[[:space:]]*'
    local w='[a-zA-Z0-9_]*'
    fs=`echo @|tr @ '\034'`

    for line in $(sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p"  $values_file |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {
    if (i > indent) {
        delete vname[i]}
    }
    if (length($3) > 0) {
        vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])(".")}
        printf("%s%s%s=%s\n", "'$prefix'",vn, $2, $3);
    }
}' | grep image); do
        echo $line
        if echo $line | grep -q Version ; then
            pull_docker_image "$image_name:$(echo $line | awk -F "=" '{print $2}')" &
        else
            image_name=`echo ${line#*=}`
            if [[ ${image_name#*${nexus_docker_repo:-nexus3.onap.org:10001}} == *:* ]]; then
                pull_docker_image $image_name &
            else
                pull_docker_image $image_name:latest
            fi
        fi
    done
}

# get_oom_images() - Function that retrieves ONAP images from official hub
function get_oom_images {
    if [[ "$build_image" == "True" ]]; then
        for project in aai appc dcae dmaap mr msb mso multicloud policy portal robot sdc sdnc vfc vid; do
            source /var/onap/$project
            get_${project}_images
        done
    else
        if [[ "$clone_repo" != "True" ]]; then
            clone_repos "oom"
        fi

        docker_openecomp_login
        for values_file in `find ${src_folders[oom]}/kubernetes -name values.yaml -type f`; do
            _pull_images_from_yaml_file $values_file
        done
        docker logout
        wait_docker_pull
    fi
}

# install_oom() - Function that clones OOM and deploys ONAP
function install_oom {
    local k8s_deployment_tool="kubespray"

    mount_external_partition sda /var/lib/docker/
    install_kubernetes kubespray
    if [[ "$deployment_tool" == "rancher" ]]; then
        pushd ~/.kube
        install_python_package requests
        python /var/onap/files/kubectl_config_generator.py
        popd
    fi
    until kubectl cluster-info; do
        echo "waiting for kubernetes host"
        sleep $oom_delay
    done
    install_helm
    printf "Kubernetes Info\n===============\n" > k8s_info.log
    echo "Dashboard URL: http://$IP_ADDRESS:$(kubectl get service -n kube-system |grep kubernetes-dashboard | awk '{print $5}' |awk -F "[:/]" '{print $2}')" >> k8s_info.log
    echo "Admin user: $(cat /etc/kubernetes/users/known_users.csv |awk -F ',' '{print $2}')" >> k8s_info.log
    echo "Admin password: $(cat /etc/kubernetes/users/known_users.csv |awk -F ',' '{print $1}')" >> k8s_info.log

    if [[ "$clone_repo" != "True" ]]; then
        clone_repos "oom"
    fi
    pushd ${src_folders[oom]}/kubernetes
    make repo
    make all
    helm install local/onap -n beijing -f /var/onap/files/dev.yaml
}

# init_oom() - Function that deploys ONAP using OOM
function init_oom {
    if [[ "$clone_repo" == "True" ]]; then
        clone_repos "oom"
    fi
    if [[ "$skip_get_images" == "False" ]]; then
        get_oom_images
    fi
    if [[ "$skip_install" == "False" ]]; then
        install_oom
    fi
}