virtualbox-ws 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +33 -0
- data/README.md +39 -0
- data/lib/virtualbox/classes/i_bios_settings.rb +7 -0
- data/lib/virtualbox/classes/i_console.rb +16 -0
- data/lib/virtualbox/classes/i_host.rb +15 -0
- data/lib/virtualbox/classes/i_host_network_interface.rb +9 -0
- data/lib/virtualbox/classes/i_machine.rb +40 -0
- data/lib/virtualbox/classes/i_managed_object_ref.rb +6 -0
- data/lib/virtualbox/classes/i_medium.rb +13 -0
- data/lib/virtualbox/classes/i_medium_format.rb +6 -0
- data/lib/virtualbox/classes/i_network_adapter.rb +12 -0
- data/lib/virtualbox/classes/i_session.rb +6 -0
- data/lib/virtualbox/classes/i_system_properties.rb +18 -0
- data/lib/virtualbox/classes/i_virtualbox.rb +17 -0
- data/lib/virtualbox/classes/i_web_session_manager.rb +21 -0
- data/lib/virtualbox/connection.rb +43 -0
- data/lib/virtualbox/core_ext/string.rb +9 -0
- data/lib/virtualbox/enumerations.rb +6 -0
- data/lib/virtualbox/i_base.rb +51 -0
- data/lib/virtualbox-ws.rb +6 -0
- data/virtualbox-ws.gemspec +16 -0
- metadata +81 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: c19d181323956fc9c6a21c66e82471f872f5f09c
         | 
| 4 | 
            +
              data.tar.gz: 14ef98271b843289e6d4fcbdc893971ba941a8f9
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 2244297783f0448236657edd24e391d0c70fb68b1d8437a37dfbc14374d7f5c0c235cfd118440532cb4a323edfd2c6c6b8ed0841968c6ad2afb6bd640ee95145
         | 
| 7 | 
            +
              data.tar.gz: db8aa2318dbefec7af12b7e18b1d1b98675d471976f5c3d502373f2ffb729fb0e49ec21390f5d2cdaf8d6d9fea712a0f390e192b9d1ac996071521577cd311c5
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            .idea
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            GEM
         | 
| 2 | 
            +
              remote: https://rubygems.org/
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                akami (1.2.0)
         | 
| 5 | 
            +
                  gyoku (>= 0.4.0)
         | 
| 6 | 
            +
                  nokogiri (>= 1.4.0)
         | 
| 7 | 
            +
                builder (3.2.2)
         | 
| 8 | 
            +
                gyoku (1.1.0)
         | 
| 9 | 
            +
                  builder (>= 2.1.2)
         | 
| 10 | 
            +
                httpi (2.1.0)
         | 
| 11 | 
            +
                  rack
         | 
| 12 | 
            +
                  rubyntlm (~> 0.3.2)
         | 
| 13 | 
            +
                nokogiri (1.5.10)
         | 
| 14 | 
            +
                nori (2.3.0)
         | 
| 15 | 
            +
                rack (1.5.2)
         | 
| 16 | 
            +
                rubyntlm (0.3.4)
         | 
| 17 | 
            +
                savon (2.3.0)
         | 
| 18 | 
            +
                  akami (~> 1.2.0)
         | 
| 19 | 
            +
                  builder (>= 2.1.2)
         | 
| 20 | 
            +
                  gyoku (~> 1.1.0)
         | 
| 21 | 
            +
                  httpi (~> 2.1.0)
         | 
| 22 | 
            +
                  nokogiri (>= 1.4.0, < 1.6)
         | 
| 23 | 
            +
                  nori (~> 2.3.0)
         | 
| 24 | 
            +
                  wasabi (~> 3.2.0)
         | 
| 25 | 
            +
                wasabi (3.2.0)
         | 
| 26 | 
            +
                  httpi (~> 2.0)
         | 
| 27 | 
            +
                  nokogiri (>= 1.4.0, < 1.6)
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            PLATFORMS
         | 
| 30 | 
            +
              ruby
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            DEPENDENCIES
         | 
| 33 | 
            +
              savon
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            Usage
         | 
| 2 | 
            +
            -----
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            First connect to vboxwebsrv service
         | 
