Skip to content

Commit

Permalink
Clean up syntax and force string type when setting integration option
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroberts committed May 25, 2018
1 parent beacb5b commit 2bd6f53
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions plugins/providers/hyperv/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,64 +77,64 @@ def execute(path, options={})
#
# @return [Hash<state, status>]
def get_current_state
execute(:get_vm_status, { VmId: vm_id })
execute(:get_vm_status, VmId: vm_id)
end

# Delete the VM
#
# @return [nil]
def delete_vm
execute(:delete_vm, { VmId: vm_id })
execute(:delete_vm, VmId: vm_id)
end

# Export the VM to the given path
#
# @param [String] path Path for export
# @return [nil]
def export(path)
execute(:export_vm, {VmId: vm_id, Path: path})
execute(:export_vm, VmId: vm_id, Path: path)
end

# Get the IP address of the VM
#
# @return [Hash<ip>]
def read_guest_ip
execute(:get_network_config, { VmId: vm_id })
execute(:get_network_config, VmId: vm_id)
end

# Get the MAC address of the VM
#
# @return [Hash<mac>]
def read_mac_address
execute(:get_network_mac, { VmId: vm_id })
execute(:get_network_mac, VmId: vm_id)
end

# Resume the VM from suspension
#
# @return [nil]
def resume
execute(:resume_vm, { VmId: vm_id })
execute(:resume_vm, VmId: vm_id)
end

# Start the VM
#
# @return [nil]
def start
execute(:start_vm, { VmId: vm_id })
execute(:start_vm, VmId: vm_id )
end

# Stop the VM
#
# @return [nil]
def stop
execute(:stop_vm, { VmId: vm_id })
execute(:stop_vm, VmId: vm_id)
end

# Suspend the VM
#
# @return [nil]
def suspend
execute(:suspend_vm, { VmId: vm_id })
execute(:suspend_vm, VmId: vm_id)
end

# Import a new VM
Expand All @@ -150,38 +150,38 @@ def import(options)
# @param [String] vlan_id VLAN ID
# @return [nil]
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

# Set the VM adapter MAC address
#
# @param [String] mac_addr MAC address
# @return [nil]
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

# Create a new snapshot with the given name
#
# @param [String] snapshot_name Name of the new snapshot
# @return [nil]
def create_snapshot(snapshot_name)
execute(:create_snapshot, { VmId: vm_id, SnapName: (snapshot_name) } )
execute(:create_snapshot, VmId: vm_id, SnapName: snapshot_name)
end

# Restore the given snapshot
#
# @param [String] snapshot_name Name of snapshot to restore
# @return [nil]
def restore_snapshot(snapshot_name)
execute(:restore_snapshot, { VmId: vm_id, SnapName: (snapshot_name) } )
execute(:restore_snapshot, VmId: vm_id, SnapName: snapshot_name)
end

# Get list of current snapshots
#
# @return [Array<String>] snapshot names
def list_snapshots
snaps = execute(:list_snapshots, { VmID: vm_id } )
snaps = execute(:list_snapshots, VmID: vm_id)
snaps.map { |s| s['Name'] }
end

Expand All @@ -190,7 +190,7 @@ def list_snapshots
# @param [String] snapshot_name Name of snapshot to delete
# @return [nil]
def delete_snapshot(snapshot_name)
execute(:delete_snapshot, {VmID: vm_id, SnapName: snapshot_name})
execute(:delete_snapshot, VmID: vm_id, SnapName: snapshot_name)
end

# Enable or disable VM integration services
Expand All @@ -203,8 +203,8 @@ def delete_snapshot(snapshot_name)
# to configurable even if Vagrant is not aware of them.
def set_vm_integration_services(config)
config.each_pair do |srv_name, srv_enable|
args = {VMID: vm_id, Name: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name)}
args[:Name] = true if srv_enable
args = {VMID: vm_id, Name: INTEGRATION_SERVICES_MAP.fetch(srv_name.to_sym, srv_name).to_s}
args[:Enable] = true if srv_enable
execute(:set_vm_integration_services, args)
end
end
Expand Down

0 comments on commit 2bd6f53

Please sign in to comment.