def main(): # Get the Ansible parameters. module = AnsibleModule(argument_spec=dict(server=dict(required=True, type='str'), user=dict(required=True, type='str'), password=dict(required=True, type='str', no_log=True)), supports_check_mode=True) m_args = module.params try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) try: tintri.restart_webserver(DEFAULT_DATASTORE) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMSTore. tintri.logout() # Return the result to Ansible. module.exit_json(changed=True)
def CreateSession(user, passw, TGC): session = Tintri(TGC) session.login(user, passw) if session.is_logged_in(): return session else: return False
def main(): module = AnsibleModule(argument_spec=dict(server=dict(required=True, type='str'), user=dict(required=True, type='str'), password=dict(required=True, type='str', no_log=True), timezone=dict(required=True, type='str'), useNtp=dict(required=False, type='bool'), ntpPrimary=dict(required=False, type='str'), ntpSecondary=dict(required=False, type='str'), year=dict(required=False, type='int'), month=dict(required=False, type='int'), day=dict(required=False, type='int'), time=dict(required=False, type='str')), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user', 'password'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) remove_dict_keys(m_args, param_skip) try: update_datetime(tintri, m_args) results = obj_to_str(get_datetime(tintri)) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMSTore. tintri.logout() # Return the result to Ansible. module.exit_json(changed=True, meta=results)
def main(): # Get the Ansible parameters. # Note: that some of the parameters names are the same as the HypervisorConfig DTO attributes. module = AnsibleModule( argument_spec = dict( server = dict(required=True, type='str'), user = dict(required=True, type='str'), password = dict(required=True, type='str', no_log=True), host = dict(required=True, type='str'), hypervisorType = dict(required=True, choices=['VMWARE'], type='str'), #hypervisorType = dict(required=True,choices=['VMWARE','RHEV','HYPERV','UNKNOWN','OPENSTACK','XENSERVER','VMWARE_VVOL'], type='str'), username = dict(required=True,type='str'), hypervisor_password = dict(required=True, type='str', no_log=True)), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user', 'password'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) # Forge the hypervisor manager configuration DTO. hypervisor_config = HypervisorManagerConfig() for key, value in m_args.iteritems(): if key not in param_skip: if key == 'hypervisor_password': setattr(hypervisor_config, 'password', value) else: setattr(hypervisor_config, key, value) # Add the hypervisor manager configuration. try: add_hypervisor_config(tintri, hypervisor_config) hyper_configs = get_hypervisor_configs(tintri) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMSTore. tintri.logout() # Return the result to Ansible. results = customize_output(hyper_configs) module.exit_json(changed=True, meta=results)
def main(): # Get the Ansible parameters. # Note: that some of the parameters names are the same as the ApplianceIP DTO attributes. module = AnsibleModule(argument_spec=dict( server=dict(required=True, type='str'), user=dict(required=True, type='str'), password=dict(required=True, type='str', no_log=True), ip=dict(required=True, type='str'), netmask=dict(required=True, type='str'), gateway=dict(required=True, type='str'), isJumboFrameEnabled=dict(required=False, type='bool', default=True), vlanId=dict(required=False, type='str', default='untagged'), networkBond=dict(required=False, type='str', default='NET_BOND_DATA')), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user', 'password'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) # Forge the DTO to update the IP network configuration. new_network = ApplianceIp() m_args['serviceType'] = DATA_SERVICE_TYPE for key, value in m_args.iteritems(): if key not in param_skip: setattr(new_network, key, value) # Append the new data IP network configuration. try: add_data_network_config(tintri, new_network) ip_configs = get_ip_configs(tintri) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMstore. tintri.logout() # Return the result to Ansible. results = customize_output(ip_configs) module.exit_json(changed=True, meta=results)
def main(): # Get the Ansible parameters. # Note: that some of the parameters names are the same as the contact DTO attributes. module = AnsibleModule(argument_spec=dict( server=dict(required=True, type='str'), user=dict(required=True, type='str'), password=dict(required=True, type='str', no_log=True), contact=dict(required=False, type='str'), email=dict(required=False, type='str'), isEnabled=dict(required=False, type='bool', default=True), location=dict(required=False, type='str'), phone=dict(required=False, type='str'), webProxyHostname=dict(required=False, type='str'), webProxyUsername=dict(required=False, type='str'), webProxyPassword=dict(required=False, type='str'), webProxyPort=dict(required=False, type='int')), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user', 'password'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) remove_dict_keys(m_args, param_skip) try: update_contact_config(tintri, m_args) contact_conf = get_contact_config(tintri) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMSTore. tintri.logout() # Return the result to Ansible. results = obj_to_str(contact_conf) module.exit_json(changed=True, meta=results)
def main(): # Get the Ansible parameters. # Note: that some of the parameters names are the same dictionary keys to get POSTed. module = AnsibleModule(argument_spec=dict(server=dict(required=True, type='str'), user=dict(required=True, type='str'), password=dict(required=True, type='str', no_log=True), newPassword=dict(required=True, type='str', no_log=True)), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) # Create the dictionary for the raw API post. remove_dict_keys(m_args, param_skip) m_args['typeId'] = TYPE_ID m_args['username'] = m_args['user'] try: results = api_post(tintri, "resetPassword", m_args) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) #Log out VMSTore tintri.logout() # Return the result to Ansible. module.exit_json(changed=True, meta=results)
def main(): # Get the Ansible parameters. # Note: that some of the parameters names are the same as the DNS configuration dictionary. module = AnsibleModule( argument_spec = dict( server = dict(required=True, type='str'), user = dict(required=True, type='str'), password = dict(required=True, type='str', no_log=True), dnsPrimary = dict(required=True, type='str'), dnsSecondary = dict(required=False, type='str')), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user', 'password'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) remove_dict_keys(m_args, param_skip) try: update_dns_config(tintri, m_args) dns_conf = get_dns_config(tintri) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMSTore. tintri.logout() # Return the result to Ansible. results = obj_to_str(dns_conf) module.exit_json(changed=True, meta=results)
def get_session(server): ''' Get authenticated Tintri Session for the given server Requires: ConnectionInfo object with name 'Tintri VMstore for Environment X' Otherwise return None Args: server (obj): CB server object Returns: tintri: Tintri object ''' conn = get_ci(server) if not conn: return None # instantiate the Tintri server. tintri = Tintri(conn['ip']) # Login to VMstore tintri.login(conn['username'], conn['password']) return tintri
password = sys.argv[3] # Put it here so that it could be made an input parameter if desired. page_size = 100 try: # instantiate the Tintri server. tintri = Tintri(server_name) # Get version and product version_info = tintri.version product_name = version_info.productName print_info("API Version: " + version_info.preferredVersion) # Login to VMstore tintri.login(user_name, password) except TintriServerError as tse: print_error(tse.__str__()) sys.exit(-2) try: vms = get_vms(tintri, page_size) except TintriServerError as tse: print_error(tse.__str__()) tintri.logout() sys.exit(-3) print_info("Statistics collected") tintri.logout()
def main(): # Get the Ansible parameters. # Note: that some of the parameters names are the same as the e-mail configuration dictionary. module = AnsibleModule(argument_spec=dict( server=dict(required=True, type='str'), user=dict(required=True, type='str'), password=dict(required=True, type='str', no_log=True), toEmail=dict(required=False, type='str', default='*****@*****.**'), smtpHost=dict(required=True, type='str'), emailNoticeLevel=dict(required=False, choices=[ 'ALERTS_ONLY', 'ALERTS_AND_SOME_NOTICES', 'ALERTS_AND_ALL_NOTICES' ], type='str'), fromEmail=dict(required=True, type='str'), smtpIsLoginRequired=dict(required=False, type='bool'), smtpConnection=dict(required=False, choices=['NO_SECURE_CONNECTION', 'TLS', 'SSL'], type='str', default='NO_SECURE_CONNECTION'), smtpPort=dict(required=False, type='int', default=25), smtpSSLPort=dict(required=False, type='int'), username=dict(required=False, type='str'), email_password=dict(required=False, type='str', no_log=True)), supports_check_mode=True) m_args = module.params param_skip = ['server', 'user', 'password'] try: # Instantiate the Tintri VMStore. tintri = Tintri(m_args['server']) # Login to VMStore. tintri.login(m_args['user'], m_args['password']) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) remove_dict_keys(m_args, param_skip) if m_args['email_password'] is not None: m_args['password'] = m_args.pop('email_password') try: update_email_config(tintri, m_args) email_conf = get_email_config(tintri) except TintriServerError as tse: module.fail_json(msg=tse.__str__()) tintri.logout() # Log out VMSTore. tintri.logout() # Return the result to Ansible. results = obj_to_str(email_conf) module.exit_json(changed=True, meta=results)
# Try to login into the TGC. try: # instantiate the Tintri server. tgc = Tintri(server_name) # Get version and product version_info = tgc.version product = version_info.productName if product != "Tintri Global Center": raise TintriServerError(0, cause="Server needs to be a TGC") print_info("API Version: " + version_info.preferredVersion) # Login to Tintri server tgc.login(user_name, password) except TintriServerError as tse: print_error(tse.__str__()) sys.exit(2) try: # Create the report filter. report_filter = VirtualMachineDownloadableReportFilter() report_filter.attachment = csv_file_name report_filter.attributes = attributes report_filter.since = "" report_filter.until = "" report_filter.format = "CSV" # Invoke API to get a useable report URL.