def __request(self, method, url,  headers, body,  error):
        """
        Launch a request and returns its response
        :param method: method used ex: POST, GET, DELETE, etc
        :param url: <IP>:<port>/<path>
        :param headers: headers used
        :param body: body in case of POST method
        :param error: error types
        :return: response
        """
        headers['X-Auth-Token'] = utils.errorLabel (headers['X-Auth-Token'], error)
        url = utils.errorUrl(url, error)

        if error == "GET" or error == "PUT" or error == "POST" or error == "DELETE":
            method = error

        if method == "GET":
            response = http.get(url, headers)
        elif method == "POST":
            response = http.post(url, headers, body)
        elif method == "PUT":
            response =  http.put(url, headers, body)
        elif method == "DELETE":
            response = http.delete(url, headers)

        #utils.printRequest(method,url,headers,body)                 # show request
        #utils.printResponse(response)                               # show response
        return response
示例#2
0
 def __delete_environment(self, url):
     headers = {
         'X-Auth-Token': self.token,
         'Tenant-Id': self.vdc,
         'Accept': "application/json"
     }
     return http.delete(url, headers)
示例#3
0
 def __delete_node(self, url):
     headers = {
         'X-Auth-Token': self.token,
         'Tenant-Id': self.vdc,
         'Content-Type': "application/xml"
     }
     return http.delete(url, headers)
示例#4
0
    def __request(self, method, url, headers, body, error):
        """
        Launch a request and returns its response
        :param method: method used ex: POST, GET, DELETE, etc
        :param url: <IP>:<port>/<path>
        :param headers: headers used
        :param body: body in case of POST method
        :param error: error types
        :return: response
        """
        headers['X-Auth-Token'] = utils.errorLabel(headers['X-Auth-Token'],
                                                   error)
        url = utils.errorUrl(url, error)

        if error == "GET" or error == "PUT" or error == "POST" or error == "DELETE":
            method = error

        if method == "GET":
            response = http.get(url, headers)
        elif method == "POST":
            response = http.post(url, headers, body)
        elif method == "PUT":
            response = http.put(url, headers, body)
        elif method == "DELETE":
            response = http.delete(url, headers)

        #utils.printRequest(method,url,headers,body)                 # show request
        #utils.printResponse(response)                               # show response
        return response
示例#5
0
def delete_claimed_msgs(*claim_response):
    """
    Deletes claimed messages.
    Verifies that the deletes were successful by doing a GET on the deleted msg
    """
    test_result_flag = False

    urllist = create_urllist_fromhref(*claim_response)
    header = common.functionlib.create_marconi_headers()

    for url in urllist:
        delete_response = http.delete(url, header)
        if delete_response.status_code == 204:
            print url
            get_deleted = http.get(url, header)
            if get_deleted.status_code == 404:
                test_result_flag = True
            else:
                print "GET deleted message: {}".format(url)
                print get_deleted.status_code
                print get_deleted.headers
                print get_deleted.text
        else:
            print "DELETE message with claim ID: {}".format(url)
            print delete_response.status_code
            print delete_response.headers
            print delete_response.text

    if not test_result_flag:
        assert test_result_flag, "DELETE message with claim ID failed"
示例#6
0
 def __delete_product_sdc(self, url):
     """ Delete product from SDC catalog """
     headers = {
         'X-Auth-Token': self.token,
         'Tenant-Id': self.vdc,
         'Content-Type': "application/xml"
     }
     return http.delete(url, headers)
示例#7
0
    def __delete_environments(self, url):
        #url="%s/%s" %(self.paasmanager_url,"catalog/org/FIWARE/environment")
        headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc,
                   'Accept': "application/json"}
        response = http.delete(url, headers)

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 200 and response.status != 204:
            print 'error to delete the environment ' + str(response.status)
            sys.exit(1)
示例#8
0
    def delete_env (self, env_id):
        url = "http://{0}/v1/environments/{1}".format(self.murano_url, env_id)
        headers = {'X-Auth-Token': self.token,
               'Accept': "application/json",
               'Content-Type': 'application/json'}

        print "Deleting the environment " + url
        response = http.delete(url, headers)

        if response.status != 200:
            print 'error to delete the env ' + str(response.status)
            exit()
