Revision 76f01c50 kamaki/client.py

b/kamaki/client.py
34 34
import json
35 35
import logging
36 36

  
37
from base64 import b64encode
37 38
from httplib import HTTPConnection, HTTPSConnection
38 39
from urlparse import urlparse
39 40

  
......
126 127
        reply = self._get(path)
127 128
        return reply['server']
128 129
    
129
    def create_server(self, name, flavor, image):
130
    def create_server(self, name, flavor, image, personality=None):
131
        """personality is a list of (path, data) tuples"""
132
        
130 133
        req = {'name': name, 'flavorRef': flavor, 'imageRef': image}
134
        if personality:
135
            p = []
136
            for path, data in personality:
137
                contents = b64encode(data)
138
                p.append({'path': path, 'contents': contents})
139
            req['personality'] = p
140
        
131 141
        body = json.dumps({'server': req})
132 142
        reply = self._post('/servers', body)
133 143
        return reply['server']

Also available in: Unified diff