Find the answer to your Linux question:
Results 1 to 3 of 3
Hello people, This is my first post, and i have a question with the fence software for VMWare ESXi. The fence_vmware agent only works with ESX, and redhat (in you ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    3

    Cluster Suite and Fence for VMWare ESXi 4.0

    Hello people,

    This is my first post, and i have a question with the fence software for VMWare ESXi. The fence_vmware agent only works with ESX, and redhat (in you GIT repository) has submited a new agent called fence_vmware_ng that claims to work with ESXi. But the problem is that they do not specify the version that works with that.

    Anybody has test the fence_vmware_ng agent for VMWare ESXi 4.0 ?, i follow the instructions in the redhat wiki site, and i can install the software, the API from VMWARE site, etc, but in the moment when i run the agent nothing happen, The agent connects to server, i see in logs, but the off-reboot-on operations not works. Only works status operations, that return the state of a virtual machine.

    I have RHEL 5.3 (fully today updated) with RHCS.

    The output is:



    Thanks for your help!

    Sincerelly,

    ---
    Julián Ríos
    CHK Security Systems
    Medellín, Colombia

  2. #2
    Just Joined!
    Join Date
    Oct 2009
    Posts
    3

    Output

    The output is:

    [root@node1 ~]# fence_vmware_ng -o off -a IP -l root -p xxxxxx -n 'rhel node 2' -v

    fence_vmware_ng_helper --server 'IP' --username 'root' --password 'xxxxx' --operation status --vmname 'rhel node 2'
    rhel node 2:[datastore1] rhel node 2/rhel node 2.vmxoweredOn:connected

    fence_vmware_ng_helper --server 'IP' --username 'root' --password 'xxxxx' --operation off --vmname 'rhel node 2'

    fence_vmware_ng_helper --server 'IP' --username 'root' --password 'xxxxx' --operation status --vmname 'rhel node 2'
    rhel node 2:[datastore1] rhel node 2/rhel node 2.vmxoweredOn:connected

    fence_vmware_ng_helper --server 'IP' --username 'root' --password 'xxxxx' --operation status --vmname 'rhel node 2'
    rhel node 2:[datastore1] rhel node 2/rhel node 2.vmxoweredOn:connected
    ......

    Failed: Timed out waiting to power OFF

    In the VMWare ESXi Events tab i see:

    User root@127.0.0.1 logged in
    User root logged out
    User root@127.0.0.1 logged in
    User root logged out
    User root@127.0.0.1 logged in
    User root logged out
    ......

    And nothing happen !, not fence occurs. Help! Help!
    _________________
    Julián Ríos
    Red Hat Architect
    CHK Security Systems
    Medellín, Colombia

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    3
    Ok. I found the solution myself. Post for the community:

    0. Install VMWare tools, VMWare Perl API, VMWare vSphere SDK in each node,
    1. Install VMware VIX API version 1.6 (not 1.7 for license problems) from VMWARE site.
    2. Copy the script attach to this message into file called fence_vmware and copy to /sbin, set permissions 766. Note: this script is from redhat sources GIT repository, but this script have bugs, i correct them.
    3. Test fencing with this command: fence_vmware -o off -a "https://172.16.17.193/sdk" -l root -p xxxx -n "[datastore1] RHEL Cluster 1/RHEL Cluster 1.vmx" -v. Note that the IP address have /sdk in the end, and is https. If this command not work, see the output, the common problem is the name and path of the virtual machine.
    4. If the 4 point work, modofy your cluster.conf that looks:

    <clusternodes>
    <clusternode name="node2.chkgroup.net" nodeid="1" votes="1">
    <fence>
    <method name="1">
    <device name="VMWare_FENCE_n2" port="[datastore1] RHEL Cluster 2/RHEL Cluster 2.vmx"/>
    </method>
    </fence>
    </clusternode>
    <clusternode name="node1.chkgroup.net" nodeid="2" votes="1">
    <fence>
    <method name="1">
    <device name="VMWare_FENCE_n1" port="[datastore1] RHEL Cluster 1/RHEL Cluster 1.vmx"/>
    </method>
    </fence>
    </clusternodes>

    <fencedevices>
    <fencedevice agent="fence_vmware" ipaddr="https://172.16.17.193/sdk" name="VMWare_FENCE_n1" login="root" passwd="xxxx"/>
    <fencedevice agent="fence_vmware" ipaddr="https://172.16.17.193/sdk" name="VMWare_FENCE_n2" login="root" passwd="xxxx"/>
    </fencedevices>

    5. Wallaa!, this works!.

    Script attach:

    #!/usr/bin/python

    #
    # The Following agent has been tested on:
    # vmrun 2.0.0 build-116503 (from VMware Server 2.0) against:
    # VMware ESX 3.5 (works correctly)
    # VMware Server 2.0.0 (works correctly)
    # VMware ESXi 3.5 update 2 (works correctly)
    # VMware Server 1.0.7 (doesn't work)
    # Any older version of vmrun doesn't have support for ESX/ESXi
    #

    import sys, re, pexpect
    sys.path.append("/usr/lib/fence")
    from fencing import *

    #BEGIN_VERSION_GENERATION
    RELEASE_VERSION="VMware Agent using VIX API"
    REDHAT_COPYRIGHT=""
    BUILD_DATE=""
    #END_VERSION_GENERATION

    # Path to vmrun command
    VMRUN_COMMAND="/usr/bin/vmrun"
    # Default type for -T parameter of vmrun command (default is esx, can be changed with -c)
    VMWARE_DEFAULT_TYPE="esx"
    # Minimum required version of vmrun command
    VMRUN_MINIMUM_REQUIRED_VERSION=2

    # Return string with command and additional parameters (something like vmrun -h 'host'
    def vmware_vix_prepare_command(options,add_login_param s,additional_params):
    res=options["-c"]

    if (add_login_params):
    res+=" -h '%s' -u '%s' -p '%s' -T '%s' "%(options["-a"],options["-l"],options["-p"],options["-d"])

    if (additional_params!=""):
    res+=additional_params

    return res

    # Log message if user set verbose option
    def vmware_vix_log(options, message):
    if options["log"] >= LOG_MODE_VERBOSE:
    options["debug_fh"].write(message+"\n")

    # Run vmrun command with timeout and parameters. Internaly uses vmware_vix_prepare_command. Returns string
    # with output from vmrun command. If something fails (command not found, exit code is not 0), fail_usage
    # function is called (and never return).
    def vmware_vix_run_command(options,add_login_params,ad ditional_params):
    command=vmware_vix_prepare_command(options,add_log in_params,additional_params)

    try:
    vmware_vix_log(options,command)

    (res_output,res_code)=pexpect.run(command,POWER_TI MEOUT+SHELL_TIMEOUT+LOGIN_TIMEOUT,True)

    if (res_code==None):
    fail(EC_TIMED_OUT)
    if ((res_code!=0) and (add_login_params)):
    vmware_vix_log(options,res_output)
    fail_usage("vmrun returned %s"%(res_output))
    else:
    vmware_vix_log(options,res_output)

    except pexpect.ExceptionPexpect:
    fail_usage(("Bad command name %s. Make sure, that you installed\nvmrun command (VIX Api). "+\
    "If you have nonstandard installation location,\ntry use -c switch.")%(options["-c"]))

    return res_output

    # Returns True, if user uses supported vmrun version (currently >=2.0.0) otherwise False.
    def vmware_vix_is_supported_vmrun_version(options):
    vmware_help_str=vmware_vix_run_command(options,Fal se,"")
    version_re=re.search("vmrun version (\d\.(\d[\.]*)*)",vmware_help_str.lower())
    if (version_re==None):
    return False # Looks like this "vmrun" is not real vmrun

    version_array=version_re.group(1).split(".")

    try:
    if (int(version_array[0])<VMRUN_MINIMUM_REQUIRED_VERSION):
    return False
    except Exception:
    return False

    return True

    def get_outlets_status(conn, options):
    outlets={}

    running_machines=vmware_vix_run_command(options,Tr ue,"list")
    all_machines=vmware_vix_run_command(options,True," listRegisteredVM")

    all_machines_array=all_machines.splitlines()[1:]
    running_machines_array=running_machines.splitlines ()[1:]

    for machine in all_machines_array:
    if (machine!=""):
    outlets[machine]=("",((machine in running_machines_array) and "on" or "off"))

    return outlets

    def get_power_status(conn,options):
    outlets=get_outlets_status(conn,options)

    if (not (options["-n"] in outlets)):
    fail_usage("Failed: You have to enter existing name of virtual machine!")
    else:
    return outlets[options["-n"]][1]

    def set_power_status(conn, options):
    additional_params="%s '%s'"%((options["-o"]=="on" and "start" or "stop"),options["-n"])
    if (options["-o"]=="off"):
    additional_params+=" hard"

    vmware_vix_run_command(options,True,additional_par ams)

    # Define new options
    def vmware_vix_define_new_opts():
    all_opt["vmrun_cmd"]={
    "getopt":"c:",
    "help":"-c <command> Name of vmrun command (default "+VMRUN_COMMAND+")",
    "order": 2}
    all_opt["host_type"]={
    "getopt":"d:",
    "help":"-d <type> Type of VMware to connect (default "+VMWARE_DEFAULT_TYPE+")",
    "order": 2}

    def main():
    device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
    "action", "ipaddr", "login", "passwd", "passwd_script",
    "test", "port", "vmrun_cmd", "host_type" ]

    vmware_vix_define_new_opts()

    options = check_input(device_opt, process_input(device_opt))

    # Fence agent specific defaults
    if (not options.has_key("-c")):
    options["-c"]=VMRUN_COMMAND

    if (not options.has_key("-d")):
    options["-d"]=VMWARE_DEFAULT_TYPE

    # Test user vmrun command version
    if (not (vmware_vix_is_supported_vmrun_version(options))):
    fail_usage("Unsupported version of vmrun command! You must use at least version %d!"%(VMRUN_MINIMUM_REQUIRED_VERSION))

    # Operate the fencing device
    #fence_action(None, options, set_power_status, get_power_status, get_outlets_status)
    fence_action(None, options, set_power_status, get_power_status)

    if __name__ == "__main__":
    main()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...