| 5 | 
            +
            ```
         | 
| 6 | 
            +
            irb> VirtualBoxWS.connect
         | 
| 7 | 
            +
             => true
         | 
| 8 | 
            +
            ```
         | 
| 9 | 
            +
            By default it connects to `http://127.0.0.1:18083` but host and port parameters can be passed to the connect method
         | 
| 10 | 
            +
            explicitly
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            To operate on the VirtualBox Web Service you need to logon to it.
         | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
            irb> web_session = VirtualBoxWS::IWebsessionManager.new
         | 
| 15 | 
            +
             => #<VirtualBoxWS::IWebsessionManager:0x0000000383b9b0 @_this={}>
         | 
| 16 | 
            +
            irb> key = web_session.logon(:username => 'john', :password => 'doe')
         | 
| 17 | 
            +
             => "deb9086e1f72ddbf-0000000000000002"
         | 
| 18 | 
            +
            ```
         | 
| 19 | 
            +
            Having a key we can now create an instance of IVirtualBox class, which is basically the entry point for the whole
         | 
| 20 | 
            +
            VirtualBox operations scope.
         | 
| 21 | 
            +
            ```
         | 
| 22 | 
            +
            irb> i_virtualbox = VirtualBoxWS::IVirtualBox.new(key)
         | 
| 23 | 
            +
             => #<VirtualBoxWS::IVirtualBox:0x0000000352a028 @_this={:_this=>"deb9086e1f72ddbf-0000000000000002"}>
         | 
| 24 | 
            +
            ```
         | 
| 25 | 
            +
            Now having an IVirtualBox we are ready to do something useful. The following will create a very basic virtual machine
         | 
| 26 | 
            +
            ```
         | 
| 27 | 
            +
            irb> machine = i_virtualbox.create_machine(:name => 'JohnDoe')
         | 
| 28 | 
            +
             => "deb9086e1f72ddbf-0000000000000003"
         | 
| 29 | 
            +
            irb> i_virtualbox.register_machine(:machine => machine)
         | 
| 30 | 
            +
             => nil
         | 
| 31 | 
            +
            ```
         | 
| 32 | 
            +
            To start the machine we've just created we first need to create an instance of IMachine passing it our machine's
         | 
| 33 | 
            +
            object reference. After that we are able to execute launch_vm_process on this instance
         | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
            irb> i_machine = VirtualBoxWS::IMachine.new(machine)
         | 
| 36 | 
            +
             => #<VirtualBoxWS::IMachine:0x000000047fdee8 @_this={:_this=>"deb9086e1f72ddbf-0000000000000003"}>
         | 
| 37 | 
            +
            irb> i_machine.launch_vm_process(:session => web_session.get_session_object, :type => 'gui')
         | 
| 38 | 
            +
             => "deb9086e1f72ddbf-0000000000000004"
         | 
| 39 | 
            +
            ```
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IConsole < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :machine, :state, :guest, :keyboard, :mouse, :display, :debugger, :usb_devices, :remote_usb_devices,
         | 
| 5 | 
            +
                               :shared_folders, :vrde_server_info, :event_source, :attached_pci_devices
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                vb_attr_accessor :use_host_clipboard
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                vb_method :adopt_saved_state, :attach_usb_device, :create_shared_folder, :delete_snapshot,
         | 
| 10 | 
            +
                          :delete_snapshot_and_all_children, :delete_snapshot_range, :detach_usb_device, :discard_saved_state,
         | 
| 11 | 
            +
                          :find_usb_device_by_address, :find_usb_device_by_id, :get_device_activity, :get_guest_entered_acpi_mode,
         | 
| 12 | 
            +
                          :get_power_button_handled, :pause, :power_button, :power_down, :power_up, :power_up_paused,
         | 
| 13 | 
            +
                          :remove_shared_folder, :reset, :restore_snapshot, :resume, :save_state, :sleep_button, :take_snapshot,
         | 
| 14 | 
            +
                          :teleport
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IHost < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :dvd_drives, :floppy_drives, :usb_devices, :usb_devices_filters, :network_interfaces,
         | 
| 5 | 
            +
                               :processor_count, :processor_online_count, :processor_core_count, :memory_size, :memory_available,
         | 
