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
  • 相关阅读:
    三元表达式、递归、匿名函数
    迭代器、生成器、面向对象
    LeetCode35-搜索插入位置(二分查找)
    自动化测试框架搭建3-TestNG
    LeetCode28-实现strStr()(水题)
    前端页面与Nodejs使用websocket通信
    LeetCode14-最长公共前缀(水题)
    LeetCode13-罗马数字转整数(水题)
    AngularJS学习3-服务(service)/http服务/跨域
    九度OJ 1001:A+B for Matrices
  • 原文地址:https://www.cnblogs.com/telnetning/p/3084832.html
Copyright © 2011-2022 走看看