Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMware: add new module vmware_guest_sendkey #56697

Open
wants to merge 1 commit into
base: devel
from

Conversation

@Tomorrow9
Copy link
Contributor

commented May 21, 2019

SUMMARY

Fixes #56558

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

vmware_guest_sendkey

ADDITIONAL INFORMATION
  vmware_guest_sendkey:
    validate_certs: no
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    datacenter: "{{ datacenter_name }}"
    folder: "{{ folder_name }}"
    name: "{{ vm_name }}"
    keys_send:
      - TAB
      - TAB
      - ENTER
  string_send: "username"
  delegate_to: localhost
  register: keys_num_sent

@Tomorrow9 Tomorrow9 force-pushed the Tomorrow9:fix_pr56558 branch from c91d45d to 7c4bd84 May 21, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

@GBrawl @MikeKlebolt @alongchamps @bedecarroll @CastawayEGR @chrrrles @dav1x @davidmhewitt @garbled1 @gyorgypeter @imjoseangel @jjahns @kamsz @karstenjakobsen @kryptsi @lrivallain @michaeldeaton @nafpliot-ibm @nerzhul @oboukili @ritzk @rmin @stravassac @sumkincpp @vmwjoseph @warthog9 @woshihaoren

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@Akasurde Akasurde self-assigned this May 22, 2019

@Akasurde Akasurde requested review from jillr and goneri May 22, 2019

@Akasurde Akasurde removed the needs_triage label May 22, 2019

@Akasurde
Copy link
Member

left a comment

Thanks for the contribution. A couple of suggestion, otherwise lgtm. There are new VMware test case changes that allows you to write testcase against real vCenter. You can take an example of this - https://github.com/ansible/ansible/blob/devel/test/integration/targets/vcenter_license/tasks/main.yml#L5 (This testcase fails on vcsim but if ran against vCenter, it works)

@Tomorrow9 Tomorrow9 force-pushed the Tomorrow9:fix_pr56558 branch 2 times, most recently from 4e71700 to 7ce5fb7 May 22, 2019

@Tomorrow9

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Thanks for the contribution. A couple of suggestion, otherwise lgtm. There are new VMware test case changes that allows you to write testcase against real vCenter. You can take an example of this - https://github.com/ansible/ansible/blob/devel/test/integration/targets/vcenter_license/tasks/main.yml#L5 (This testcase fails on vcsim but if ran against vCenter, it works)

Thank you. Added a test case for this module: test/integration/targets/vmware_guest_sendkey/tasks/main.yml

@Tomorrow9 Tomorrow9 force-pushed the Tomorrow9:fix_pr56558 branch from ada4376 to af1c35c May 22, 2019

def hid_to_hex(hid_code):
return int(hid_code, 16) << 16 | 0o0007

def get_hid_from_key(self, key):

This comment has been minimized.

Copy link
@goneri

goneri May 22, 2019

Contributor

You can simplify the structure and the logic a lot if:

  • self.keys_hid_code is a dict()

  • the key is always a string, not a tuple or a string.

      self.keys_hid_code = {
          'a': ('0x04', ('a', [])),
          'A': ('0x04', ('A', ['LEFTSHIFT'])),
          'b': ('0x05', ('B', ['LEFTSHIFT'])),
          ....
    

This comment has been minimized.

Copy link
@Tomorrow9

Tomorrow9 May 23, 2019

Author Contributor

In this case, this dict will be long since many keys in keyboard having two values with modifier.

This comment has been minimized.

Copy link
@goneri

goneri May 23, 2019

Contributor

absolutely, but you will also improve the readability.

This comment has been minimized.

Copy link
@Tomorrow9

Tomorrow9 May 24, 2019

Author Contributor

but they're the same key on the keyboard with the same hid, we do not need to list everyone with the hid listed twice. And the string ones are the functional keys, can be differentiated with the tuple ones.

Show resolved Hide resolved lib/ansible/modules/cloud/vmware/vmware_guest_sendkey.py Outdated
Show resolved Hide resolved lib/ansible/modules/cloud/vmware/vmware_guest_sendkey.py Outdated
Show resolved Hide resolved lib/ansible/modules/cloud/vmware/vmware_guest_sendkey.py Outdated
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.