def update_data_ip(server_name, session_id, new_ip_configs): # Create the Appliance object with the new configIps DTO. new_appliance = \ {'typeId': 'com.tintri.api.rest.v310.dto.domain.Appliance', 'configIps': new_ip_configs } # Create the Request object with the Appliance DTO. Request = \ {'typeId': 'com.tintri.api.rest.v310.dto.Request', 'objectsWithNewValues': new_appliance, 'propertiesToBeUpdated': ['configIps'] } # Update the VMstore wit the new data IP configuration. url = APPLIANCE_URL r = tintri.api_put(server_name, url, Request, session_id) print_debug("The JSON response of the get invoke to the server " + server_name + " is: " + r.text) # if HTTP Response is not 204 then raise exception if r.status_code != 204: message = "The HTTP response for put call to the server is not 204." raise tintri.TintriApiException(message, r.status_code, url, str(Request), r.text)
def process_vmstore(vmstore_name, user_name, password, new_dns_primary): server_name = vmstore_name # Get the server type r = tintri.api_version(server_name) json_info = r.json() if json_info['productName'] != "Tintri VMstore": this_error = "Server needs to be a VMstore" return this_error session_id = tintri.api_login(server_name, user_name, password) dns_info = get_dns_info(server_name, session_id) print_dns_info(dns_info, server_name + " current: ") new_dns_secondary = dns_info['dnsSecondary'] # Create the ApplianceDns DTO. new_dns_info = \ {'typeId': 'com.tintri.api.rest.v310.dto.domain.beans.hardware.ApplianceDns', 'dnsPrimary': new_dns_primary, 'dnsSecondary': new_dns_secondary } # Create the Appliance object wit the new ApplianceDns DTO. new_appliance = \ {'typeId': 'com.tintri.api.rest.v310.dto.domain.Appliance', 'dnsConfig': new_dns_info } # Create the Request object with the Appliance DTO. Request = \ {'typeId': 'com.tintri.api.rest.v310.dto.Request', 'objectsWithNewValues': new_appliance, 'propertiesToBeUpdated': ['dnsConfig'] } url = APPLIANCE_URL r = tintri.api_put(server_name, url, Request, session_id) print_debug("The JSON response of the get invoke to the server " + server_name + " is: " + r.text) # if HTTP Response is not 204 then raise exception if r.status_code != 204: tintri.api_logout(server_name, session_id) message = "The HTTP response for put call to the server is not 204." raise tintri.TintriApiException(message, r.status_code, url, str(Request), r.text) dns_info = get_dns_info(server_name, session_id) print_dns_info(dns_info, server_name + " now: ") # All pau, log out tintri.api_logout(server_name, session_id)
def set_qos(server_name, session_id, sg_uuid, new_min_value, new_max_value): # Create new QoS object with the fields to be changed modify_qos_info = { 'minNormalizedIops': int(new_min_value), 'maxNormalizedIops': int(new_max_value), 'typeId': 'com.tintri.api.rest.v310.dto.domain.beans.vm.VirtualMachineQoSConfig' } # Configure the QoS for the service group modify_qos_url = "/v310/servicegroup/" + sg_uuid + "/qosConfig" r = tintri.api_put(server_name, modify_qos_url, modify_qos_info, session_id) print_debug("The JSON response of the get invoke to the server " + server_name + " is: " + r.text) # if HTTP Response is not 204 then raise an exception if r.status_code != 204: print_error("The HTTP response for the put invoke to the server " + server_name + " is not 204, but is: " + str(r.status_code)) print_error("url = " + modify_qos_url) print_error("payload = " + str(modify_qos_info)) print_error("response: " + r.text) tintri.api_logout(server_name, session_id) print_info("Error log off " + server_name) sys.exit(-20) # Apply the QoS values that were for the service group that # were configured above. apply_qos_url = "/v310/servicegroup/" + sg_uuid + "/qos" r = tintri.api_post(server_name, apply_qos_url, None, session_id) print_debug("The JSON response of the get invoke to the server " + server_name + " is: " + r.text) # if HTTP Response is not 204 then raise an exception if r.status_code != 204: print_error("The HTTP response for the post invoke to the server " + server_name + " is not 204, but is: " + str(r.status_code)) print_error("url = " + modify_qos_url) print_error("payload = None") print_error("response: " + r.text) tintri.api_logout(server_name, session_id) print_info("Error log off " + server_name) sys.exit(-21)