summaryrefslogtreecommitdiffstats
path: root/ci/deploy.sh
blob: 714336832551a38ff1fd41148a65f5520298ca1e (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash
##############################################################################
# Copyright (c) 2015 Tim Rozet (Red Hat), Dan Radez (Red Hat) and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

# Deploy script to install provisioning server for OPNFV Apex
# author: Dan Radez (dradez@redhat.com)
# author: Tim Rozet (trozet@redhat.com)
#
# Based on RDO Manager http://www.rdoproject.org

set -e

##VARIABLES
reset=$(tput sgr0 || echo "")
blue=$(tput setaf 4 || echo "")
red=$(tput setaf 1 || echo "")
green=$(tput setaf 2 || echo "")

interactive="FALSE"
ping_site="8.8.8.8"
ntp_server="pool.ntp.org"
net_isolation_enabled="TRUE"
net_isolation_arg=""
post_config="TRUE"
debug="FALSE"

declare -i CNT
declare UNDERCLOUD
declare -A deploy_options_array
declare -a performance_options
declare -A NET_MAP

SSH_OPTIONS=(-o StrictHostKeyChecking=no -o GlobalKnownHostsFile=/dev/null -o UserKnownHostsFile=/dev/null -o LogLevel=error)
DEPLOY_OPTIONS=""
CONFIG=${CONFIG:-'/var/opt/opnfv'}
RESOURCES=${RESOURCES:-"$CONFIG/images"}
LIB=${LIB:-"$CONFIG/lib"}
OPNFV_NETWORK_TYPES="admin_network private_network public_network storage_network api_network"

VM_CPUS=4
VM_RAM=8
VM_COMPUTES=2

# Netmap used to map networks to OVS bridge names
NET_MAP['admin_network']="br-admin"
NET_MAP['private_network']="br-private"
NET_MAP['public_network']="br-public"
NET_MAP['storage_network']="br-storage"
NET_MAP['api_network']="br-api"
ext_net_type="interface"
ip_address_family=4

# Libraries
lib_files=(
$LIB/common-functions.sh
$LIB/configure-deps-functions.sh
$LIB/parse-functions.sh
$LIB/virtual-setup-functions.sh
$LIB/undercloud-functions.sh
$LIB/overcloud-deploy-functions.sh
$LIB/post-install-functions.sh
$LIB/utility-functions.sh
$LIB/installer/onos/onos_gw_mac_update.sh
)
for lib_file in ${lib_files[@]}; do
  if ! source $lib_file; then
    echo -e "${red}ERROR: Failed to source $lib_file${reset}"
    exit 1
  fi
done

display_usage() {
  echo -e "Usage:\n$0 [arguments] \n"
  echo -e "   -d|--deploy-settings : Full path to deploy settings yaml file. Optional.  Defaults to null"
  echo -e "   -i|--inventory : Full path to inventory yaml file. Required only for baremetal"
  echo -e "   -n|--net-settings : Full path to network settings file. Optional."
  echo -e "   -p|--ping-site : site to use to verify IP connectivity. Optional. Defaults to 8.8.8.8"
  echo -e "   -v|--virtual : Virtualize overcloud nodes instead of using baremetal."
  echo -e "   --flat : disable Network Isolation and use a single flat network for the underlay network."
  echo -e "   --no-post-config : disable Post Install configuration."
  echo -e "   --debug : enable debug output."
  echo -e "   --interactive : enable interactive deployment mode which requires user to confirm steps of deployment."
  echo -e "   --virtual-cpus : Number of CPUs to use per Overcloud VM in a virtual deployment (defaults to 4)."
  echo -e "   --virtual-ram : Amount of RAM to use per Overcloud VM in GB (defaults to 8)."
}

##translates the command line parameters into variables
##params: $@ the entire command line is passed
##usage: parse_cmd_line() "$@"
parse_cmdline() {
  echo -e "\n\n${blue}This script is used to deploy the Apex Installer and Provision OPNFV Target System${reset}\n\n"
  echo "Use -h to display help"
  sleep 2

  while [ "${1:0:1}" = "-" ]
  do
    case "$1" in
        -h|--help)
                display_usage
                exit 0
            ;;
        -d|--deploy-settings)
                DEPLOY_SETTINGS_FILE=$2
                echo "Deployment Configuration file: $2"
                shift 2
            ;;
        -i|--inventory)
                INVENTORY_FILE=$2
                shift 2
            ;;
        -n|--net-settings)
                NETSETS=$2
                echo "Network Settings Configuration file: $2"
                shift 2
            ;;
        -p|--ping-site)
                ping_site=$2
                echo "Using $2 as the ping site"
                shift 2
            ;;
        -v|--virtual)
                virtual="TRUE"
                echo "Executing a Virtual Deployment"
                shift 1
            ;;
        --flat )
                net_isolation_enabled="FALSE"
                net_isolation_arg="--flat"
                echo "Underlay Network Isolation Disabled: using flat configuration"
                shift 1
            ;;
        --no-post-config )
                post_config="FALSE"
                echo "Post install configuration disabled"
                shift 1
            ;;
        --debug )
                debug="TRUE"
                echo "Enable debug output"
                shift 1
            ;;
        --interactive )
                interactive="TRUE"
                echo "Interactive mode enabled"
                shift 1
            ;;
        --virtual-cpus )
                VM_CPUS=$2
                echo "Number of CPUs per VM set to $VM_CPUS"
                shift 2
            ;;
        --virtual-ram )
                VM_RAM=$2
                echo "Amount of RAM per VM set to $VM_RAM"
                shift 2
            ;;
        --virtual-computes )
                VM_COMPUTES=$2
                echo "Virtual Compute nodes set to $VM_COMPUTES"
                shift 2
            ;;
        *)
                display_usage
                exit 1
            ;;
    esac
  done

  if [[ ! -z "$NETSETS" && "$net_isolation_enabled" == "FALSE" ]]; then
    echo -e "${red}INFO: Single flat network requested. Only admin_network settings will be used!${reset}"
  elif [[ -z "$NETSETS" ]]; then
    echo -e "${red}ERROR: You must provide a network_settings file with -n.${reset}"
    exit 1
  fi

  if [[ -n "$virtual" && -n "$INVENTORY_FILE" ]]; then
    echo -e "${red}ERROR: You should not specify an inventory with virtual deployments${reset}"
    exit 1
  fi

  if [[ -z "$DEPLOY_SETTINGS_FILE" || ! -f "$DEPLOY_SETTINGS_FILE" ]]; then
    echo -e "${red}ERROR: Deploy Settings: ${DEPLOY_SETTINGS_FILE} does not exist! Exiting...${reset}"
    exit 1
  fi

  if [[ ! -z "$NETSETS" && ! -f "$NETSETS" ]]; then
    echo -e "${red}ERROR: Network Settings: ${NETSETS} does not exist! Exiting...${reset}"
    exit 1
  fi

  if [[ ! -z "$INVENTORY_FILE" && ! -f "$INVENTORY_FILE" ]]; then
    echo -e "{$red}ERROR: Inventory File: ${INVENTORY_FILE} does not exist! Exiting...${reset}"
    exit 1
  fi

  if [[ -z "$virtual" && -z "$INVENTORY_FILE" ]]; then
    echo -e "${red}ERROR: You must specify an inventory file for baremetal deployments! Exiting...${reset}"
    exit 1
  fi

  if [[ "$net_isolation_enabled" == "FALSE" && "$post_config" == "TRUE" ]]; then
    echo -e "${blue}INFO: Post Install Configuration will be skipped.  It is not supported with --flat${reset}"
    post_config="FALSE"
  fi

}

