Commit 682fa2b9 by Czémán Arnold

minor modifications

parent 01bf8c3a
from django.contrib import admin
# Register your models here.
from django.db import models
# Create your models here.
import requests
from requests.exceptions import ConnectionError
import json
# import urllib3
......@@ -18,7 +17,6 @@ loginData = {"username": username, "password": password}
# automatikusan benne maradjon az osszes keresunkben
with requests.Session() as session:
headers = {"Content-Type": "application/json", "Referer": server}
try:
# Csrf-Token a bejelentkezeshez
req = session.get(server + "occi/login/", headers=headers,
verify=False)
......@@ -149,7 +147,6 @@ with requests.Session() as session:
print(json.dumps(json.loads(req.text), sort_keys=True,
indent=4, separators=(",", ": ")))
print
# vm krealas
try:
headers["X-CSRFToken"] = req.cookies["csrftoken"]
......@@ -198,5 +195,3 @@ with requests.Session() as session:
print
print(json.dumps(json.loads(req.text), sort_keys=True,
indent=4, separators=(",", ": ")))
except ConnectionError as e:
print(e)
......@@ -215,8 +215,8 @@ CREDENTIALS_MIXIN = Mixin("http://circlecloud.org/occi/infrastructure#",
"credentials",
title="Credentials Mixin",
attributes=CREDENTIALS_ATTRIBUTES,
applies="http://schemas.ogf.org/occi/infrastructure" +
"#compute")
applies="http://schemas.ogf.org/occi/" +
"infrastructure#compute")
OS_TPL_MIXIN = Mixin("http://schemas.ogf.org/occi/infrastructure#",
"os_tpl",
......
......@@ -87,8 +87,8 @@ def validate_request(request, authentication_required=True,
if has_data:
# checking content type
if request.META.get("CONTENT_TYPE") != "application/json":
raise OcciRequestNotValid("Only application/json content type is " +
"allowed.")
raise OcciRequestNotValid("Only application/json content type" +
" is allowed.")
# checking if the data is a valid json
try:
data = json.loads(request.body.decode("utf-8"))
......
from django.test import TestCase
# Create your tests here.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment