Clean up syntax and force string type when setting integration option

This commit is contained in:
Chris Roberts 2018-05-25 10:11:05 -07:00
parent beacb5bada
commit 2bd6f537ef
1 changed files with 17 additions and 17 deletions

View File

@ -77,14 +77,14 @@ module VagrantPlugins
# #
# @return [Hash<state, status>] # @return [Hash<state, status>]
def get_current_state def get_current_state
execute(:get_vm_status, { VmId: vm_id }) execute(:get_vm_status, VmId: vm_id)
end end
# Delete the VM # Delete the VM
# #
# @return [nil] # @return [nil]
def delete_vm def delete_vm
execute(:delete_vm, { VmId: vm_id }) execute(:delete_vm, VmId: vm_id)
end end
# Export the VM to the given path # Export the VM to the given path
@ -92,49 +92,49 @@ module VagrantPlugins
# @param [String] path Path for export # @param [String] path Path for export
# @return [nil] # @return [nil]
def export(path) def export(path)
execute(:export_vm, {VmId: vm_id, Path: path}) execute(:export_vm, VmId: vm_id, Path: path)
end end
# Get the IP address of the VM # Get the IP address of the VM
# #
# @return [Hash<ip>] # @return [Hash<ip>]
def read_guest_ip def read_guest_ip
execute(:get_network_config, { VmId: vm_id }) execute(:get_network_config, VmId: vm_id)
end end
# Get the MAC address of the VM # Get the MAC address of the VM
# #
# @return [Hash<mac>] # @return [Hash<mac>]
def read_mac_address def read_mac_address
execute(:get_network_mac, { VmId: vm_id }) execute(:get_network_mac, VmId: vm_id)
end end
# Resume the VM from suspension # Resume the VM from suspension
# #
# @return [nil] # @return [nil]
def resume def resume
execute(:resume_vm, { VmId: vm_id }) execute(:resume_vm, VmId: vm_id)
end end
# Start the VM # Start the VM
# #
# @return [nil] # @return [nil]
def start def start
execute(:start_vm, { VmId: vm_id }) execute(:start_vm, VmId: vm_id )
end end
# Stop the VM # Stop the VM
# #
# @return [nil] # @return [nil]
def stop def stop
execute(:stop_vm, { VmId: vm_id }) execute(:stop_vm, VmId: vm_id)
end end
# Suspend the VM # Suspend the VM
# #
# @return [nil] # @return [nil]
def suspend def suspend
execute(:suspend_vm, { VmId: vm_id }) execute(:suspend_vm, VmId: vm_id)
end end
# Import a new VM # Import a new VM
@ -150,7 +150,7 @@ module VagrantPlugins
# @param [String] vlan_id VLAN ID # @param [String] vlan_id VLAN ID
# @return [nil] # @return [nil]
def net_set_vlan(vlan_id) def net_set_vlan(vlan_id)
execute(:set_network_vlan, { VmId: vm_id, VlanId: vlan_id }) execute(:set_network_vlan, VmId: vm_id, VlanId: vlan_id)
end end
# Set the VM adapter MAC address # Set the VM adapter MAC address
@ -158,7 +158,7 @@ module VagrantPlugins
# @param [String] mac_addr MAC address # @param [String] mac_addr MAC address
# @return [nil] # @return [nil]
def net_set_mac(mac_addr) def net_set_mac(mac_addr)
execute(:set_network_mac, { VmId: vm_id, Mac: mac_addr }) execute(:set_network_mac, VmId: vm_id, Mac: mac_addr)
end end
# Create a new snapshot with the given name # Create a new snapshot with the given name
@ -166,7 +166,7 @@ module VagrantPlugins
# @param [String] snapshot_name Name of the new snapshot # @param [String] snapshot_name Name of the new snapshot
# @return [nil] # @return [nil]
def create_snapshot(snapshot_name) def create_snapshot(snapshot_name)
execute(:create_snapshot, { VmId: vm_id, SnapName: (snapshot_name) } ) execute(:create_snapshot, VmId: vm_id, SnapName: snapshot_name)
end end
# Restore the given snapshot # Restore the given snapshot
@ -174,14 +174,14 @@ module VagrantPlugins
# @param [String] snapshot_name Name of snapshot to restore # @param [String] snapshot_name Name of snapshot to restore
# @return [nil] # @return [nil]
def restore_snapshot(snapshot_name) def restore_snapshot(snapshot_name)
execute(:restore_snapshot, { VmId: vm_id, SnapName: (snapshot_name) } ) execute(:restore_snapshot, VmId: vm_id, SnapName: snapshot_name)
end end
# Get list of current snapshots # Get list of current snapshots
# #
# @return [Array<String>] snapshot names # @return [Array<String>] snapshot names
def list_snapshots def list_snapshots
snaps = execute(:list_snapshots, { VmID: vm_id } ) snaps = execute(:list_snapshots, VmID: vm_id)
snaps.map { |s| s['Name'] } snaps.map { |s| s['Name'] }
end end
@ -190,7 +190,7 @@ module VagrantPlugins
# @param [String] snapshot_name Name of snapshot to delete # @param [String] snapshot_name Name of snapshot to delete
# @return [nil] # @return [nil]
def delete_snapshot(snapshot_name) def delete_snapshot(snapshot_name)
execute(:delete_snapshot, {VmID: vm_id, SnapName: snapshot_name}) execute(:delete_snapshot, VmID: vm_id, SnapName: snapshot_name)
end end
# Enable or disable VM integration services # Enable or disable VM integration services
@ -203,8 +203,8 @@ module VagrantPlugins
# to configurable even if Vagrant is not aware of them. # to configurable even if Vagrant is not aware of them.
def set_vm_integration_services(config) def set_vm_integration_services(config)
config.each_pair do |srv_name, srv_enable| config.each_pair do |srv_name, srv_enable|
args = {VMID: vm_id, Name: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name)} args = {VMID: vm_id, Name: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name).to_s}
args[:Name] = true if srv_enable args[:Enable] = true if srv_enable
execute(:set_vm_integration_services, args) execute(:set_vm_integration_services, args)
end end
end end