f8bc5e08f818583c2a2490f4358755243b861756
[bottlenecks.git] / utils / dev_env / deploy / mac_generator.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11
12 ## This script is used in 'create_libvirt_vm.sh'
13 function mac_address_part() {
14     hex_number=$(printf '%02x' $RANDOM)
15     number_length=${#hex_number}
16     number_start=$(expr $number_length - 2)
17     echo ${hex_number:$number_start:2}
18 }
19
20 function mac_address() {
21     echo "00:00:$(mac_address_part):$(mac_address_part):$(mac_address_part):$(mac_address_part)"
22 }
23
24 machines=''
25 for i in `seq $1`; do
26   mac=$(mac_address)
27
28   if [[ -z $machines ]]; then
29     machines="${mac}"
30   else
31     machines="${machines} ${mac}"
32   fi
33 done
34
35 echo ${machines}