示例#9
0
    def delete_template(self, template_id):
        url = "http://{0}/v1/templates/{1}".format(self.murano_url, template_id)
        headers = {'X-Auth-Token': self.token,
                   'Accept': "application/json",
                   'Content-Type': 'application/json'}

        print "Deleting a blueprint template " + url
        response = http.delete(url, headers)

        if response.status != 200:
            print 'error deleting the template' + str(response.status)
            exit()
示例#10
0
    def delete_env(self, env_id):
        url = "http://{0}/v1/environments/{1}".format(self.murano_url, env_id)
        headers = {
            'X-Auth-Token': self.token,
            'Accept': "application/json",
            'Content-Type': 'application/json'
        }

        print "Deleting the environment " + url
        response = http.delete(url, headers)

        if response.status != 200:
            print 'error to delete the env ' + str(response.status)
            exit()
示例#11
0
    def delete_vm(self):
        url = "%s/%s/%s/%s" % (self.url_openstack, self.id_tenant, "servers", self.id)
        headers = {'X-Auth-Token': self.token,
                   'Content-Type': "application/json"}
        response = http.delete(url, headers)


        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 204:
            print 'error deleting vm' + str(response.status) + response.reason
            sys.exit(1)
        else:
            print 'Deleting VM ........'
            print response.msg
示例#12
0
    def delete_product_release(self, product_name, version):
        #headers={'X-Auth-Token': self.token,
        #         'Accept': "application/json"}
        headers = {'Accept': "application/json"}
        #get product release
        url = "%s/%s/%s/%s/%s" % (self.sdc_url, "catalog/product", product_name, "release", version)

        response = http.delete(url, headers)

        if response.status != 200 and response.status != 204:
            print 'error to delete the product release ' + product_name + ' ' + str(response.status)
            sys.exit(1)
        else:
            pass
示例#13
0
    def delete_product(self, product_name):
        version = self.get_product_release(product_name);

        if version != None:
            self.delete_product_release(product_name, version);
            #headers={'X-Auth-Token': self.token,
        #         'Accept': "application/json"}
        headers = {'Accept': "application/json"}
        #get product release
        url = "%s/%s" % (self.sdc_url, "catalog/product/" + product_name)
        response = http.delete(url, headers)

        if response.status != 200 and response.status != 204:
            print 'error to delete the product ' + product_name + ' ' + str(response.status)
            sys.exit(1)
示例#14
0
    def delete_template(self, template_id):
        url = "http://{0}/v1/templates/{1}".format(self.murano_url,
                                                   template_id)
        headers = {
            'X-Auth-Token': self.token,
            'Accept': "application/json",
            'Content-Type': 'application/json'
        }

        print "Deleting a blueprint template " + url
        response = http.delete(url, headers)

        if response.status != 200:
            print 'error deleting the template' + str(response.status)
            exit()
示例#15
0
    def delete_product_release(self, product_name, version):
        #headers={'X-Auth-Token': self.token,
        #         'Accept': "application/json"}
        headers = {'Accept': "application/json"}
        #get product release
        url = "%s/%s/%s/%s/%s" % (self.sdc_url, "catalog/product",
                                  product_name, "release", version)

        response = http.delete(url, headers)

        if response.status != 200 and response.status != 204:
            print 'error to delete the product release ' + product_name + ' ' + str(
                response.status)
            sys.exit(1)
        else:
            pass
示例#16
0
    def delete_vm(self):
        url = "%s/%s/%s/%s" % (self.url_openstack, self.id_tenant, "servers",
                               self.id)
        headers = {
            'X-Auth-Token': self.token,
            'Content-Type': "application/json"
        }
        response = http.delete(url, headers)

        ## Si la respuesta es la adecuada, creo el diccionario de los datos en JSON.
        if response.status != 204:
            print 'error deleting vm' + str(response.status) + response.reason
            sys.exit(1)
        else:
            print 'Deleting VM ........'
            print response.msg
