zoukankan      html  css  js  c++  java
  • openstack根据软件选择实例resume

    这是为我们项目所写的一个脚本,用来根据实例的metadata以及所需要开启的软件来启动相应的一个实例

    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
    #!/bin/bash
         
    #used to resume a instance from a suspended statue instance 
    #by find a instance who's metadata containing software named $1
         
    #list_00 used to save all id of suspended instances
    nova list 2>/dev/null  grep SUSPENDED | awk '{print $2}' >> list_00
         
    #list_01 used to save all ip of suspended instances
    #list_02 used to save all metadata of suspended instances
    for in `cat list_00`
            do
                    nova show $i 2>/dev/null sed -n "/network/p" awk '{print $6}' >> list_01
                    nova show $i 2>/dev/null sed -n "/metadata/p" awk '{print $5}' >> list_02
            done
         
    #by finding a metadata containing software and get the id and ip
    a=0
    for in `cat list_02`
            do
                    let "a += 1"
                    echo $i | grep $1
                    if [ $? -eq 0 ]
                            then
                                    nova resume `sed -n ${a}p list_00` 2>/dev/null
                                    sed -n "${a}p" list_01 2>/dev/null
                                    sed -n "${a}p" list_02 2>/dev/null sed -n 's/u//p' sed -n 's/}//p'
                            break
                    fi
            done
         
    rm list_00
    rm list_01
    rm list_02
  • 相关阅读:
    mapreduce 函数入门 三
    *hiho 1475
    hiho 1571
    hiho 1620
    hiho 1613
    centos下nginx配置
    hiho 1617
    hiho 172周
    uva 11584
    hiho1605
  • 原文地址:https://www.cnblogs.com/telnetning/p/3084832.html
Copyright © 2011-2022 走看看