Skip to content

Commit

Permalink
Fix machine.clj, session.clj, virtualbox.clj and condition.clj re:
Browse files Browse the repository at this point in the history
breaking changes in VirtualBox SDK 4.0
    - Adapt conditions.clj adapters to the new exception hierarchy
    - Make status logs to be of category 'trace'
    - Replace is* methods for get* methods in VBox object attributes
    - Rebuild session wrapper macros: now there is not a direct and a
    remote session wrappers. There is just one session wrapper that
    can wither be of type :write or :shared
    - Update machine methods to use the new methods, sometimes in
    other objects than originally (what a mess!)
    - Write integration test for session.clj
  • Loading branch information
tbatchelli committed Feb 8, 2011
1 parent 6361bc6 commit 4f20ec1
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 106 deletions.
24 changes: 18 additions & 6 deletions src/vmfest/virtualbox/conditions.clj
Expand Up @@ -5,7 +5,8 @@
InvalidObjectFault
InvalidObjectFaultMsg
RuntimeFault
RuntimeFaultMsg]))
RuntimeFaultMsg]
[org.virtualbox_4_0 VBoxException]))

(defn unsigned-int-to-long [ui]
(bit-and (long ui) 0xffffffff))
Expand Down Expand Up @@ -39,25 +40,36 @@
(extend-protocol fault
java.lang.Exception
(as-map [this]
(log/warn (format "Processing exception %s as a java.lang.Exception. Cause %s" (class this) (.getCause this)))
(log/warn
(format "Processing exception %s as a java.lang.Exception. Cause %s"
(class this)
(.getCause this)))
{:original-message (.getMessage this)
:cause (.getCause this)
:type :exception
})
:type :exception})
java.net.ConnectException
(as-map [this]
{:type :connection-error})
com.sun.xml.internal.ws.client.ClientTransportException
(as-map [this]
{:type :connection-error})
VBoxException
(as-map [this]
(let [message (.getMessage this)
wrapped (.getWrapped this)]
(merge
(when wrapped (as-map wrapped))
{:message message})))
RuntimeFaultMsg
(as-map [this]
(let [message (.getMessage this)
info (try (.getFaultInfo this)
(catch Exception e)) ;; runtime fault
interface-id (when info (.getInterfaceID info))
component (when info (.getComponent info))
result-code (when info (unsigned-int-to-long (int (.getResultCode info)))) ;; originally an unsigned int
result-code (when info
(unsigned-int-to-long
(int (.getResultCode info))))
text (when info (.getText info))]
{:type :vbox-runtime
:original-message message
Expand Down Expand Up @@ -92,7 +104,7 @@
(defn wrap-vbox-runtime [e error-condition-map & default-condition-map]
(let [condition (condition-from-webservice-exception e)
error-type (:original-error-type condition)
condition-map (error-type error-condition-map) ;; the map corresponding to the error type
condition-map (error-type error-condition-map)
merged-condition (merge default-condition-map condition-map)]
(log-and-raise e merged-condition)))

Expand Down
28 changes: 16 additions & 12 deletions src/vmfest/virtualbox/guest_os_type.clj
Expand Up @@ -10,23 +10,27 @@
:family-description (.getFamilyDescription o)
:id (.getId o)
:description (.getDescription o)
:64-bit? (.isIs64Bit o)
:recommended-io-apic? (.isRecommendedIOAPIC o)
:recommended-virt-ex? (.isRecommendedVirtEx o)
:64-bit? (.getIs64Bit o)
:recommended-io-apic? (.getRecommendedIOAPIC o)
:recommended-virt-ex? (.getRecommendedVirtEx o)
:recommended-ram (.getRecommendedRAM o)
:recommended-vram (.getRecommendedVRAM o)
:recommended-hdd (.getRecommendedHDD o)
:adapter-type (.getAdapterType o) ;todo: pull the object
:recommended-pae? (.isRecommendedPae o)
:recommended-dvd-storage-controller (.getRecommendedDvdStorageController o) ;todo: pull object
:recommended-dvd-storage-bus (.getRecommendedDvdStorageBus o) ;todo: pull object
:recommended-hd-storage-controller (.getRecommendedHdStorageController o) ;todo: pull object
:recommended-hd-storage-bus (.getRecommendedHdStorageBus o) ;todo: pull object
:recommended-pae? (.getRecommendedPae o)
:recommended-dvd-storage-controller
(.getRecommendedDvdStorageController o) ;todo: pull object
:recommended-dvd-storage-bus
(.getRecommendedDvdStorageBus o) ;todo: pull object
:recommended-hd-storage-controller
(.getRecommendedHdStorageController o) ;todo: pull object
:recommended-hd-storage-bus
(.getRecommendedHdStorageBus o) ;todo: pull object
:recommended-firmware (.getRecommendedFirmware o) ;todo: pull object
:recommended-usb-hid? (.isRecommendedUsbHid o)
:recommended-hpet? (.isRecommendedHpet o)
:recommended-usb-tablet? (.isRecommendedUsbTablet o)
:recommended-rtc-use-utc? (.isRecommendedRtcUseUtc o)
:recommended-usb-hid? (.getRecommendedUsbHid o)
:recommended-hpet? (.getRecommendedHpet o)
:recommended-usb-tablet? (.getRecommendedUsbTablet o)
:recommended-rtc-use-utc? (.getRecommendedRtcUseUtc o)
})


Expand Down

0 comments on commit 4f20ec1

Please sign in to comment.