~jose/charms/precise/vsm/fix-readme

« back to all changes in this revision

Viewing changes to hooks/lib/common.sh

  • Committer: Marga Millet
  • Date: 2014-04-13 21:53:17 UTC
  • Revision ID: millet@cisco.com-20140413215317-j95znco4v498mufy
Many fixes to VSM charm: added memory/vncport configurable paramaters. Make HA more user friendly...

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    fi
30
30
}
31
31
 
 
32
# Returns 0 if VSM VM is not created
 
33
function is_vsm_vm_created
 
34
{
 
35
    if [ `/usr/bin/virsh list --all | grep -c ${VSM_NAME}` -eq 1 ]; then
 
36
        return 1
 
37
    else
 
38
        return 0
 
39
    fi
 
40
}
 
41
 
32
42
# It creates a persistent VSM VM if it was not created already
33
43
# Returns 1 if it was not able to create it
34
44
function create_vsm_vm
35
45
{
36
 
    juju-log "start: Check if ${VSM_NAME} vm already exists"
 
46
    juju-log "Check if ${VSM_NAME} vm already exists"
37
47
 
38
48
    if [ `/usr/bin/virsh list --all | grep -c ${VSM_NAME}` -eq 1 ]; then
 
49
        juju-log "vsm vm is already created"
39
50
        return 0
40
51
    fi
41
52
 
42
53
    juju-log "Define vsm vm"
43
54
    if [ ! -f ${VSM_VM_DIR}/${VSM_VM_XML} ]; then
44
 
        juju-log "Error: ${VSM_NAME} template doesn't exists"
 
55
        juju-log "Error: ${VSM_NAME} template does not exist"
45
56
        return 1
46
57
    fi
47
58
    /usr/bin/virsh define ${VSM_VM_DIR}/${VSM_VM_XML}
60
71
                   ;;
61
72
        shut*)     juju-log "need to restart vsm ${VSM_NAME}"
62
73
                   /usr/bin/virsh start ${VSM_NAME}
 
74
                   if [ $? -eq 1 ]; then
 
75
                       juju-log "Error: vsm vm is shutdown but couldn't restart it"
 
76
                       return 1
 
77
                   fi
63
78
                   # Restart ovs to handle server reboot case
64
79
                   service openvswitch-switch restart
65
80
                   ;;
69
84
    return 0
70
85
}
71
86
 
72
 
export -f logger is_vsm_vm_running create_vsm_vm start_vsm_vm
 
87
export -f logger is_vsm_vm_running is_vsm_vm_created create_vsm_vm start_vsm_vm
73
88