示例#1
0
def rebalance_ring():
    """
    1. Turn on "enforce-rebalance" flag on puppet master
    2. Send command to ringbuilder server to refresh puppet agent, so that it starts ring rebuilding
    3. Send command to all storage node and proxy node to refresh puppet agent
    
    """
    
    
    cmd= "rm /etc/swift/enforce-rebalance "
    exec_command_alone(cmd)
    cmd="cp /etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp /etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp.bk"
    exec_command_alone(cmd)
    try:    
        replaceAll("/etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp","$enforce_rebalance = 'no'","$enforce_rebalance = 'yes'")
        cmd= "puppet agent -t"
        __run_cmd_print__(cmd)
        replaceAll("/etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp","$enforce_rebalance = 'yes'","$enforce_rebalance = 'no'")
        
    except:
        cmd="cp /etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp.bk /etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp"
        exec_command_alone(cmd)
    
    finally:
        cmd="rm /etc/puppet/modules/openstack/manifests/swift_ringbuilder.pp.bk"
        exec_command_alone(cmd)
    
    push_ring()
示例#2
0
def print_output_multiple(cmd):
    output = exec_command_alone(cmd)
    str1 = str(output)
    i = str1.splitlines()
    for part in i:
        type = part.partition(':')[0]
        type1 = repr(type)
        cmd = "salt %s puppet.run" % type1
        print_formatted_output(cmd)
示例#3
0
def ring_rebalance():
    try:
        cmd= "rm /etc/swift/enforce-rebalance"
        exec_command_alone(cmd)
    except FileNotExist:
        
        print"File does not exist : %s" % cmd
        continue
    
    try:
        turn_on_rebalance()
    except FileNotExist:
        print "Sorry that file does not exist"
        sys.exit(1)
            
    cmd= "puppet agent -t"
    exec_command(cmd)       
    
    try:
        turn_off_rebalance()
    except FileNotExist:
        print" sorry this file does not exist"
        sys.exit(1)