示例#17
0
    def delete_product(self, product_name):
        version = self.get_product_release(product_name)

        if version != None:
            self.delete_product_release(product_name, version)
            #headers={'X-Auth-Token': self.token,
        #         'Accept': "application/json"}
        headers = {'Accept': "application/json"}
        #get product release
        url = "%s/%s" % (self.sdc_url, "catalog/product/" + product_name)
        response = http.delete(url, headers)

        if response.status != 200 and response.status != 204:
            print 'error to delete the product ' + product_name + ' ' + str(
                response.status)
            sys.exit(1)
示例#18
0
def request(method, url,  headers, body,  error):
    headers['X-Auth-Token'] = errorLabel (headers['X-Auth-Token'], error)
    url = errorUrl(url, error)

    if error == "GET" or error == "PUT" or error == "POST" or error == "DELETE":
        method = error

    if method == "GET":
        response = http.get(url, headers)
    elif method == "POST":
        response = http.post(url, headers, body)
    elif method == "PUT":
        response =  http.put(url, headers, body)
    elif method == "DELETE":
        response = http.delete(url, headers)

    printRequest(method,url,headers,body)
    #printResponse(response)
    return response
示例#19
0
def request(method, url, headers, body, error):
    headers['X-Auth-Token'] = errorLabel(headers['X-Auth-Token'], error)
    url = errorUrl(url, error)

    if error == "GET" or error == "PUT" or error == "POST" or error == "DELETE":
        method = error

    if method == "GET":
        response = http.get(url, headers)
    elif method == "POST":
        response = http.post(url, headers, body)
    elif method == "PUT":
        response = http.put(url, headers, body)
    elif method == "DELETE":
        response = http.delete(url, headers)

    printRequest(method, url, headers, body)
    #printResponse(response)
    return response
示例#20
0
文件: msgfnlib.py 项目: racker/handy
def delete_msg(*postresponse):
    """Post DELETE message & verifies that a subsequent GET returns 404"""
    test_result_flag = False
    headers = str(postresponse[0])
    headers = headers.replace("'", '"')
    headers = json.loads(headers)
    location = headers["location"]
    url = common.functionlib.create_url_from_appender(location)
    header = common.functionlib.create_marconi_headers()
    deletemsg = http.delete(url, header)
    if deletemsg.status_code == 204:
        test_result_flag = verify_delete(url, header)
    else:
        print ("DELETE message failed")
        print ("URL")
        print url
        print ("headers")
        print header
        print ("Response Body")
        print deletemsg.text
        assert test_result_flag, "DELETE Response Code {}".format(deletemsg.status_code)
示例#21
0
 def __delete_node(self, url):
     headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc,
                'Content-Type': "application/xml"}
     return http.delete(url, headers)
示例#22
0
 def __delete_product_sdc(self, url):
     """ Delete product from SDC catalog """
     headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc,
                'Content-Type': "application/xml"}
     return http.delete(url, headers)
 def __delete_tier_environment(self, url):
     headers = {'X-Auth-Token': self.token, 'Tenant-Id': self.vdc,
                'Accept': "application/json"}
     return http.delete(url, headers)
示例#24
0
 def delete(self, sysNam, id):
     return http.delete(sysNam, '%s/%d' % (self.path, id))
示例#25
0
 def del_member(self, sysNam, objId, userId):
     return http.delete(sysNam,
                        '%s/%d/members/%d' % (self.path, objId, userId))
示例#26
0
	def delete(self, sysNam, id):
		return http.delete(sysNam, '%s/%d' % (self.path, id))
示例#27
0
def remove_index(es_url, index):
    http.delete(es_url, index, "\nThe index below has been removed successfully:\n")
示例#28
0
 def remove(auth):
   r = http.get("%s/authorizations" % GITHUB_ROOT, cache = False, auth = auth)
   for i in r:
     if i["note"] == "airstrip2":
       http.delete("%s/authorizations/%s" % (GITHUB_ROOT, i["id"]), auth = auth)
示例#29
0
 def del_member(self, sysNam, objId, userId):
     return http.delete(sysNam, "%s/%d/members/%d" % (self.path, objId, userId))