main() {
  parse_cmdline "$@"
  if [ -n "$DEPLOY_SETTINGS_FILE" ]; then
    echo -e "${blue}INFO: Parsing deploy settings file...${reset}"
    parse_deploy_settings
  fi
  echo -e "${blue}INFO: Parsing network settings file...${reset}"
  parse_network_settings
  if ! configure_deps; then
    echo -e "${red}Dependency Validation Failed, Exiting.${reset}"
    exit 1
  fi
  setup_undercloud_vm
  if [ "$virtual" == "TRUE" ]; then
    setup_virtual_baremetal $VM_CPUS $VM_RAM
  elif [ -n "$INVENTORY_FILE" ]; then
    parse_inventory_file
  fi
  configure_undercloud
  overcloud_deploy
  if [ "$post_config" == "TRUE" ]; then
    if ! configure_post_install; then
      echo -e "${red}ERROR:Post Install Configuration Failed, Exiting.${reset}"
      exit 1
    else
      echo -e "${blue}INFO: Post Install Configuration Complete${reset}"
    fi
  fi
  if [[ "${deploy_options_array['sdn_controller']}" == 'onos' ]]; then
    if ! onos_update_gw_mac ${public_network_cidr} ${public_network_gateway}; then
      echo -e "${red}ERROR:ONOS Post Install Configuration Failed, Exiting.${reset}"
      exit 1
    else
      echo -e "${blue}INFO: ONOS Post Install Configuration Complete${reset}"
    fi
  fi
}

main "$@"
pan>; } static inline unsigned int b1_get_word(unsigned int base) { unsigned int val = 0; val |= b1_get_byte(base); val |= (b1_get_byte(base) << 8); val |= (b1_get_byte(base) << 16); val |= (b1_get_byte(base) << 24); return val; } static inline int b1_tx_empty(unsigned int base) { return inb(base + B1_OUTSTAT) & 0x1; } static inline void b1_put_byte(unsigned int base, unsigned char val) { while (!b1_tx_empty(base)); b1outp(base, B1_WRITE, val); } static inline int b1_save_put_byte(unsigned int base, unsigned char val) { unsigned long stop = jiffies + 2 * HZ; while (!b1_tx_empty(base) && time_before(jiffies, stop)); if (!b1_tx_empty(base)) return -1; b1outp(base, B1_WRITE, val); return 0; } static inline void b1_put_word(unsigned int base, unsigned int val) { b1_put_byte(base, val & 0xff); b1_put_byte(base, (val >> 8) & 0xff); b1_put_byte(base, (val >> 16) & 0xff); b1_put_byte(base, (val >> 24) & 0xff); } static inline unsigned int b1_get_slice(unsigned int base, unsigned char *dp) { unsigned int len, i; len = i = b1_get_word(base); while (i-- > 0) *dp++ = b1_get_byte(base); return len; } static inline void b1_put_slice(unsigned int base, unsigned char *dp, unsigned int len) { unsigned i = len; b1_put_word(base, i); while (i-- > 0) b1_put_byte(base, *dp++); } static void b1_wr_reg(unsigned int base, unsigned int reg, unsigned int value) { b1_put_byte(base, WRITE_REGISTER); b1_put_word(base, reg); b1_put_word(base, value); } static inline unsigned int b1_rd_reg(unsigned int base, unsigned int reg) { b1_put_byte(base, READ_REGISTER); b1_put_word(base, reg); return b1_get_word(base); } static inline void b1_reset(unsigned int base) { b1outp(base, B1_RESET, 0); mdelay(55 * 2); /* 2 TIC's */ b1outp(base, B1_RESET, 1); mdelay(55 * 2); /* 2 TIC's */ b1outp(base, B1_RESET, 0); mdelay(55 * 2); /* 2 TIC's */ } static inline unsigned char b1_disable_irq(unsigned int base) { return b1outp(base, B1_INSTAT, 0x00); } /* ---------------------------------------------------------------- */ static inline void b1_set_test_bit(unsigned int base, enum avmcardtype cardtype, int onoff) { b1_wr_reg(base, B1_STAT0(cardtype), onoff ? 0x21 : 0x20); } static inline int b1_get_test_bit(unsigned int base, enum avmcardtype cardtype) { return (b1_rd_reg(base, B1_STAT0(cardtype)) & 0x01) != 0; } /* ---------------------------------------------------------------- */ #define T1_FASTLINK 0x00 #define T1_SLOWLINK 0x08 #define T1_READ B1_READ #define T1_WRITE B1_WRITE #define T1_INSTAT B1_INSTAT #define T1_OUTSTAT B1_OUTSTAT #define T1_IRQENABLE 0x05 #define T1_FIFOSTAT 0x06 #define T1_RESETLINK 0x10 #define T1_ANALYSE 0x11 #define T1_IRQMASTER 0x12 #define T1_IDENT 0x17 #define T1_RESETBOARD 0x1f #define T1F_IREADY 0x01 #define T1F_IHALF 0x02 #define T1F_IFULL 0x04 #define T1F_IEMPTY 0x08 #define T1F_IFLAGS 0xF0 #define T1F_OREADY 0x10 #define T1F_OHALF 0x20 #define T1F_OEMPTY 0x40 #define T1F_OFULL 0x80 #define T1F_OFLAGS 0xF0 /* there are HEMA cards with 1k and 4k FIFO out */ #define FIFO_OUTBSIZE 256 #define FIFO_INPBSIZE 512 #define HEMA_VERSION_ID 0 #define HEMA_PAL_ID 0 static inline void t1outp(unsigned int base, unsigned short offset, unsigned char value) { outb(value, base + offset); } static inline unsigned char t1inp(unsigned int base, unsigned short offset) { return inb(base + offset); } static inline int t1_isfastlink(unsigned int base) { return (inb(base + T1_IDENT) & ~0x82) == 1; } static inline unsigned char t1_fifostatus(unsigned int base) { return inb(base + T1_FIFOSTAT); } static inline unsigned int t1_get_slice(unsigned int base, unsigned char *dp) { unsigned int len, i; #ifdef FASTLINK_DEBUG unsigned wcnt = 0, bcnt = 0; #endif len = i = b1_get_word(base); if (t1_isfastlink(base)) { int status; while (i > 0) { status = t1_fifostatus(base) & (T1F_IREADY | T1F_IHALF); if (i >= FIFO_INPBSIZE) status |= T1F_IFULL; switch (status) { case T1F_IREADY | T1F_IHALF | T1F_IFULL: insb(base + B1_READ, dp, FIFO_INPBSIZE); dp += FIFO_INPBSIZE; i -= FIFO_INPBSIZE; #ifdef FASTLINK_DEBUG wcnt += FIFO_INPBSIZE; #endif break; case T1F_IREADY | T1F_IHALF: insb(base + B1_READ, dp, i); #ifdef FASTLINK_DEBUG wcnt += i; #endif dp += i; i = 0; break; default: *dp++ = b1_get_byte(base); i--; #ifdef FASTLINK_DEBUG bcnt++; #endif break; } } #ifdef FASTLINK_DEBUG if (wcnt) printk(KERN_DEBUG "b1lli(0x%x): get_slice l=%d w=%d b=%d\n", base, len, wcnt, bcnt); #endif } else { while (i-- > 0) *dp++ = b1_get_byte(base); } return len; } static inline void t1_put_slice(unsigned int base, unsigned char *dp, unsigned int len) { unsigned i = len; b1_put_word(base, i); if (t1_isfastlink(base)) { int status; while (i > 0) { status = t1_fifostatus(base) & (T1F_OREADY | T1F_OHALF); if (i >= FIFO_OUTBSIZE) status |= T1F_OEMPTY; switch (status) { case T1F_OREADY | T1F_OHALF | T1F_OEMPTY: outsb(base + B1_WRITE, dp, FIFO_OUTBSIZE); dp += FIFO_OUTBSIZE; i -= FIFO_OUTBSIZE; break; case T1F_OREADY | T1F_OHALF: outsb(base + B1_WRITE, dp, i); dp += i; i = 0; break; default: b1_put_byte(base, *dp++); i--; break; } } } else { while (i-- > 0) b1_put_byte(base, *dp++); } } static inline void t1_disable_irq(unsigned int base) { t1outp(base, T1_IRQMASTER, 0x00); } static inline void t1_reset(unsigned int base) { /* reset T1 Controller */ b1_reset(base); /* disable irq on HEMA */ t1outp(base, B1_INSTAT, 0x00); t1outp(base, B1_OUTSTAT, 0x00); t1outp(base, T1_IRQMASTER, 0x00); /* reset HEMA board configuration */ t1outp(base, T1_RESETBOARD, 0xf); } static inline void b1_setinterrupt(unsigned int base, unsigned irq, enum avmcardtype cardtype) { switch (cardtype) { case avm_t1isa: t1outp(base, B1_INSTAT, 0x00); t1outp(base, B1_INSTAT, 0x02); t1outp(base, T1_IRQMASTER, 0x08); break; case avm_b1isa: b1outp(base, B1_INSTAT, 0x00); b1outp(base, B1_RESET, b1_irq_table[irq]); b1outp(base, B1_INSTAT, 0x02); break; default: case avm_m1: case avm_m2: case avm_b1pci: b1outp(base, B1_INSTAT, 0x00); b1outp(base, B1_RESET, 0xf0); b1outp(base, B1_INSTAT, 0x02); break; case avm_c4: case avm_t1pci: b1outp(base, B1_RESET, 0xf0); break; } } /* b1.c */ avmcard *b1_alloc_card(int nr_controllers); void b1_free_card(avmcard *card); int b1_detect(unsigned int base, enum avmcardtype cardtype); void b1_getrevision(avmcard *card); int b1_load_t4file(avmcard *card, capiloaddatapart *t4file); int b1_load_config(avmcard *card, capiloaddatapart *config); int b1_loaded(avmcard *card); int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data); void b1_reset_ctr(struct capi_ctr *ctrl); void b1_register_appl(struct capi_ctr *ctrl, u16 appl, capi_register_params *rp); void b1_release_appl(struct capi_ctr *ctrl, u16 appl); u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); void b1_parse_version(avmctrl_info *card); irqreturn_t b1_interrupt(int interrupt, void *devptr); extern const struct file_operations b1ctl_proc_fops; avmcard_dmainfo *avmcard_dma_alloc(char *name, struct pci_dev *, long rsize, long ssize); void avmcard_dma_free(avmcard_dmainfo *); /* b1dma.c */ int b1pciv4_detect(avmcard *card); int t1pci_detect(avmcard *card); void b1dma_reset(avmcard *card); irqreturn_t b1dma_interrupt(int interrupt, void *devptr); int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data); void b1dma_reset_ctr(struct capi_ctr *ctrl); void b1dma_remove_ctr(struct capi_ctr *ctrl); void b1dma_register_appl(struct capi_ctr *ctrl, u16 appl, capi_register_params *rp); void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl); u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb); extern const struct file_operations b1dmactl_proc_fops; #endif /* _AVMCARD_H_ */