# Path: virtman/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
#                  level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):


import requests
from virtman.openstack.common import jsonutils
    def get(self, url, **kwargs):
        return self.requests(url, 'GET', **kwargs) 
    
    def post(self, url, **kwargs):
        return self.requests(url, 'POST', **kwargs)
    
    def put(self, url, **kwargs):
        return self.requests(url, 'PUT', **kwargs)
    
    def delete(self, url, **kwargs):
        return self.requests(url, 'DELETE', **kwargs)


def test4():
    url4 = 'http://127.0.0.1:8001/list'
    r4 = requests.get(url4)
    print r4.headers, '\n', r4.content

    url5 = 'http://127.0.0.1:8001/create'

    body = {
        'image_id': '123456',
        'vm_name': 'vm6',
        'connections': [],
        'snapshot_dev': '/dev/loop8'
    }
    kwargs = {}
    kwargs.setdefault('headers', kwargs.get('headers', {}))
    kwargs['headers']['Accept'] = 'application/json'
    kwargs['headers']['Content-Type'] = 'application/json'

# Path: virtman/openstack/common/jsonutils.py
# def to_primitive(value, convert_instances=False, convert_datetime=True,
#                  level=0, max_depth=3):
# def dumps(value, default=to_primitive, **kwargs):
# def loads(s):
# def load(s):


# Path: tests/client-test.py
import requests
from virtman.openstack.common import jsonutils

    def get(self, url, **kwargs):
        return self.requests(url, 'GET', **kwargs) 
    
    def post(self, url, **kwargs):
        return self.requests(url, 'POST', **kwargs)
    
    def put(self, url, **kwargs):
        return self.requests(url, 'PUT', **kwargs)
    
    def delete(self, url, **kwargs):
        return self.requests(url, 'DELETE', **kwargs)


def test4():
    url4 = 'http://127.0.0.1:8001/list'
    r4 = requests.get(url4)
    print r4.headers, '\n', r4.content

    url5 = 'http://127.0.0.1:8001/create'

    body = {
        'image_id': '123456',
        'vm_name': 'vm6',
        'connections': [],
        'snapshot_dev': '/dev/loop8'
    }
    kwargs = {}
    kwargs.setdefault('headers', kwargs.get('headers', {}))
    kwargs['headers']['Accept'] = 'application/json'
    kwargs['headers']['Content-Type'] = 'application/json'

    kwargs['body'] = jsonutils.dumps(body)