text: #!/usr/bin/env python
  
  from ansible.module_utils.basic import *
  
  
  DOCUMENTATION = '''
  ---
  module: cisco_ucs_callhome_system_inventory_send_now
  short_description: sends callhome system inventory now on cisco ucs server
  version_added: 0.9.0.0
  description:
     -  sends callhome system inventory now on a cisco ucs server
  
  requirements: ['ucsmsdk', 'ucsm_apis']
  author: "Rahul Gupta(ragupta4@cisco.com)"
  '''
  
  
  EXAMPLES = '''
  - name:
    cisco_ucs_callhome_system_inventory_send_now:
      ucs_ip: "192.168.1.1"
      ucs_username: "admin"
      ucs_password: "password"
  '''
  
  def _argument_connection():
      return  dict(
          # UcsHandle
          ucs_server=dict(type='dict'),
  
          # Ucs server credentials
          ucs_ip=dict(type='str'),
          ucs_username=dict(default="admin", type='str'),
          ucs_password=dict(type='str', no_log=True),
          ucs_port=dict(default=None),
          ucs_secure=dict(default=None),
          ucs_proxy=dict(default=None)
      )
  
  
  def _ansible_module_create():
      argument_spec = dict()
      argument_spec.update(_argument_connection())
  
      return AnsibleModule(argument_spec,
                           supports_check_mode=True)
  
  
  def setup_callhome_system_inventory_send_now(server, module):
      from ucsm_apis.admin.callhome import callhome_system_inventory_send_now
  
      ansible = module.params
      exists = False
  
      if module.check_mode or exists:
          return not exists
      callhome_system_inventory_send_now(handle=server)
  
      return True
  
  
  def setup(server, module):
      result = {}
      err = False
  
      try:
          result["changed"] = setup_callhome_system_inventory_send_now(server, module)
      except Exception as e:
          err = True
          result["msg"] = "setup error: %s " % str(e)
          result["changed"] = False
  
      return result, err
  
  
  def main():
      from ansible.module_utils.cisco_ucs import UcsConnection
  
      module = _ansible_module_create()
      conn = UcsConnection(module)
      server = conn.login()
      result, err = setup(server, module)
      conn.logout()
      if err:
          module.fail_json(**result)
      module.exit_json(**result)
  
  
  if __name__ == '__main__':
      main()
  
  