| 6 | 
            +
                               :operating_system, :os_version, :utc_time, :accleration_3d_available
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                vb_method :create_host_only_network_interface, :create_usb_device_filter, :find_host_dvd_drive,
         | 
| 9 | 
            +
                          :find_host_floppy_drive, :find_host_network_interface_by_id, :find_host_network_interface_by_name,
         | 
| 10 | 
            +
                          :find_host_network_interfaces_of_type, :find_usb_device_by_address, :find_usb_device_by_id,
         | 
| 11 | 
            +
                          :generate_mac_address, :get_processof_cpuid_leaf, :get_processor_description, :get_processor_feature,
         | 
| 12 | 
            +
                          :get_processor_speed, :insert_usb_device_filter, :remove_host_only_network_interface,
         | 
| 13 | 
            +
                          :remove_usb_device_filter
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IHostNetworkInterface < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :name, :id, :network_name, :dhcp_enabled, :ip_address, :network_mask, :ipv6_supported, :ipv6_address,
         | 
| 5 | 
            +
                               :ipv6_network_mask_prefix_length, :hardware_address, :medium_type, :status, :interface_type
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                vb_method :dycp_rediscover, :enable_dynamic_ip_config, :enable_static_ip_config, :enable_static_ip_config_v6
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IMachine < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :parent, :accessible, :access_error, :id, :bios_settings, :vrde_server, :medium_attachments,
         | 
| 5 | 
            +
                               :usb_controller, :audio_adapter, :storage_controllers, :settings_file_path, :settings_modified,
         | 
| 6 | 
            +
                               :session_state, :session_type, :sessio_pid, :state, :last_state_change, :state_file_path,
         | 
| 7 | 
            +
                               :log_folder, :current_snapshot, :snaphot_count, :current_state_modified, :shared_folders,
         | 
| 8 | 
            +
                               :pci_devices_assignments, :bandwidth_control
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                vb_attr_accessor :name, :description, :groups, :os_type_id, :hardware_version, :hardware_uuid, :cpu_count,
         | 
| 11 | 
            +
                                 :cpu_hot_plug_enabled, :cpu_execution_cap, :memory_size, :memory_balloon_size,
         | 
| 12 | 
            +
                                 :page_fusion_enabled, :vram_size, :accelerate_3d_enabled, :accelerate_2d_video_enabled,
         | 
| 13 | 
            +
                                 :monitor_count, :video_capture_enabled, :video_capture_file, :video_capture_width,
         | 
| 14 | 
            +
                                 :video_capture_height, :firmware_type, :pointing_hid_type, :keyboard_hid_type, :hpet_enabled,
         | 
| 15 | 
            +
                                 :chipset_type, :snapshot_folder, :emulated_usb_webcamera_enabled,
         | 
| 16 | 
            +
                                 :emulated_usb_card_reader_enabled, :clipboard_mode, :drag_and_drop_mode,
         | 
| 17 | 
            +
                                 :guest_proprty_notificaton_patterns, :teleporter_enabled, :teleporter_port, :teleporter_address,
         | 
| 18 | 
            +
                                 :teleporter_password, :fault_tolerance_state, :fault_tolerance_port, :fault_tolerance_address,
         | 
| 19 | 
            +
                                 :fault_tolerance_password, :fault_tolerance_sync_interval, :rtc_use_utc, :io_cache_enabled,
         | 
| 20 | 
            +
                                 :io_cache_size, :io_cache_size, :tracing_enabled, :tracing_config, :allow_tracing_to_access_vm,
         | 
| 21 | 
            +
                                 :autostart_enabled, :autostart_delay, :autostop_type
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                vb_method :add_storage_controller, :attach_device, :attach_device_without_medium, :attach_host_pci_device,
         | 
| 24 | 
            +
                          :can_show_console_window, :clone_to, :create_shared_folder, :delete, :delete_guest_property,
         | 
| 25 | 
            +
                          :detach_device, :detach_host_pci_device, :discard_settings, :enumerate_guest_properties, :export,
         | 
| 26 | 
            +
                          :find_snapshot, :get_boot_order, :get_cpuid_leaf, :get_cpu_property, :get_cpu_status, :get_extra_data,
         | 
| 27 | 
            +
                          :get_extra_data_keys, :get_guest_property, :get_guest_property_timestamp, :get_guest_property_value,
         | 
| 28 | 
            +
                          :get_hw_virt_ex_property, :get_medium, :get_medium_attachment, :get_medium_attachments_of_controller,
         | 
| 29 | 
            +
                          :get_network_adapter, :get_parallel_port, :get_serial_port, :get_storage_controller_by_instance,
         | 
| 30 | 
            +
                          :get_storage_controller_by_name, :hot_plug_cpu, :hot_unplug_cpu, :launch_vm_process, :lock_machine,
         | 
| 31 | 
            +
                          :mount_medium, :non_rotational_device, :passthrough_device, :query_log_filename,
         | 
| 32 | 
            +
                          :query_saved_guest_screen_info, :query_saved_screnshot_png_size, :query_saved_thumbnail_size, :read_log,
         | 
| 33 | 
            +
                          :read_saved_screenshot_png_to_array, :read_saved_thumbnail_png_to_array, :read_saved_thumbnail_to_array,
         | 
| 34 | 
            +
                          :reamove_all_cpuid_leaves, :remove_cpuid_leaf, :remove_shared_folder, :remove_storage_controller,
         | 
| 35 | 
            +
                          :save_settings, :set_auto_discard_for_device, :set_bandwidth_group_for_device, :set_boot_order,
         | 
| 36 | 
            +
                          :set_cpuid_leaf, :set_cpu_property, :set_extra_data, :set_guest_property, :set_guest_property_value,
         | 
| 37 | 
            +
                          :set_hw_virt_ex_property, :set_no_bandwidth_group_for_device, :set_storage_controller_bootable,
         | 
| 38 | 
            +
                          :show_console_window, :temporary_eject_device, :unmount_medium, :unregister
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IMedium < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :id, :state, :name, :device_type, :host_drive, :size, :format, :medium_format, :allowed_types,
         | 
| 5 | 
            +
                               :parent, :children, :base, :read_only, :logical_size, :last_access_error, :machine_ids
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                vb_attr_accessor :description, :location, :type, :auto_reset
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                vb_method :clone_to, :clone_to_base, :close, :cpmpact, :create_base_storage, :create_diff_storage, :delete_storage,
         | 
| 10 | 
            +
                          :get_properties, :get_property, :get_snapshot_ids, :lock_read, :lock_write, :merge_to, :refresh_state,
         | 
| 11 | 
            +
                          :reset, :resize, :set_ids, :set_properties, :set_property, :unlock_read, :unlock_write
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class INetworkAdapter < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :slot, :nat_engine
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                vb_attr_accessor :adapter_type, :enabled, :mac_address, :attachment_type, :bridged_interface, :host_only_interface,
         | 
| 7 | 
            +
                                 :internal_network, :nat_network, :generic_driver, :cable_connected, :line_speed,
         | 
| 8 | 
            +
                                 :promisc_mode_policy, :trace_enabled, :trace_file, :boot_proirity, :bandwidth_group
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                vb_method :get_properties, :get_property, :set_property
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class ISystemProperties < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :min_guest_ram, :max_guest_ram, :min_guest_vram, :max_guest_vram, :min_guest_cpu_count,
         | 
| 5 | 
            +
                               :max_guest_cpu_count, :max_guest_monitors, :info_vd_size, :serial_port_count, :parallel_port_count,
         | 
| 6 | 
            +
                               :max_boot_position, :meduim_formats, :default_audio_driver
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                vb_attr_accessor :default_machine_folder, :default_hard_disk_format, :free_disk_space_warning,
         | 
| 9 | 
            +
                                 :free_disk_space_percent_warning, :free_disk_space_error, :free_disk_space_percent_error,
         | 
| 10 | 
            +
                                 :vrde_auth_library, :web_service_auth_library, :default_vrde_ext_pack, :log_history_count,
         | 
| 11 | 
            +
                                 :autostart_database_path, :default_additional_iso
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                vb_method :get_default_io_cache_setting_for_storage_controller, :get_device_types_for_storage_bus,
         | 
