Revision d5841e90 kamaki/clients/cyclades/__init__.py

b/kamaki/clients/cyclades/__init__.py
42 42

  
43 43
    def create_server(
44 44
            self, name, flavor_id, image_id,
45
            metadata=None, personality=None, networks=None):
45
            metadata=None, personality=None, networks=None, project=None):
46 46
        """Submit request to create a new server
47 47

  
48 48
        :param name: (str)
......
64 64
            ATTENTION: Empty list is different to None. None means ' do not
65 65
            mention it', empty list means 'automatically get an ip'
66 66

  
67
        :param project: the project where to assign the server
68

  
67 69
        :returns: a dict with the new virtual server details
68 70

  
69 71
        :raises ClientError: wraps request errors
......
78 80

  
79 81
        return super(CycladesClient, self).create_server(
80 82
            name, flavor_id, image_id,
81
            metadata=metadata, personality=personality, networks=networks)
83
            metadata=metadata, personality=personality, networks=networks,
84
            project=project)
82 85

  
83 86
    def start_server(self, server_id):
84 87
        """Submit a startup request
......
112 115
        r = self.servers_action_post(server_id, json_data=req, success=200)
113 116
        return r.json['console']
114 117

  
118
    def reassign_server(self, server_id, project):
119
        req = {'reassign': {'project': project}}
120
        r = self.servers_action_post(server_id, json_data=req, success=200)
121
        return r.headers
122

  
115 123
    def get_server_stats(self, server_id):
116 124
        """
117 125
        :param server_id: integer (str or int)
......
169 177
        r = self.get(path, success=200)
170 178
        return r.json['networks']
171 179

  
172
    def create_network(self, type, name=None, shared=None):
180
    def create_network(self, type, name=None, shared=None, project=None):
173 181
        req = dict(network=dict(type=type, admin_state_up=True))
174 182
        if name:
175 183
            req['network']['name'] = name
176 184
        if shared not in (None, ):
177 185
            req['network']['shared'] = bool(shared)
186
        if project is not None:
187
            req['network']['project'] = project
178 188
        r = self.networks_post(json_data=req, success=201)
179 189
        return r.json['network']
180 190

  
191
    def reassign_network(self, network_id, project):
192
        req = {'reassign': {'project': project}}
193
        r = self.networks_action_post(network_id, json_data=req, success=200)
194
        return r.headers
195

  
181 196
    def list_ports(self, detail=None):
182 197
        path = path4url('ports', 'detail' if detail else '')
183 198
        r = self.get(path, success=200)
......
204 219
        r = self.ports_post(json_data=dict(port=port), success=201)
205 220
        return r.json['port']
206 221

  
207
    def create_floatingip(self, floating_network_id, floating_ip_address=''):
222
    def create_floatingip(self, floating_network_id, floating_ip_address='',
223
                          project=None):
208 224
        return super(CycladesNetworkClient, self).create_floatingip(
209 225
            floating_network_id, floating_ip_address=floating_ip_address)
210 226

  
......
212 228
        """To nullify something optional, use None"""
213 229
        return super(CycladesNetworkClient, self).update_floatingip(
214 230
            floating_network_id, floating_ip_address=floating_ip_address)
231

  
232
    def reassign_floating_ip(self, floating_network_id, project):
233
        req = {'reassign': {'project': project}}
234
        r = self.floating_ip_action_post(floating_network_id, json_data=req)

Also available in: Unified diff