izoratti / MAAS_VirtualBox

VirtualBox Extensions for MAAS
GNU General Public License v2.0
25 stars 13 forks source link

it this extention work for virtual box on windows>? #4

Open liuyanbiao opened 8 years ago

liuyanbiao commented 8 years ago

I am running virtualbox on windows desktop.

would this extension work?

Shuliyey commented 8 years ago

yeah same question I had in mind.

Also the Virtual Host Credentials, does it use ssh to authenticate for powering on and off the machine, if that's the case, I believe this extension won't work on windows, unless you set up an openssh-server on windows

Shuliyey commented 8 years ago

yeah I think you can get to work on windows, after you install openssh-server on windows

The power_on file

/usr/bin/maas login maas http://localhost/MAAS `cat ~/VBox_extensions/maas-api-key`

# Retrieve the id from the MAAS Power address
vm_to_start=${1//:}

# Loop through all the zones to send the request to all the VBox host machines
for zone_description in `maas maas zones read | grep '"description": "' | cut -d: -f 2`
do
    # Remove the "s
    vbox_host_credentials=${zone_description//\"}

    # Check if there is the @ sign, typical of ssh user@address
    if [[ ${vbox_host_credentials} == *"@"* ]]
    then
        # Create the command string
        command_to_execute="ssh ${vbox_host_credentials} '~/VBox_host_extensions/startvm ${vm_to_start//-}'"
        # Execute the command string
        eval "${command_to_execute}"

        # Log the command
        echo -e "VirtualBox-Power ON:" `date` "\n" \
                "Credentials: ${vbox_host_credentials}\n" \
                "ID: ${vm_to_start}\n" >> /tmp/VBox.log
    fi
done

As you can see, it is actually using ssh to push the remote execution command.