| 14 | 
            +
                          :get_max_devices_per_port_for_storage_bus, :get_max_instances_of_storage_bus, :get_max_network_adapters,
         | 
| 15 | 
            +
                          :get_max_network_adapters_of_type, :get_max_port_count_for_storage_bus,
         | 
| 16 | 
            +
                          :get_min_port_count_for_storage_bus
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IVirtualBox < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_attr_reader :version, :version_normalized, :revision, :package_type, :api_version, :home_folder,
         | 
| 5 | 
            +
                               :settings_file_path, :host, :system_properties, :machines, :machine_groups, :hard_disks, :dvd_images,
         | 
| 6 | 
            +
                               :floppy_images, :progress_operations, :guest_os_types, :shared_folders, :performance_collector,
         | 
| 7 | 
            +
                               :dhcp_servers, :event_source, :internal_networks, :generic_network_drivers
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                vb_method :check_firmware_present, :compose_machine_filename, :create_appliance, :create_dhcp_server,
         | 
| 10 | 
            +
                          :create_hard_disk, :create_machine, :create_shared_folder, :find_dhcp_server_by_network_name,
         | 
| 11 | 
            +
                          :find_machine, :get_extra_data, :get_extra_data_keys, :get_guest_os_types, :get_machine_states,
         | 
| 12 | 
            +
                          :get_machines_by_groups, :open_machine, :open_medium, :register_machine, :remove_dhcp_server,
         | 
| 13 | 
            +
                          :remove_shared_folder, :set_extra_data, :set_settings_secret
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
             | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              class IWebsessionManager < IBase
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                vb_method :get_session_object
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def initialize(obj_ref=nil)
         | 
| 7 | 
            +
                  super
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def logon(args={})
         | 
| 11 | 
            +
                  key = VirtualBoxWS.send_request(:i_websession_manager_logon, args)
         | 
| 12 | 
            +
                  @_this[:ref_i_virtual_box] = key
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def logoff
         | 
| 16 | 
            +
                  VirtualBoxWS.send_request(:i_websession_manager_logoff, @_this)
         | 
| 17 | 
            +
                  @_this = {}
         | 
| 18 | 
            +
                  nil
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            require 'savon'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            module VirtualBoxWS
         | 
| 5 | 
            +
              class << self
         | 
| 6 | 
            +
                def parse_response(response)
         | 
| 7 | 
            +
                  if response.body[response.body.keys[0]].nil?
         | 
| 8 | 
            +
                    nil
         | 
| 9 | 
            +
                  else
         | 
| 10 | 
            +
                    response.body[response.body.keys[0]][:returnval]
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def send_request(soap_method, soap_message)
         | 
| 15 | 
            +
                  response = @conn.call(soap_method, :message => soap_message)
         | 
| 16 | 
            +
                  parse_response(response)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def connect(host='127.0.0.1', port='18083', debug=false)
         | 
| 20 | 
            +
                  endpoint = "http://#{host}:#{port}"
         | 
| 21 | 
            +
                  wsdl = endpoint + '/?wsdl'
         | 
| 22 | 
            +
                  @conn = Savon.client(:wsdl => wsdl, :endpoint => endpoint, :log => debug, :pretty_print_xml => debug)
         | 
| 23 | 
            +
                  if @conn.operations.include?(:i_websession_manager_logon)
         | 
| 24 | 
            +
                    @debug = debug
         | 
| 25 | 
            +
                    true
         | 
| 26 | 
            +
                  else
         | 
| 27 | 
            +
                    raise "Could not connect to VirtualBox SOAP Web Service at #{endpoint} (No VirtualBox SOAP service found)"
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                rescue Errno::ECONNREFUSED
         | 
| 30 | 
            +
                  raise "Could not connect to VirtualBox SOAP Web Service at #{endpoint} (Connection refused)"
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def debug
         | 
| 34 | 
            +
                  @debug
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                def debug=(debug)
         | 
| 38 | 
            +
                  @debug = debug
         | 
| 39 | 
            +
                  @conn.globals[:log] = debug
         | 
| 40 | 
            +
                  @conn.globals[:pretty_print_xml] = debug
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            module VirtualBoxWS
         | 
| 2 | 
            +
              DEVICE_TYPE = %w(Null Floppy DVD HardDisk Network USB SharedFolder)
         | 
| 3 | 
            +
              NETWORK_ADAPTER_TYPE = %w(Null Am79C970A Am79C973 I82540EM I82543GC I82545EM Virtio)
         | 
| 4 | 
            +
              NETWORK_ATTACHMENT_TYPE = %w(Null NAT Bridged Internal HostOnly Generic)
         | 
| 5 | 
            +
              STORAGE_BUS = %w(Null IDE SATA SCSI Floppy SAS)
         | 
| 6 | 
            +
            end
         | 
| @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/core_ext/string')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            module VirtualBoxWS
         | 
| 5 | 
            +
              class IBase
         | 
| 6 | 
            +
                def initialize(obj_ref)
         | 
| 7 | 
            +
                  @_this = {}
         | 
| 8 | 
            +
                  @_this[:_this] = obj_ref unless obj_ref.nil?
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def self.vb_attr_accessor(*vb_attrs)
         | 
| 12 | 
            +
                  vb_attrs.each do |vb_attr|
         | 
| 13 | 
            +
                    define_method(vb_attr) do
         | 
| 14 | 
            +
                      soap_method = "#{self.class.name.split('::').last.to_underscore}_get_#{vb_attr}".to_sym
         | 
| 15 | 
            +
                      VirtualBoxWS.send_request(soap_method, @_this)
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    define_method("#{vb_attr}=") do |value|
         | 
| 19 | 
            +
                      soap_method = "#{self.class.name.split('::').last.to_underscore}_set_#{vb_attr}".to_sym
         | 
| 20 | 
            +
                      # A hack for tags that start with an uppercase character
         | 
| 21 | 
            +
                      if vb_attr == :ioapic_enabled
         | 
| 22 | 
            +
                        soap_message = {'IOAPICEnabled' => value}
         | 
| 23 | 
            +
                      elsif vb_attr == :cpu_count
         | 
| 24 | 
            +
                        soap_message = {'CPUCount' => value}
         | 
| 25 | 
            +
                      else
         | 
| 26 | 
            +
                        soap_message = {vb_attr => value}
         | 
| 27 | 
            +
                      end
         | 
| 28 | 
            +
                      VirtualBoxWS.send_request(soap_method, @_this.merge(soap_message))
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def self.vb_attr_reader(*vb_attrs)
         | 
| 34 | 
            +
                  vb_attrs.each do |vb_attr|
         | 
| 35 | 
            +
                    define_method(vb_attr) do
         | 
| 36 | 
            +
                      soap_method = "#{self.class.name.split('::').last.to_underscore}_get_#{vb_attr}".to_sym
         | 
| 37 | 
            +
                      VirtualBoxWS.send_request(soap_method, @_this)
         | 
| 38 | 
            +
                    end
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                def self.vb_method(*vb_meths)
         | 
| 43 | 
            +
                  vb_meths.each do |vb_meth|
         | 
| 44 | 
            +
                    define_method(vb_meth) do |message={}|
         | 
| 45 | 
            +
                      soap_method = "#{self.class.name.split('::').last.to_underscore}_#{vb_meth}".to_sym
         | 
| 46 | 
            +
                      VirtualBoxWS.send_request(soap_method, @_this.merge(message))
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
            end
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/virtualbox/connection')
         | 
| 2 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/virtualbox/i_base')
         | 
| 3 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/virtualbox/enumerations')
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            classes_dir = File.expand_path(File.dirname(__FILE__)) + '/virtualbox/classes/*.rb'
         | 
| 6 | 
            +
            Dir[classes_dir].each { |file| require file }
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            Gem::Specification.new do |s|
         | 
| 2 | 
            +
              s.name = "virtualbox-ws"
         | 
| 3 | 
            +
              s.version = '0.0.1'
         | 
| 4 | 
            +
              s.platform = Gem::Platform::RUBY
         | 
| 5 | 
            +
              s.authors = ['Andriy Yurchuk']
         | 
| 6 | 
            +
              s.email = ['ayurchuk@minuteware.net']
         | 
| 7 | 
            +
              s.homepage = 'https://github.com/Ch00k/virtualbox-ws'
         | 
