You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/27 17:36:45 UTC
[9/9] git commit: JCLOUDS-758 Drop VirtualBox labs provider.
JCLOUDS-758 Drop VirtualBox labs provider.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/75178c77
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/75178c77
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/75178c77
Branch: refs/heads/master
Commit: 75178c7708260d9d9e3a70161b88a9dd6985a726
Parents: eea1bdb
Author: Adrian Cole <ad...@apache.org>
Authored: Mon Oct 27 09:36:14 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Mon Oct 27 09:36:14 2014 -0700
----------------------------------------------------------------------
pom.xml | 1 -
virtualbox/README.md | 238 ---------------
virtualbox/pom.xml | 156 ----------
.../main/java/org/jclouds/virtualbox/Host.java | 34 ---
.../jclouds/virtualbox/Preconfiguration.java | 34 ---
.../java/org/jclouds/virtualbox/VirtualBox.java | 32 --
.../virtualbox/VirtualBoxApiMetadata.java | 104 -------
.../compute/LoadMachineFromVirtualBox.java | 90 ------
.../VirtualBoxComputeServiceAdapter.java | 271 ----------------
.../extensions/VirtualBoxImageExtension.java | 168 ----------
...HardcodeLocalhostAsNodeMetadataSupplier.java | 130 --------
.../VirtualBoxComputeServiceContextModule.java | 234 --------------
.../virtualbox/config/VirtualBoxConstants.java | 66 ----
.../jclouds/virtualbox/domain/BridgedIf.java | 194 ------------
.../jclouds/virtualbox/domain/CloneSpec.java | 116 -------
.../virtualbox/domain/DeviceDetails.java | 116 -------
.../jclouds/virtualbox/domain/ErrorCode.java | 108 -------
.../virtualbox/domain/ExecutionType.java | 32 --
.../org/jclouds/virtualbox/domain/HardDisk.java | 146 ---------
.../org/jclouds/virtualbox/domain/IsoImage.java | 69 -----
.../org/jclouds/virtualbox/domain/IsoSpec.java | 92 ------
.../org/jclouds/virtualbox/domain/Master.java | 64 ----
.../jclouds/virtualbox/domain/MasterSpec.java | 117 -------
.../jclouds/virtualbox/domain/NatAdapter.java | 106 -------
.../virtualbox/domain/NetworkAdapter.java | 172 -----------
.../virtualbox/domain/NetworkInterfaceCard.java | 122 --------
.../jclouds/virtualbox/domain/NetworkSpec.java | 80 -----
.../org/jclouds/virtualbox/domain/NodeSpec.java | 89 ------
.../jclouds/virtualbox/domain/RedirectRule.java | 101 ------
.../virtualbox/domain/StorageController.java | 157 ----------
.../org/jclouds/virtualbox/domain/VmSpec.java | 180 -----------
.../jclouds/virtualbox/domain/YamlImage.java | 166 ----------
.../functions/AddIDEControllerIfNotExists.java | 50 ---
.../functions/ApplyBootOrderToMachine.java | 42 ---
.../functions/ApplyMemoryToMachine.java | 37 ---
.../AttachBridgedAdapterToMachine.java | 46 ---
.../functions/AttachHostOnlyAdapter.java | 45 ---
...tachMediumToMachineIfNotAlreadyAttached.java | 55 ----
...chNATAdapterToMachineIfNotAlreadyExists.java | 65 ----
.../functions/AttachNicToMachine.java | 60 ----
.../functions/BridgedIfStringToBridgedIf.java | 97 ------
...erMachineFromIMachineIfNotAlreadyExists.java | 133 --------
.../functions/CreateAndInstallVm.java | 168 ----------
...egisterMachineFromIsoIfNotAlreadyExists.java | 184 -----------
.../CreateMediumIfNotAlreadyExists.java | 144 ---------
.../DetachDistroMediumFromMachine.java | 53 ----
.../HardcodedHostToHostNodeMetadata.java | 65 ----
.../functions/IMachineToHardware.java | 56 ----
.../virtualbox/functions/IMachineToImage.java | 74 -----
.../functions/IMachineToIpAddress.java | 95 ------
.../functions/IMachineToNodeMetadata.java | 164 ----------
.../functions/IMachineToSshClient.java | 96 ------
.../virtualbox/functions/IMachineToVmSpec.java | 92 ------
.../functions/IpAddressesLoadingCache.java | 85 ------
.../LaunchMachineIfNotAlreadyRunning.java | 94 ------
.../virtualbox/functions/MacAddressToBSD.java | 47 ---
.../functions/MastersLoadingCache.java | 286 -----------------
.../virtualbox/functions/NodeCreator.java | 294 ------------------
.../RetrieveActiveBridgedInterfaces.java | 118 -------
.../virtualbox/functions/SendScancodes.java | 71 -----
.../virtualbox/functions/StringToKeyCode.java | 67 ----
.../TakeSnapshotIfNotAlreadyAttached.java | 110 -------
.../functions/YamlImagesFromFileConfig.java | 64 ----
.../functions/admin/FileDownloadFromURI.java | 83 -----
.../ImagesToYamlImagesFromYamlDescriptor.java | 82 -----
.../functions/admin/PreseedCfgServer.java | 69 -----
.../admin/StartVBoxIfNotAlreadyRunning.java | 138 ---------
...egisterMachineIfExistsAndDeleteItsMedia.java | 125 --------
...erMachineIfExistsAndForceDeleteItsMedia.java | 105 -------
.../predicates/IMachinePredicates.java | 60 ----
.../predicates/IMediumPredicates.java | 91 ------
.../predicates/RetryIfSocketNotYetOpen.java | 94 ------
.../virtualbox/predicates/SshAvailable.java | 65 ----
.../virtualbox/predicates/SshResponds.java | 48 ---
.../virtualbox/settings/KeyboardScancodes.java | 162 ----------
.../statements/DeleteGShadowLock.java | 43 ---
.../statements/EnableNetworkInterface.java | 79 -----
.../statements/GetIPAddressFromMAC.java | 70 -----
.../statements/InstallGuestAdditions.java | 99 ------
.../org/jclouds/virtualbox/statements/Md5.java | 47 ---
.../virtualbox/statements/PasswordlessSudo.java | 49 ---
.../statements/ScanNetworkWithPing.java | 56 ----
.../virtualbox/statements/SetHostname.java | 50 ---
.../virtualbox/statements/SetIpAddress.java | 70 -----
.../virtualbox/statements/Statements.java | 36 ---
.../virtualbox/util/IMediumAttachments.java | 41 ---
.../virtualbox/util/MachineController.java | 262 ----------------
.../util/MachineNameOrIdAndNicSlot.java | 131 --------
.../jclouds/virtualbox/util/MachineUtils.java | 280 -----------------
.../jclouds/virtualbox/util/NetworkUtils.java | 305 -------------------
.../services/org.jclouds.apis.ApiMetadata | 1 -
.../src/main/resources/default-images.yaml | 149 ---------
.../resources/functions/checkVBoxService.sh | 24 --
.../resources/functions/cleanupUdevIfNeeded.sh | 23 --
.../functions/exportIpAddressFromVmNamed.sh | 32 --
.../main/resources/functions/getIpAddress.cmd | 16 -
.../main/resources/functions/getIpAddress.sh | 32 --
.../functions/installModuleAssistantIfNeeded.sh | 27 --
.../BaseVirtualBoxClientLiveTest.java | 211 -------------
.../virtualbox/PreseedCfgServerTest.java | 70 -----
.../virtualbox/VirtualBoxApiMetadataTest.java | 28 --
...VirtualBoxComputeServiceAdapterLiveTest.java | 115 -------
.../VirtualBoxComputeServiceAdapterTest.java | 84 -----
.../compute/VirtualBoxExperimentLiveTest.java | 85 ------
.../VirtualBoxImageExtensionLiveTest.java | 56 ----
.../domain/ExportIpAddressForVMNamedTest.java | 44 ---
.../domain/ScanNetworkWithPingTest.java | 37 ---
.../jclouds/virtualbox/domain/VmSpecTest.java | 78 -----
.../experiment/TestConfiguration.java | 77 -----
.../AddIDEControllerIfNotExistsTest.java | 87 ------
.../functions/ApplyBootOrderToMachineTest.java | 46 ---
.../functions/ApplyMemoryToMachineTest.java | 66 ----
.../AttachBridgedAdapterToMachineTest.java | 62 ----
...MediumToMachineIfNotAlreadyAttachedTest.java | 159 ----------
...TAdapterToMachineIfNotAlreadyExistsTest.java | 138 ---------
.../BridgedIfStringToBridgedIfTest.java | 68 -----
...eFromIMachineIfNotAlreadyExistsLiveTest.java | 135 --------
.../functions/CreateAndInstallVmLiveTest.java | 162 ----------
...achineFromIsoIfNotAlreadyExistsLiveTest.java | 123 --------
...terMachineFromIsoIfNotAlreadyExistsTest.java | 162 ----------
.../CreateMediumIfNotAlreadyExistsLiveTest.java | 88 ------
.../CreateMediumIfNotAlreadyExistsTest.java | 242 ---------------
.../DetachDistroMediumFromMachineTest.java | 106 -------
.../functions/IMachineToHardwareTest.java | 69 -----
.../functions/IMachineToImageTest.java | 156 ----------
.../functions/IMachineToNodeMetadataTest.java | 140 ---------
.../functions/IMachineToVmSpecTest.java | 99 ------
.../LaunchMachineIfNotAlreadyRunningTest.java | 68 -----
.../functions/MacAddressToBSDTest.java | 37 ---
...trieveActiveBridgedInterfacesExpectTest.java | 56 ----
.../TakeSnapshotIfNotAlreadyAttachedTest.java | 105 -------
.../admin/ImageFromYamlStringTest.java | 57 ----
.../StartVBoxIfNotAlreadyRunningLiveTest.java | 64 ----
...terMachineIfExistsAndDeleteItsMediaTest.java | 81 -----
.../GuestAdditionsInstallerLiveTest.java | 136 ---------
.../predicates/IMachinePredicatesLiveTest.java | 117 -------
.../predicates/RetryIfSocketNotYetOpenTest.java | 83 -----
.../InstallGuestAdditionsLiveTest.java | 60 ----
.../statements/InstallGuestAdditionsTest.java | 76 -----
.../virtualbox/statements/PasswordlessTest.java | 34 ---
.../virtualbox/statements/SetIpAddressTest.java | 64 ----
.../util/MachineControllerLiveTest.java | 125 --------
.../virtualbox/util/MachineUtilsLiveTest.java | 181 -----------
virtualbox/src/test/resources/.gitattributes | 1 -
.../src/test/resources/default-images.yaml | 151 ---------
.../test/resources/default-keystroke-sequence | 19 --
virtualbox/src/test/resources/logback.xml | 76 -----
.../resources/redHatAndDerivatives/hostOnly | 26 --
.../src/test/resources/redHatAndDerivatives/nat | 30 --
.../test_export_ip_address_from_vm_named.sh | 29 --
.../src/test/resources/test_get_ip_address.cmd | 0
.../src/test/resources/test_get_ip_address.sh | 29 --
.../resources/test_guest_additions_installer.sh | 6 -
.../test_guest_additions_installer_init.sh | 223 --------------
154 files changed, 14813 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ebedd4d..6b91b42 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,6 @@
<modules>
<module>azurecompute</module>
<module>docker</module>
- <module>virtualbox</module>
<module>vcloud-director</module>
<module>cdmi</module>
<module>cloudsigma2</module>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/README.md
----------------------------------------------------------------------
diff --git a/virtualbox/README.md b/virtualbox/README.md
deleted file mode 100644
index 84fd2d6..0000000
--- a/virtualbox/README.md
+++ /dev/null
@@ -1,238 +0,0 @@
-# VirtualBox as a local cloud provider
-jclouds-virtualbox is a local cloud provider modelled on the virtualbox hypervisor. Similar to other jclouds supported providers, it supports the same portable abstractions offered by jclouds.
-
-##Setup
-
-Please follow these steps to configure your workstation for jclouds-virtualbox:
-
-- install the latest VirtualBox release (please visit https://www.virtualbox.org/wiki/Downloads)
-- assign passwordless ssh and passwordless sudo rights to your user
-
-### Passwordless ssh
-
-jclouds-virtualbox uses the current user.name and private key for sending commands to localhost over ssh.
-
-The current user (user.name) should have passwordless ssh. On a *nix system, you can enable this feature using `ssh-keygen` and `ssh-copy-id`.
-
-- ssh-keygen \- creates the public and private keys (by default in `${user.home}/.ssh/id_rsa.pub` and `${user.home}/.ssh/id_rsa`)
-> $ ssh-keygen
-- ssh-copy-id \- copies the user’s public key to a specified host’s `authorized_keys` file.
-ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys
-
-In this case:
-> $ ssh-copy-id -i ~/.ssh/id_rsa your-user@localhost
-
-If your system does not have an `ssh-copy-id` command, use something like this:
-> $ cat ~/.ssh/id_rsa.pub | ssh your-user@localhost "cat -> ~/.ssh/authorized_keys"
-
-### Passwordless sudo
-
-You need to have passwordless sudo rights on localhost. This is done by editing the sudoers file (/etc/sudoers). Use caution when editing this file, as introducing errors will lock you out of the system. Therefore, it is recommended to edit this file through the visudo command.
-
-The sudoers file should have a line like this (replace your-user):
-> your-user ALL=(ALL) NOPASSWD: ALL
-
-At this point, you should be able to login to localhost with `ssh your-user@localhost` without password.
-
-#How it works
-
-
- --------------- -------------
- | Image(s) | | Node(s) |
- --------------- -------------
- ------------------------------- -------
- | VirtualBox || Jetty |
- ------------------------------- -------
- --------- passwordless ssh+sudo ----------------------------------------
- | jclouds | ---------------------------> | localhost |
- --------- ----------------------------------------
-
-###Components
-- jclouds \- acts as a java (or clojure) client to access to virtualbox functionalities
-- localhost \- hosts the VirtualBox hypervisor and a jetty server which is automatically installed by jclouds-virtualbox during Images creation
-- VirtualBox \- jclouds-virtualbox assumes that the latest VirtualBox is installed (please see https://www.virtualbox.org/wiki/Downloads)
-- Jetty \- in this scenario, this http server is used to serve the preseed.cfg specified in YAML descriptor file
-- Image \- it logically represents a master VM (Virtual Machine) that can be cloned. It is a union of 2 sets of entities:
- * a list of supported images, described in the YAML descriptor files
- * a list of existing virtualbox VMs with name starting with "jclouds-image-0x0-"
-- Node \- is a virtualbox VM, linked cloned from another virtualbox VM marked as Image
-
-## Image creation
-
- ssh ---------------
- /----------------------------------> | Image(s) |
- | ---------------
- | ------------------------------- -------
- | | VirtualBox || Jetty |
- | ------------------------------- -------
- --------- passwordless ssh+sudo ----------------------------------------
- | jclouds | ---------------------------> | localhost |
- --------- ----------------------------------------
-
-The OS supported by jclouds-virtualbox are described in a YAML file `default-images.yaml` stored at `src/main/resources/`.
-
-For each OS supported, it stores the following information:
-a unique id, a name, a description, an os_arch, os_family, os_description, os_version, the iso url, the iso md5, username and credential to access this vm, a keystroke sequence for the OS installer and a preseed configuration file that contains the settings for this OS installation.
-
-For example, the corresponding YAML section for ubuntu 10.04.4 server (32 bit) looks like:
-
- - id: ubuntu-10.04.4-server-i386
- name: ubuntu-10.04-server-i386
- description: ubuntu 10.04.4 server (i386)
- os_arch: x86
- os_family: ubuntu
- os_description: ubuntu
- os_version: 10.04.4
- iso: http://releases.ubuntu.com/10.04.4/ubuntu-10.04.4-server-i386.iso
- iso_md5: fc08a01e78348e3918180ea91a6883bb
- username: toor
- credential: password
- keystroke_sequence: |
- <Esc><Esc><Enter>
- /install/vmlinuz noapic preseed/url=http://10.0.2.2:8080/src/test/resources/preseed.cfg
- debian-installer=en_US auto locale=en_US kbd-chooser/method=us
- hostname=vmName
- fb=false debconf/frontend=noninteractive
- console-setup/ask_detect=false console-setup/modelcode=pc105 console-setup/layoutcode=us
- initrd=/install/initrd.gz -- <Enter>
- preseed_cfg: |
- ## Options to set on the command line
- d-i debian-installer/locale string en_US
- d-i console-setup/ask_detect boolean false
- d-i console-setup/layoutcode string us
- d-i netcfg/get_hostname string unassigned-hostname
- d-i netcfg/get_domain string unassigned-domain
- d-i time/zone string UTC
- d-i clock-setup/utc-auto boolean true
- d-i clock-setup/utc boolean true
- d-i kbd-chooser/method select American English
- d-i netcfg/wireless_wep string
- d-i base-installer/kernel/override-image string linux-server
- d-i debconf debconf/frontend select Noninteractive
- d-i pkgsel/install-language-support boolean false
- tasksel tasksel/first multiselect standard, ubuntu-server
- d-i partman-auto/method string lvm
- #d-i partman-auto/purge_lvm_from_device boolean true
- d-i partman-lvm/confirm boolean true
- d-i partman-lvm/device_remove_lvm boolean true
- d-i partman-auto/choose_recipe select atomic
- d-i partman/confirm_write_new_label boolean true
- d-i partman/confirm_nooverwrite boolean true
- d-i partman/choose_partition select finish
- d-i partman/confirm boolean true
- # Write the changes to disks and configure LVM?
- d-i partman-lvm/confirm boolean true
- d-i partman-lvm/confirm_nooverwrite boolean true
- d-i partman-auto-lvm/guided_size string max
- ## Default user, we can get away with a recipe to change this
- d-i passwd/user-fullname string toor
- d-i passwd/username string toor
- d-i passwd/user-password password password
- d-i passwd/user-password-again password password
- d-i user-setup/encrypt-home boolean false
- d-i user-setup/allow-password-weak boolean true
- d-i pkgsel/include string openssh-server ntp
- # Whether to upgrade packages after debootstrap.
- # Allowed values: none, safe-upgrade, full-upgrade
- d-i pkgsel/upgrade select full-upgrade
- d-i grub-installer/only_debian boolean true
- d-i grub-installer/with_other_os boolean true
- d-i finish-install/reboot_in_progress note
- #For the update
- d-i pkgsel/update-policy select none
- # debconf-get-selections --install
- #Use mirror
- choose-mirror-bin mirror/http/proxy string
-
-The OS isos and guest additions isos will be stored in the jclouds working directory (by default ~/.jclouds-vbox/isos/)
-
-##Cloning nodes
-
- ssh --------------- -------------
- /----------------------------------> | Node(s) | | Image |
- | --------------- -------------
- | -------------------------------
- | | VirtualBox |
- | -------------------------------
- --------- (a) passwordless ssh+sudo ----------------------------------------
- | jclouds | ---------------------------> | localhost |
- --------- ----------------------------------------
-
-###Cloning strategy
-By default, a new node is cloned from a matching 'Image' with 'CloneOptions.Link'. This advanced option will save a lot of disk space and installation time as opposed to creating completely unique VMs for each new node.
-
-### Networking
-Each Node will have 2 NICs (Network Interface Cards) to enable an NAT+Host-Only networking strategy:
-
-* NIC1 at port 0 will be attached to Host-Only network to allow localhost-nodes communication and node-node communication
-* NIC2 at port 1 will be attached to NAT network to give each node internet access
-
---------------
-
-#Interacting with jclouds-vbox and connecting to machines
-
-For java guidance, please see [src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java].
-For now nat+host-only is the only available network configuration, nodes should be accessible from the host by:
-
- ssh user@192.168.56.X
-
-where:
-
-- user \- has passwordless ssh and sudo rights
-- X (2-253) \- is assigned by DHCP server of `vboxnet0`
-
---------------
-
-
-#Customization
-
-##Identity and Credential
-By default, jclouds-virtualbox will try to use the current user (with passwordless ssh and sudo rights), but you can also override this default by specifying
-`-Dvirtualbox.identity` and `-Dvirtualbox.credential`, if you want to use another user available on your local machine.
-
-##Preseed file
-In order to make available a preseed file, jclouds-virtualbox will start a PreseedServer at `http://localhost:23232` that will serve a preseed.cfg file.
-Make sure your firewall rules are not blocking this port.
-If you need to override this default you can use `-Djclouds.virtualbox.preconfigurationurl=http://localhost:PORT/preseed.cfg`, with a different PORT.
-
-##Working directory
-By default, cached isos for the OSs, guest additions, VMs and most configs are kept at the default working directory named `~/.jclouds-vbox/`,
-you can override the default working directory using `-Dtest.virtualbox.workingDir=/path/to/your/workingDir`.
-
-##Host-Only network
-jclouds-virtualbox needs an Host-Only network with DHCP enabled. This DHCP server will be responsible for assigning local IP addresses to the Nodes created by jclouds-virtualbox.
-
-jclouds-virtualbox will automatically create an Host-Only network with these settings:
-
-- IPv4: 192.168.56.1
-- IPv4 Network Mask: 255.255.255.0
-- DHCP Server: enabled
-
-with
-- Server Address: 192.168.56.254
-- Server Mask: 255.255.255.0
-- Lower Address Bound: 192.168.56.2
-- Upper Address Bound: 192.168.56.253
-
-Check virtualbox->Preferences->Networks for more details.
-
-**NB**: jclouds-virtualbox will not edit/replace a pre-exisiting Host-Only network.
-
---------------
-
-#Notes:
-
-- jclouds-virtualbox is still at alpha stage please report any issues you find at [jclouds issues](https://github.com/jclouds/jclouds/issues?state=open) or [jclouds google group](http://groups.google.com/group/jclouds).
-- jclouds-virtualbox has been tested on Mac OSX, it might work on Linux iff vbox is running and set up correctly. However, it will not currently run on Windows.
-
---------------
-
-#Troubleshooting
-
-As jclouds vbox support is quite new, issues may occasionally arise. Please follow these steps to get things going again:
-
-1. Remove all relevant VMs (named "jclouds-* ") with the vbox GUI. Make sure to select "delete all files". This step will solve most issues.
-2. If you are still receiving errors, please try the following steps to resolve any issues:
- * Kill all vbox processes (VboxHadless, VBoxSVC, VBoxXPCOMIPCD, VirtualBox, vboxwebsrv)
- * Manually delete the files by executing: "rm -rf ~/.jclouds-vbox/jclouds-*"
- * Restart the vbox GUI and make sure to delete all remaining machines while ignoring all errors
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/pom.xml
----------------------------------------------------------------------
diff --git a/virtualbox/pom.xml b/virtualbox/pom.xml
deleted file mode 100644
index da72c7f..0000000
--- a/virtualbox/pom.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>jclouds-labs</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <!-- TODO: when out of labs, switch to org.jclouds.api -->
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>virtualbox</artifactId>
- <name>jclouds virtualbox api</name>
- <description>jclouds components to access an implementation of virtualbox</description>
- <packaging>bundle</packaging>
-
- <properties>
- <virtualbox.version>4.2.8</virtualbox.version>
- <test.virtualbox.endpoint>http://localhost:18083/</test.virtualbox.endpoint>
- <test.virtualbox.api-version>4.2.8</test.virtualbox.api-version>
- <test.virtualbox.build-version>${virtualbox.version}</test.virtualbox.build-version>
- <test.virtualbox.identity>${user.name}</test.virtualbox.identity>
- <test.virtualbox.credential>CHANGE_ME</test.virtualbox.credential>
- <test.virtualbox.template>osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64,loginUser=toor:password,authenticateSudo=true</test.virtualbox.template>
- <jclouds.osgi.export>org.jclouds.virtualbox*;version="${project.version}"</jclouds.osgi.export>
- <jclouds.osgi.import>
- org.jclouds.labs*;version="${project.version}",
- org.jclouds*;version="${jclouds.version}",
- org.eclipse.jetty*;version="[7.5,9)",
- javax.servlet*;version="[2.5,3)",
- *
- </jclouds.osgi.import>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.virtualbox</groupId>
- <artifactId>vboxjws</artifactId>
- <version>${virtualbox.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>byon</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-sshj</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-slf4j</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-compute</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <artifactId>snakeyaml</artifactId>
- <groupId>org.yaml</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>live</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>integration</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <threadCount>1</threadCount>
- <parallel>false</parallel>
- <systemPropertyVariables>
- <test.virtualbox.endpoint>${test.virtualbox.endpoint}</test.virtualbox.endpoint>
- <test.virtualbox.api-version>${test.virtualbox.api-version}</test.virtualbox.api-version>
- <test.virtualbox.build-version>${test.virtualbox.build-version}</test.virtualbox.build-version>
- <test.virtualbox.identity>${test.virtualbox.identity}</test.virtualbox.identity>
- <test.virtualbox.credential>${test.virtualbox.credential}</test.virtualbox.credential>
- <test.virtualbox.template>${test.virtualbox.template}</test.virtualbox.template>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/Host.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/Host.java b/virtualbox/src/main/java/org/jclouds/virtualbox/Host.java
deleted file mode 100644
index d2fb65a..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/Host.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Signals the annotated target pertains to the vbox host and not to one of the nodes.
- */
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
-@Qualifier
-public @interface Host {
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/Preconfiguration.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/Preconfiguration.java b/virtualbox/src/main/java/org/jclouds/virtualbox/Preconfiguration.java
deleted file mode 100644
index 11718db..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/Preconfiguration.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Relating to a preseed or KickStart source
- */
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
-@Qualifier
-public @interface Preconfiguration {
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBox.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBox.java b/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBox.java
deleted file mode 100644
index e745160..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBox.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox;
-
-import org.virtualbox_4_2.VirtualBoxManager;
-
-public class VirtualBox {
-
- private VirtualBoxManager manager;
-
- public VirtualBox() {
- this.manager = VirtualBoxManager.createInstance("");
- }
-
- public VirtualBoxManager manager() {
- return manager;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java b/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java
deleted file mode 100644
index 51f2bb2..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox;
-
-import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_GUEST_MEMORY;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
-
-import java.io.File;
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.apis.internal.BaseApiMetadata;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.virtualbox.config.HardcodeLocalhostAsNodeMetadataSupplier;
-import org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- * Implementation of {@link ApiMetadata} for VirtualBox API
-
- */
-public class VirtualBoxApiMetadata extends BaseApiMetadata {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public VirtualBoxApiMetadata() {
- this(new Builder());
- }
-
- protected VirtualBoxApiMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = BaseApiMetadata.defaultProperties();
-
- String workingDir = System.getProperty("test.virtualbox.workingDir", VIRTUALBOX_DEFAULT_DIR);
- properties.put(VIRTUALBOX_WORKINGDIR, workingDir);
-
- String ram = System.getProperty(VIRTUALBOX_GUEST_MEMORY, "512");
- properties.put(VIRTUALBOX_GUEST_MEMORY, ram);
-
- String yamlDescriptor = System.getProperty("test.virtualbox.image.descriptor.yaml", VIRTUALBOX_WORKINGDIR
- + File.separator + "images.yaml");
-
- properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor);
- properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232");
- properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64");
- return properties;
- }
-
- public static class Builder extends BaseApiMetadata.Builder<Builder> {
-
- protected Builder() {
- id("virtualbox")
- .name("VirtualBox API")
- .identityName("User")
- .credentialName("Password")
- .documentation(URI.create("https://www.virtualbox.org/sdkref/index.html"))
- .defaultIdentity(System.getProperty("user.name"))
- .defaultCredential("CHANGE_ME")
- .defaultEndpoint("http://localhost:18083/")
- .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/labs/virtualbox"))
- .version("4.2.8")
- .buildVersion("4.2.8")
- .defaultProperties(VirtualBoxApiMetadata.defaultProperties())
- .view(ComputeServiceContext.class)
- .defaultModules(ImmutableSet.<Class<? extends Module>>of(HardcodeLocalhostAsNodeMetadataSupplier.class, VirtualBoxComputeServiceContextModule.class));
- }
-
- @Override
- public VirtualBoxApiMetadata build() {
- return new VirtualBoxApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/compute/LoadMachineFromVirtualBox.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/compute/LoadMachineFromVirtualBox.java b/virtualbox/src/main/java/org/jclouds/virtualbox/compute/LoadMachineFromVirtualBox.java
deleted file mode 100644
index 5e02162..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/compute/LoadMachineFromVirtualBox.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox.compute;
-
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_CREDENTIAL;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_GROUP;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_LOCATION;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_MACHINE_USERNAME;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.inject.Inject;
-
-import org.jclouds.byon.Node;
-import org.jclouds.compute.domain.OsFamily;
-import org.virtualbox_4_2.IGuestOSType;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.base.Function;
-import com.google.common.cache.CacheLoader;
-
-/**
- * Loads a node from a VirtualBox IMachine
- */
-public class LoadMachineFromVirtualBox extends CacheLoader<String, Node> {
-
- private VirtualBoxManager manager;
- private Function<IMachine, String> iMachineToIpAddress;
-
- @Inject
- public LoadMachineFromVirtualBox(VirtualBoxManager manager, Function<IMachine, String> iMachineToIpAddress) {
- this.manager = manager;
- this.iMachineToIpAddress = iMachineToIpAddress;
- }
-
- @Override
- public Node load(final String id) throws Exception {
-
- if (id.equals("host")) {
- final Node hostNode = Node.builder().id("host").name("host installing virtualbox").hostname("localhost")
- .osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name"))
- .osVersion(System.getProperty("os.version")).group("ssh").username(System.getProperty("user.name"))
- .credentialUrl(privateKeyFile()).build();
- return hostNode;
- }
-
- final IMachine machine = manager.getVBox().findMachine(id);
- final String ipAddress = iMachineToIpAddress.apply(machine);
- final String osTypeId = machine.getOSTypeId();
- final IGuestOSType guestOSType = manager.getVBox().getGuestOSType(osTypeId);
-
- final Node node = Node.builder().id(machine.getId()).name(machine.getName())
- .description(machine.getDescription()).loginPort(22).group(System.getProperty(VIRTUALBOX_MACHINE_GROUP))
- .username(System.getProperty(VIRTUALBOX_MACHINE_USERNAME))
- .credential(System.getProperty(VIRTUALBOX_MACHINE_CREDENTIAL))
- .sudoPassword(System.getProperty(VIRTUALBOX_MACHINE_CREDENTIAL))
- .locationId(System.getProperty(VIRTUALBOX_MACHINE_LOCATION)).os64Bit(guestOSType.getIs64Bit())
- .osArch(guestOSType.getDescription()).osFamily(guestOSType.getFamilyDescription())
- .osVersion(guestOSType.getId()).osDescription(guestOSType.getDescription()).hostname(ipAddress).build();
-
- return node;
-
- }
-
- private static URI privateKeyFile() {
- try {
- return new URI("file://" + System.getProperty("user.home") + "/.ssh/id_rsa");
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java b/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java
deleted file mode 100644
index 61c459b..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox.compute;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.collect.Iterables.contains;
-import static com.google.common.collect.Iterables.filter;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_NAME_SEPARATOR;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_NODE_PREFIX;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.Location;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.logging.Logger;
-import org.jclouds.virtualbox.domain.Master;
-import org.jclouds.virtualbox.domain.NodeSpec;
-import org.jclouds.virtualbox.domain.YamlImage;
-import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndForceDeleteItsMedia;
-import org.jclouds.virtualbox.util.MachineController;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.IProgress;
-import org.virtualbox_4_2.ISession;
-import org.virtualbox_4_2.MachineState;
-import org.virtualbox_4_2.VBoxException;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.inject.Singleton;
-
-/**
- * Defines the connection between the {@link org.virtualbox_4_2.VirtualBoxManager} implementation
- * and the jclouds {@link org.jclouds.compute.ComputeService}
- */
-@Singleton
-public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter<IMachine, Hardware, Image, Location> {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
-
- private final Supplier<VirtualBoxManager> manager;
- private final Map<Image, YamlImage> imagesToYamlImages;
- private final LoadingCache<Image, Master> mastersLoader;
- private final Function<NodeSpec, NodeAndInitialCredentials<IMachine>> cloneCreator;
- private final Function<IMachine, Image> imachineToImage;
- private final MachineController machineController;
-
- @Inject
- public VirtualBoxComputeServiceAdapter(Supplier<VirtualBoxManager> manager,
- Supplier<Map<Image, YamlImage>> imagesMapper, LoadingCache<Image, Master> mastersLoader,
- Function<NodeSpec, NodeAndInitialCredentials<IMachine>> cloneCreator,
- Function<IMachine, Image> imachineToImage,
- MachineController machineController) {
- this.manager = checkNotNull(manager, "virtualbox manager can't be null");
- this.imagesToYamlImages = imagesMapper.get();
- this.mastersLoader = mastersLoader;
- this.cloneCreator = cloneCreator;
- this.imachineToImage = imachineToImage;
- this.machineController = machineController;
- }
-
- @Override
- public NodeAndInitialCredentials<IMachine> createNodeWithGroupEncodedIntoName(String tag, String name,
- Template template) {
- try {
- checkState(!tag.contains(VIRTUALBOX_NODE_NAME_SEPARATOR), "tag names cannot contain \""
- + VIRTUALBOX_NODE_NAME_SEPARATOR + "\"");
- checkState(!name.contains(VIRTUALBOX_NODE_NAME_SEPARATOR), "node names cannot contain \""
- + VIRTUALBOX_NODE_NAME_SEPARATOR + "\"");
- Master master = mastersLoader.get(template.getImage());
- checkState(master != null, "could not find a master for image: " + template.getImage());
- NodeSpec nodeSpec = NodeSpec.builder().master(master).name(name).tag(tag).template(template).build();
- return cloneCreator.apply(nodeSpec);
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public Iterable<IMachine> listNodes() {
- return Iterables.filter(manager.get().getVBox().getMachines(), new Predicate<IMachine>() {
- @Override
- public boolean apply(IMachine arg0) {
- return arg0.getName().startsWith(VIRTUALBOX_NODE_PREFIX);
- }
- });
- }
-
- @Override
- public Iterable<IMachine> listNodesByIds(final Iterable<String> ids) {
- return filter(listNodes(), new Predicate<IMachine>() {
-
- @Override
- public boolean apply(IMachine machine) {
- return contains(ids, machine.getId());
- }
- });
- }
-
- @Override
- public Iterable<Hardware> listHardwareProfiles() {
- Set<Hardware> hardware = Sets.newLinkedHashSet();
- hardware.add(new HardwareBuilder().ids("t1.micro").hypervisor("VirtualBox").name("t1.micro").ram(512).build());
- hardware.add(new HardwareBuilder().ids("m1.small").hypervisor("VirtualBox").name("m1.small").ram(1024).build());
- hardware.add(new HardwareBuilder().ids("m1.medium").hypervisor("VirtualBox").name("m1.medium").ram(3840).build());
- hardware.add(new HardwareBuilder().ids("m1.large").hypervisor("VirtualBox").name("m1.large").ram(7680).build());
- return hardware;
- }
-
- @Override
- public Iterable<Image> listImages() {
- // the set of image vm names that were (or could be) built from the yaml file
- final Set<String> imagesFromYamlNames = Sets.newHashSet(Iterables.transform(imagesToYamlImages.keySet(),
- new Function<Image, String>() {
- @Override
- public String apply(Image input) {
- return VIRTUALBOX_IMAGE_PREFIX + input.getId();
- }
-
- }));
-
- // IMachines that were not built from the yaml file transformed to Images
- Set<Image> imagesFromCloning = Sets.newHashSet(Iterables.transform(
- Iterables.filter(imageMachines(), new Predicate<IMachine>() {
- @Override
- public boolean apply(IMachine input) {
- return !imagesFromYamlNames.contains(input.getName());
- }
- }), imachineToImage));
-
- // final set of images are those from yaml and those from vbox that were not a transformation
- // of the yaml ones
- return Sets.union(imagesToYamlImages.keySet(), imagesFromCloning);
- }
-
- private Iterable<IMachine> imageMachines() {
- final Predicate<? super IMachine> imagePredicate = new Predicate<IMachine>() {
- @Override
- public boolean apply(@Nullable IMachine iMachine) {
- return iMachine.getName().startsWith(VIRTUALBOX_IMAGE_PREFIX);
- }
- };
- final Iterable<IMachine> imageMachines = filter(manager.get().getVBox().getMachines(), imagePredicate);
- return imageMachines;
- }
-
- @Override
- public Iterable<Location> listLocations() {
- // Not using the adapter to determine locations
- return ImmutableSet.<Location> of();
- }
-
- @Override
- public IMachine getNode(String vmName) {
- try {
- return manager.get().getVBox().findMachine(vmName);
- } catch (VBoxException e) {
- if (e.getMessage().contains("Could not find a registered machine named")) {
- return null;
- }
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public Image getImage(String vmName) {
- IMachine image = getNode(vmName);
- if (image == null)
- return null;
- return imachineToImage.apply(image);
- }
-
- @Override
- public synchronized void destroyNode(String vmName) {
- IMachine machine = manager.get().getVBox().findMachine(vmName);
- powerDownMachine(machine);
- try {
- new UnregisterMachineIfExistsAndForceDeleteItsMedia().apply(machine);
- } catch (Exception e) {
- logger.error("Machine (%s) not unregistered!", vmName);
- }
- }
-
- @Override
- public void rebootNode(String vmName) {
- IMachine machine = manager.get().getVBox().findMachine(vmName);
- powerDownMachine(machine);
- launchVMProcess(machine, manager.get().getSessionObject());
- }
-
- @Override
- public void resumeNode(String vmName) {
- IMachine machine = manager.get().getVBox().findMachine(vmName);
- ISession machineSession;
- try {
- machineSession = manager.get().openMachineSession(machine);
- machineSession.getConsole().resume();
- machineSession.unlockMachine();
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- }
-
- @Override
- public void suspendNode(String vmName) {
- IMachine machine = manager.get().getVBox().findMachine(vmName);
- ISession machineSession;
- try {
- machineSession = manager.get().openMachineSession(machine);
- machineSession.getConsole().pause();
- machineSession.unlockMachine();
- } catch (Exception e) {
- throw Throwables.propagate(e);
- }
- }
-
- private void launchVMProcess(IMachine machine, ISession session) {
- IProgress prog = machine.launchVMProcess(session, "gui", "");
- prog.waitForCompletion(-1);
- session.unlockMachine();
- }
-
- private void powerDownMachine(IMachine machine) {
- try {
- if (machine.getState() == MachineState.PoweredOff) {
- logger.debug("vm was already powered down: ", machine.getId());
- return;
- }
- logger.debug("<< powering down vm(%s)", machine.getName());
- machineController.ensureMachineHasPowerDown(machine.getName());
- } catch (Exception e) {
- logger.error(e, "problem in powering down vm(%s)", machine.getName());
- throw Throwables.propagate(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/compute/extensions/VirtualBoxImageExtension.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/compute/extensions/VirtualBoxImageExtension.java b/virtualbox/src/main/java/org/jclouds/virtualbox/compute/extensions/VirtualBoxImageExtension.java
deleted file mode 100644
index ce15ee8..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/compute/extensions/VirtualBoxImageExtension.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox.compute.extensions;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
-import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
-
-import java.util.List;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.domain.CloneImageTemplate;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageTemplate;
-import org.jclouds.compute.domain.ImageTemplateBuilder;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.Location;
-import org.jclouds.logging.Logger;
-import org.jclouds.virtualbox.functions.IMachineToVmSpec;
-import org.jclouds.virtualbox.functions.TakeSnapshotIfNotAlreadyAttached;
-import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
-import org.jclouds.virtualbox.util.MachineUtils;
-import org.virtualbox_4_2.CloneMode;
-import org.virtualbox_4_2.CloneOptions;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.IProgress;
-import org.virtualbox_4_2.ISnapshot;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Virtualbox implementation of {@link ImageExtension}
- */
-@Singleton
-public class VirtualBoxImageExtension implements ImageExtension {
-
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- private Logger logger = Logger.NULL;
- private ComputeServiceAdapter<IMachine, Hardware, Image, Location> vboxAdapter;
- private Function<IMachine, NodeMetadata> machineToNode;
- private Supplier<VirtualBoxManager> manager;
- private String workingDir;
- private boolean isLinkedClone = true;
- private Function<IMachine, Image> imachineToImage;
- private MachineUtils machineUtils;
-
- @Inject
- public VirtualBoxImageExtension(ComputeServiceAdapter<IMachine, Hardware, Image, Location> vboxAdapter,
- Function<IMachine, NodeMetadata> machineToNode, Supplier<VirtualBoxManager> manager,
- @Named(VIRTUALBOX_WORKINGDIR) String workingDir, Function<IMachine, Image> imachineToImage,
- MachineUtils machineUtils) {
- this.vboxAdapter = vboxAdapter;
- this.machineToNode = machineToNode;
- this.manager = manager;
- this.workingDir = workingDir == null ? VIRTUALBOX_DEFAULT_DIR : workingDir;
- this.imachineToImage = imachineToImage;
- this.machineUtils = machineUtils;
- }
-
- @Override
- public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
- Optional<NodeMetadata> sourceNode = getNodeById(id);
- checkState(sourceNode.isPresent(), " there is no node with id " + id);
- String vmName = VIRTUALBOX_IMAGE_PREFIX + name;
-
- IMachine vm = null;
- try {
- vm = manager.get().getVBox().findMachine(vmName);
- } catch (Exception e) {
- }
- checkState(vm == null, " a machine exists with name: " + vmName);
- return new ImageTemplateBuilder.CloneImageTemplateBuilder().name(vmName).nodeId(id).build();
- }
-
- @Override
- public ListenableFuture<Image> createImage(ImageTemplate template) {
- checkState(template instanceof CloneImageTemplate, " vbox image extension only supports cloning for the moment.");
- CloneImageTemplate cloneTemplate = CloneImageTemplate.class.cast(template);
-
- IMachine source = manager.get().getVBox().findMachine(cloneTemplate.getSourceNodeId());
-
- String flags = "";
- List<String> groups = ImmutableList.of();
- String group = "";
- String settingsFile = manager.get().getVBox().composeMachineFilename(template.getName(), group , flags , workingDir);
- IMachine clonedMachine = manager.get().getVBox()
- .createMachine(settingsFile, template.getName(), groups, source.getOSTypeId(), flags);
-
- List<CloneOptions> options = Lists.newArrayList();
- if (isLinkedClone)
- options.add(CloneOptions.Link);
-
- // TODO snapshot name
- ISnapshot currentSnapshot = new TakeSnapshotIfNotAlreadyAttached(manager, "pre-image-spawn", "before spawning "
- + template.getName(), logger).apply(source);
-
- checkNotNull(currentSnapshot);
-
- // clone
- IProgress progress = currentSnapshot.getMachine().cloneTo(clonedMachine, CloneMode.MachineState, options);
- progress.waitForCompletion(-1);
-
- logger.debug(String.format("<< master(%s) is cloned correctly to vm(%s)", source.getName(), clonedMachine.getName()));
-
- // registering
- manager.get().getVBox().registerMachine(clonedMachine);
-
- return Futures.immediateFuture(imachineToImage.apply(clonedMachine));
- }
-
- @Override
- public boolean deleteImage(String id) {
- try {
- IMachine machine = manager.get().getVBox().findMachine(VIRTUALBOX_IMAGE_PREFIX + id);
- machineUtils.applyForMachine(machine.getId(), new UnregisterMachineIfExistsAndDeleteItsMedia(
- new IMachineToVmSpec().apply(machine)));
- } catch (Exception e) {
- logger.error(e, "Could not delete machine with id %s ", id);
- return false;
- }
- return true;
- }
-
- private Optional<NodeMetadata> getNodeById(final String id) {
- return Iterables.tryFind(Iterables.transform(vboxAdapter.listNodes(), machineToNode),
- new Predicate<NodeMetadata>() {
- @Override
- public boolean apply(NodeMetadata input) {
- return input.getId().equals(id);
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java b/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java
deleted file mode 100644
index 0d69600..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/config/HardcodeLocalhostAsNodeMetadataSupplier.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox.config;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.inject.Singleton;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.domain.LoginCredentials;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Strings;
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.io.Files;
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-
-/**
- * In particular, this binds {@code Supplier<NodeMetadata>} so that it can be used in ssh commands.
- * Ssh is necessary for operations that cannot be performed in the virtual box api, such as clearing
- * sessions.
- *
- * ex. once this is loaded, use Guice to inject {@code Supplier<NodeMetadata>} as {@code host} and
- * {@link RunScriptOnNode#Factory} as factory, to start making commands like the following:
- *
- * <pre>
- * import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
- * import static org.jclouds.scriptbuilder.domain.Statements.*;
- *
- * ...
- *
- * // direct execute a script as opposed to using sudo, or an init wrapper
- * ListenableFuture<ExecResponse> fooInTheFuture = factory.submit(host.get(),
- * exec("echo foo"), runAsRoot(false).wrapInInitScript(false));
- *
- * ExecResponse foo = Futures.getUnchecked(fooInTheFuture);
- *
- * // call a set of commands that are defined in classpath/functions/function_name.sh
- * ListenableFuture<ExecResponse> kill = factory.submit(host.get(),
- * call("killsession"), runAsRoot(false).wrapInInitScript(false));
- *
- * ...
- *
- * </pre>
- *
- * <h3>Note</h3>
- *
- * People often forget to call {@link Future#get} when using {@link RunScriptOnNode.Factory#submit}.
- * Don't forget!
- */
-public class HardcodeLocalhostAsNodeMetadataSupplier extends AbstractModule {
-
- public static final String HOST_ID = "host";
- public static final String HOSTNAME = Strings.nullToEmpty(System.getenv("HOSTNAME"));
-
- /**
- * Lazy so that we don't hang up the injector reading a file
- */
- @Provides
- @Singleton
- protected Supplier<NodeMetadata> lazySupplyHostAsNodeMetadata() {
- return new Supplier<NodeMetadata>() {
-
- @Override
- public NodeMetadata get() {
- String privateKey = readRsaIdentity();
- return new NodeMetadataBuilder()
- .id(HOST_ID)
- .name("host installing virtualbox")
- .hostname(HOSTNAME)
- .operatingSystem(OperatingSystem.builder()
- .family(OsFamily.LINUX)
- .description(System.getProperty("os.name"))
- .arch(System.getProperty("os.arch"))
- .version(System.getProperty("os.version"))
- .build())
- .status(Status.RUNNING)
- .location(new LocationBuilder().id(HOST_ID)
- .scope(LocationScope.HOST)
- .description(HOSTNAME)
- .build())
- .credentials(LoginCredentials.builder()
- .user(System.getProperty("user.name"))
- .privateKey(privateKey)
- .build())
- .build();
- }
-
- };
- }
-
- static String readRsaIdentity() {
- String privateKey;
- try {
- File keyFile = new File(System.getProperty("user.home") + "/.ssh/id_rsa");
- privateKey = Files.toString(keyFile, Charsets.UTF_8);
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- return privateKey;
- }
-
- @Override
- protected void configure() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java
deleted file mode 100644
index 0f4c5ed..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox.config;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.jclouds.util.Predicates2.retry;
-
-import java.io.File;
-import java.net.URI;
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.eclipse.jetty.server.Server;
-import org.jclouds.compute.ComputeServiceAdapter;
-import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
-import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
-import org.jclouds.domain.Location;
-import org.jclouds.functions.IdentityFunction;
-import org.jclouds.ssh.SshClient;
-import org.jclouds.virtualbox.compute.VirtualBoxComputeServiceAdapter;
-import org.jclouds.virtualbox.compute.extensions.VirtualBoxImageExtension;
-import org.jclouds.virtualbox.domain.CloneSpec;
-import org.jclouds.virtualbox.domain.ExecutionType;
-import org.jclouds.virtualbox.domain.IsoSpec;
-import org.jclouds.virtualbox.domain.Master;
-import org.jclouds.virtualbox.domain.MasterSpec;
-import org.jclouds.virtualbox.domain.NodeSpec;
-import org.jclouds.virtualbox.domain.YamlImage;
-import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
-import org.jclouds.virtualbox.functions.CreateAndInstallVm;
-import org.jclouds.virtualbox.functions.IMachineToHardware;
-import org.jclouds.virtualbox.functions.IMachineToImage;
-import org.jclouds.virtualbox.functions.IMachineToNodeMetadata;
-import org.jclouds.virtualbox.functions.IMachineToSshClient;
-import org.jclouds.virtualbox.functions.MastersLoadingCache;
-import org.jclouds.virtualbox.functions.NodeCreator;
-import org.jclouds.virtualbox.functions.YamlImagesFromFileConfig;
-import org.jclouds.virtualbox.functions.admin.FileDownloadFromURI;
-import org.jclouds.virtualbox.functions.admin.ImagesToYamlImagesFromYamlDescriptor;
-import org.jclouds.virtualbox.functions.admin.PreseedCfgServer;
-import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
-import org.jclouds.virtualbox.predicates.SshResponds;
-import org.virtualbox_4_2.IMachine;
-import org.virtualbox_4_2.LockType;
-import org.virtualbox_4_2.MachineState;
-import org.virtualbox_4_2.VirtualBoxManager;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Injector;
-import com.google.inject.Provides;
-import com.google.inject.TypeLiteral;
-
-@SuppressWarnings("unchecked")
-public class VirtualBoxComputeServiceContextModule extends
- ComputeServiceAdapterContextModule<IMachine, Hardware, Image, Location> {
-
- @Override
- protected void configure() {
- super.configure();
- bind(new TypeLiteral<ComputeServiceAdapter<IMachine, Hardware, Image, Location>>() {
- }).to(VirtualBoxComputeServiceAdapter.class);
- bind(new TypeLiteral<Function<IMachine, NodeMetadata>>() {
- }).to(IMachineToNodeMetadata.class);
- bind(new TypeLiteral<Function<Location, Location>>() {
- }).to(Class.class.cast(IdentityFunction.class));
- bind(new TypeLiteral<Function<Hardware, Hardware>>() {
- }).to(Class.class.cast(IdentityFunction.class));
- bind(new TypeLiteral<Function<Image, Image>>() {
- }).to(Class.class.cast(IdentityFunction.class));
- bind(new TypeLiteral<Function<IMachine, Hardware>>() {
- }).to(IMachineToHardware.class);
- bind(new TypeLiteral<Function<IMachine, Image>>() {
- }).to(IMachineToImage.class);
- bind(new TypeLiteral<CacheLoader<IsoSpec, URI>>() {
- }).to(Class.class.cast(PreseedCfgServer.class));
- bind(new TypeLiteral<Function<URI, File>>() {
- }).to(Class.class.cast(FileDownloadFromURI.class));
-
- bind(new TypeLiteral<Supplier<VirtualBoxManager>>() {
- }).to(Class.class.cast(StartVBoxIfNotAlreadyRunning.class));
- // the yaml config to image mapper
- bind(new TypeLiteral<Supplier<Map<Image, YamlImage>>>() {
- }).to(Class.class.cast(ImagesToYamlImagesFromYamlDescriptor.class));
- // the yaml config provider
- bind(YamlImagesFromFileConfig.class);
-
- // the master machines cache
- bind(new TypeLiteral<LoadingCache<Image, Master>>() {
- }).to(MastersLoadingCache.class);
-
- // the vbox image extension
- bind(new TypeLiteral<ImageExtension>() {
- }).to(VirtualBoxImageExtension.class);
-
- // the master creating function
- bind(new TypeLiteral<Function<MasterSpec, IMachine>>() {
- }).to(Class.class.cast(CreateAndInstallVm.class));
- // the machine cloning function
- bind(new TypeLiteral<Function<NodeSpec, NodeAndInitialCredentials<IMachine>>>() {
- }).to(Class.class.cast(NodeCreator.class));
- bind(new TypeLiteral<Function<CloneSpec, IMachine>>() {
- }).to(Class.class.cast(CloneAndRegisterMachineFromIMachineIfNotAlreadyExists.class));
- // the jetty server provider
- bind(new TypeLiteral<Server>() {
- }).to(Class.class.cast(PreseedCfgServer.class)).asEagerSingleton();
-
- bind(new TypeLiteral<Function<IMachine, SshClient>>() {
- }).to(IMachineToSshClient.class);
-
- bind(ExecutionType.class).toInstance(ExecutionType.HEADLESS);
- bind(LockType.class).toInstance(LockType.Write);
- }
-
- @Provides
- @Singleton
- protected Function<Supplier<NodeMetadata>, VirtualBoxManager> provideVBox() {
- return new Function<Supplier<NodeMetadata>, VirtualBoxManager>() {
-
- @Override
- public VirtualBoxManager apply(Supplier<NodeMetadata> nodeSupplier) {
- if (nodeSupplier.get().getId() != null)
- return VirtualBoxManager.createInstance(nodeSupplier.get().getId());
-
- return VirtualBoxManager.createInstance("");
- }
-
- @Override
- public String toString() {
- return "createInstanceByNodeId()";
- }
-
- };
- }
-
- @Provides
- @Singleton
- protected Predicate<SshClient> sshResponds(SshResponds sshResponds, Timeouts timeouts) {
- return retry(sshResponds, timeouts.nodeRunning, 500l, MILLISECONDS);
- }
-
- @Override
- protected Optional<ImageExtension> provideImageExtension(Injector i) {
- return Optional.of(i.getInstance(ImageExtension.class));
- }
-
- @VisibleForTesting
- public static final Map<MachineState, NodeMetadata.Status> toPortableNodeStatus = ImmutableMap
- .<MachineState, NodeMetadata.Status> builder().put(MachineState.Running, NodeMetadata.Status.RUNNING)
- .put(MachineState.PoweredOff, NodeMetadata.Status.SUSPENDED)
- .put(MachineState.DeletingSnapshot, NodeMetadata.Status.PENDING)
- .put(MachineState.DeletingSnapshotOnline, NodeMetadata.Status.PENDING)
- .put(MachineState.DeletingSnapshotPaused, NodeMetadata.Status.PENDING)
- .put(MachineState.FaultTolerantSyncing, NodeMetadata.Status.PENDING)
- .put(MachineState.LiveSnapshotting, NodeMetadata.Status.PENDING)
- .put(MachineState.SettingUp, NodeMetadata.Status.PENDING)
- .put(MachineState.Starting, NodeMetadata.Status.PENDING)
- .put(MachineState.Stopping, NodeMetadata.Status.PENDING)
- .put(MachineState.Restoring, NodeMetadata.Status.PENDING)
- // TODO What to map these states to?
- .put(MachineState.FirstOnline, NodeMetadata.Status.PENDING)
- .put(MachineState.FirstTransient, NodeMetadata.Status.PENDING)
- .put(MachineState.LastOnline, NodeMetadata.Status.PENDING)
- .put(MachineState.LastTransient, NodeMetadata.Status.PENDING)
- .put(MachineState.Teleported, NodeMetadata.Status.PENDING)
- .put(MachineState.TeleportingIn, NodeMetadata.Status.PENDING)
- .put(MachineState.TeleportingPausedVM, NodeMetadata.Status.PENDING)
- .put(MachineState.Aborted, NodeMetadata.Status.ERROR)
- .put(MachineState.Stuck, NodeMetadata.Status.ERROR)
- .put(MachineState.Null, NodeMetadata.Status.TERMINATED).build();
-
- @Singleton
- @Provides
- protected Map<MachineState, NodeMetadata.Status> toPortableNodeStatus() {
- return toPortableNodeStatus;
- }
-
- @VisibleForTesting
- public static final Map<MachineState, Image.Status> toPortableImageStatus = ImmutableMap
- .<MachineState, Image.Status> builder().put(MachineState.Running, Image.Status.PENDING)
- .put(MachineState.PoweredOff, Image.Status.AVAILABLE)
- .put(MachineState.DeletingSnapshot, Image.Status.PENDING)
- .put(MachineState.DeletingSnapshotOnline, Image.Status.PENDING)
- .put(MachineState.DeletingSnapshotPaused, Image.Status.PENDING)
- .put(MachineState.FaultTolerantSyncing, Image.Status.PENDING)
- .put(MachineState.LiveSnapshotting, Image.Status.PENDING)
- .put(MachineState.SettingUp, Image.Status.PENDING)
- .put(MachineState.Starting, Image.Status.PENDING)
- .put(MachineState.Stopping, Image.Status.PENDING)
- .put(MachineState.Restoring, Image.Status.PENDING)
- // TODO What to map these states to?
- .put(MachineState.FirstOnline, Image.Status.PENDING)
- .put(MachineState.FirstTransient, Image.Status.PENDING)
- .put(MachineState.LastOnline, Image.Status.PENDING)
- .put(MachineState.LastTransient, Image.Status.PENDING)
- .put(MachineState.Teleported, Image.Status.PENDING)
- .put(MachineState.TeleportingIn, Image.Status.PENDING)
- .put(MachineState.TeleportingPausedVM, Image.Status.PENDING)
- .put(MachineState.Aborted, Image.Status.ERROR)
- .put(MachineState.Stuck, Image.Status.ERROR)
- .put(MachineState.Null, Image.Status.DELETED).build();
-
- @Singleton
- @Provides
- protected Map<MachineState, Image.Status> toPortableImageStatus() {
- return toPortableImageStatus;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/75178c77/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxConstants.java
----------------------------------------------------------------------
diff --git a/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxConstants.java b/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxConstants.java
deleted file mode 100644
index 322bb83..0000000
--- a/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxConstants.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.virtualbox.config;
-
-import java.io.File;
-
-/**
- * Configuration properties used for interacting with VirtualBox instances.
- */
-public final class VirtualBoxConstants {
-
- public static final String VIRTUALBOX_NODE_NAME_SEPARATOR = "-0x0-";
-
- public static final String VIRTUALBOX_IMAGE_PREFIX = "jclouds-image" + VIRTUALBOX_NODE_NAME_SEPARATOR;
-
- public static final String VIRTUALBOX_NODE_PREFIX = "jclouds-node" + VIRTUALBOX_NODE_NAME_SEPARATOR;
-
- public static final String VIRTUALBOX_PRECONFIGURATION_URL = "jclouds.virtualbox.preconfigurationurl";
-
- public static final String VIRTUALBOX_WORKINGDIR = "jclouds.virtualbox.workingdir";
-
- public static final String VIRTUALBOX_IMAGES_DESCRIPTOR = "jclouds.virtualbox.image.descriptor.yaml";
-
- public static final String VIRTUALBOX_MACHINE_GROUP = "jclouds.virtualbox.machinegroup";
-
- public static final String VIRTUALBOX_MACHINE_USERNAME = "jclouds.virtualbox.username";
-
- public static final String VIRTUALBOX_MACHINE_CREDENTIAL = "jclouds.virtualbox.credential";
-
- public static final String VIRTUALBOX_MACHINE_LOCATION = "jclouds.virtualbox.location";
-
- public static final String VIRTUALBOX_GUEST_MEMORY = "jclouds.virtualbox.guest.memory";
-
- public static final String VIRTUALBOX_HOST_ID = "jclouds.virtualbox.hostid";
-
- public static final String VIRTUALBOX_WEBSERVER_IDENTITY = "jclouds.virtualbox.webserver.identity";
-
- public static final String VIRTUALBOX_WEBSERVER_CREDENTIAL = "jclouds.virtualbox.webserver.credential";
-
- public static final String VIRTUALBOX_DEFAULT_DIR = System.getProperty("user.home") + File.separator
- + ".jclouds-vbox";
-
- public static final String VIRTUALBOX_PROVIDER = "virtualbox";
-
- public static final String GUEST_OS_PASSWORD = "guestPassword";
-
- public static final String GUEST_OS_USER = "guestUser";
-
- private VirtualBoxConstants() {
- throw new AssertionError("intentionally unimplemented");
- }
-}