| 8 | 
            +
              s.summary = 'VirtualBox SOAP API wrapper'
         | 
| 9 | 
            +
              s.description = 'API wrapper that makes using VirtualBox SOAP API (relatively) easier'
         | 
| 10 | 
            +
              s.license = 'MIT'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              s.add_dependency 'savon'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              s.files = `git ls-files`.split("\n")
         | 
| 15 | 
            +
              s.require_path = 'lib'
         | 
| 16 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,81 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: virtualbox-ws
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Andriy Yurchuk
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2013-10-04 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: savon
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - '>='
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - '>='
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            description: API wrapper that makes using VirtualBox SOAP API (relatively) easier
         | 
| 28 | 
            +
            email:
         | 
| 29 | 
            +
            - ayurchuk@minuteware.net
         | 
| 30 | 
            +
            executables: []
         | 
| 31 | 
            +
            extensions: []
         | 
| 32 | 
            +
            extra_rdoc_files: []
         | 
| 33 | 
            +
            files:
         | 
| 34 | 
            +
            - .gitignore
         | 
| 35 | 
            +
            - Gemfile
         | 
| 36 | 
            +
            - Gemfile.lock
         | 
| 37 | 
            +
            - README.md
         | 
| 38 | 
            +
            - lib/virtualbox-ws.rb
         | 
| 39 | 
            +
            - lib/virtualbox/classes/i_bios_settings.rb
         | 
| 40 | 
            +
            - lib/virtualbox/classes/i_console.rb
         | 
| 41 | 
            +
            - lib/virtualbox/classes/i_host.rb
         | 
| 42 | 
            +
            - lib/virtualbox/classes/i_host_network_interface.rb
         | 
| 43 | 
            +
            - lib/virtualbox/classes/i_machine.rb
         | 
| 44 | 
            +
            - lib/virtualbox/classes/i_managed_object_ref.rb
         | 
| 45 | 
            +
            - lib/virtualbox/classes/i_medium.rb
         | 
| 46 | 
            +
            - lib/virtualbox/classes/i_medium_format.rb
         | 
| 47 | 
            +
            - lib/virtualbox/classes/i_network_adapter.rb
         | 
| 48 | 
            +
            - lib/virtualbox/classes/i_session.rb
         | 
| 49 | 
            +
            - lib/virtualbox/classes/i_system_properties.rb
         | 
| 50 | 
            +
            - lib/virtualbox/classes/i_virtualbox.rb
         | 
| 51 | 
            +
            - lib/virtualbox/classes/i_web_session_manager.rb
         | 
| 52 | 
            +
            - lib/virtualbox/connection.rb
         | 
| 53 | 
            +
            - lib/virtualbox/core_ext/string.rb
         | 
| 54 | 
            +
            - lib/virtualbox/enumerations.rb
         | 
| 55 | 
            +
            - lib/virtualbox/i_base.rb
         | 
| 56 | 
            +
            - virtualbox-ws.gemspec
         | 
| 57 | 
            +
            homepage: https://github.com/Ch00k/virtualbox-ws
         | 
| 58 | 
            +
            licenses:
         | 
| 59 | 
            +
            - MIT
         | 
| 60 | 
            +
            metadata: {}
         | 
| 61 | 
            +
            post_install_message: 
         | 
| 62 | 
            +
            rdoc_options: []
         | 
| 63 | 
            +
            require_paths:
         | 
| 64 | 
            +
            - lib
         | 
| 65 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
              requirements:
         | 
| 67 | 
            +
              - - '>='
         | 
| 68 | 
            +
                - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                  version: '0'
         | 
| 70 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
              requirements:
         | 
| 72 | 
            +
              - - '>='
         | 
| 73 | 
            +
                - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                  version: '0'
         | 
| 75 | 
            +
            requirements: []
         | 
| 76 | 
            +
            rubyforge_project: 
         | 
| 77 | 
            +
            rubygems_version: 2.1.4
         | 
| 78 | 
            +
            signing_key: 
         | 
| 79 | 
            +
            specification_version: 4
         | 
| 80 | 
            +
            summary: VirtualBox SOAP API wrapper
         | 
| 81 | 
            +
            test_files: []
         |