Revision f1e45161

b/kamaki/cli/commands/cyclades.py
473 473
            'network policy is applied. These policies are set on the cloud, '
474 474
            'so kamaki is oblivious to them',
475 475
            '--no-network'),
476
        project=ValueArgument('Assign the server to project', '--project'),
476
        project_id=ValueArgument('Assign server to project', '--project-id'),
477 477
    )
478 478
    required = ('server_name', 'flavor_id', 'image_id')
479 479

  
......
519 519
    def _run(self, name, flavor_id, image_id):
520 520
        for r in self._create_cluster(
521 521
                name, flavor_id, image_id, size=self['cluster_size'] or 1,
522
                project=self['project']):
522
                project=self['project_id']):
523 523
            if not r:
524 524
                self.error('Create %s: server response was %s' % (name, r))
525 525
                continue
......
659 659

  
660 660
@command(server_cmds)
661 661
class server_reassign(_init_cyclades, _optional_json):
662
    """Assign a VM to a different project
663
    """
662
    """Assign a virtual server to a different project"""
663

  
664
    arguments = dict(
665
        project_id=ValueArgument('The project to assign', '--project-id')
666
    )
667
    required = ('project_id', )
664 668

  
665 669
    @errors.generic.all
666 670
    @errors.cyclades.connection
......
670 674

  
671 675
    def main(self, server_id, project):
672 676
        super(self.__class__, self)._run()
673
        self._run(server_id=server_id, project=project)
677
        self._run(server_id=server_id, project=self['project'])
674 678

  
675 679

  
676 680
@command(server_cmds)
b/kamaki/cli/commands/network.py
189 189
        name=ValueArgument('Network name', '--name'),
190 190
        shared=FlagArgument(
191 191
            'Make network shared (special privileges required)', '--shared'),
192
        project=ValueArgument('Assign the network to project', '--project'),
192
        project_id=ValueArgument('Assign network to project', '--project-id'),
193 193
        network_type=NetworkTypeArgument(
194 194
            'Valid network types: %s' % (', '.join(NetworkTypeArgument.types)),
195 195
            '--type')
......
200 200
    @errors.cyclades.network_type
201 201
    def _run(self, network_type):
202 202
        net = self.client.create_network(
203
            network_type, name=self['name'],
203
            network_type,
204
            name=self['name'],
204 205
            shared=self['shared'],
205
            project=self['project'])
206
            project=self['project_id'])
206 207
        self._print(net, self.print_dict)
207 208

  
208 209
    def main(self):
......
212 213

  
213 214
@command(network_cmds)
214 215
class network_reassign(_init_network, _optional_json):
215
    """Assign a network to a different project
216
    """
216
    """Assign a network to a different project"""
217

  
218
    arguments = dict(
219
        project_id=ValueArgument('Assign network to project', '--project-id'),
220
    )
221
    required = ('project_id', )
217 222

  
218 223
    @errors.generic.all
219 224
    @errors.cyclades.connection
......
221 226
    def _run(self, network_id, project):
222 227
        self.client.reassign_network(network_id, project)
223 228

  
224
    def main(self, network_id, project):
229
    def main(self, network_id):
225 230
        super(self.__class__, self)._run()
226
        self._run(network_id=network_id, project=project)
231
        self._run(network_id=network_id, project=self['project'])
227 232

  
228 233

  
229 234
@command(network_cmds)
......
647 652

  
648 653
@command(ip_cmds)
649 654
class ip_reassign(_init_network, _optional_output_cmd):
650
    """Assign a floating IP to a different project
651
    """
655
    """Assign a floating IP to a different project"""
656

  
657
    arguments = dict(
658
        project_id=ValueArgument('Assign the IP to project', '--project-id'),
659
    )
660
    required = ('project_id', )
661

  
652 662
    @errors.generic.all
653 663
    @errors.cyclades.connection
654 664
    def _run(self, ip, project):
655 665
        self._optional_output(self.client.reassign_floating_ip(ip, project))
656 666

  
657
    def main(self, IP, project):
667
    def main(self, IP):
658 668
        super(self.__class__, self)._run()
659
        self._run(ip=IP, project=project)
669
        self._run(ip=IP, project=self['project_id'])
660 670

  
661 671

  
662 672
@command(ip_cmds)
b/kamaki/clients/compute/rest_api.py
395 395

  
396 396
    def floating_ips_post(self, json_data, ip='', success=200, **kwargs):
397 397
        path = path4url('os-floating-ips', ip or '')
398
        if json_data is not None:
399
            json_data = json.dumps(json_data)
400
            self.set_header('Content-Type', 'application/json')
401
            self.set_header('Content-Length', len(json_data))
402
        return self.post(path, data=json_data, success=success, **kwargs)
398
        return self.post(path, json=json_data, success=success, **kwargs)
403 399

  
404 400
    def floating_ips_delete(self, ip='', success=204, **kwargs):
405 401
        path = path4url('os-floating-ips', ip or '')
b/kamaki/clients/cyclades/__init__.py
37 37
from kamaki.clients import ClientError, Waiter
38 38
import json
39 39

  
40

  
40 41
class CycladesClient(CycladesRestClient, Waiter):
41 42
    """Synnefo Cyclades Compute API client"""
42 43

  
......
199 200
        r = self.networks_post(json_data=req, success=201)
200 201
        return r.json['network']
201 202

  
202
    def networks_action_post(
203
            self, network_id='', json_data=None, success=202, **kwargs):
203
    def reassign_network(self, network_id, project, **kwargs):
204 204
        """POST base_url/networks/<network_id>/action
205 205

  
206 206
        :returns: request response
207 207
        """
208
        if json_data:
209
            json_data = json.dumps(json_data)
210
            self.set_header('Content-Type', 'application/json')
211
            self.set_header('Content-Length', len(json_data))
212 208
        path = path4url('networks', network_id, 'action')
213
        return self.post(path, data=json_data, success=success, **kwargs)
214

  
215
    def reassign_network(self, network_id, project):
216 209
        req = {'reassign': {'project': project}}
217
        r = self.networks_action_post(network_id, json_data=req, success=200)
210
        r = self.post(path, json=req, success=200, **kwargs)
218 211
        return r.headers
219 212

  
220 213
    def list_ports(self, detail=None):
......
257 250
            floatingip['floating_network_id'] = floating_network_id
258 251
        if floating_ip_address:
259 252
            floatingip['floating_ip_address'] = floating_ip_address
260
        if project_id:
253
        if project_id is not None:
261 254
            floatingip['project'] = project_id
262 255
        r = self.floatingips_post(
263 256
            json_data=dict(floatingip=floatingip), success=200)
b/kamaki/clients/network/__init__.py
331 331

  
332 332
    def create_floatingip(
333 333
            self, floating_network_id,
334
            floating_ip_address='', port_id='', fixed_ip_address='',
335
            args=None):
336
        """Cyclades do not use port_id and fixed_ip_address"""
334
            floating_ip_address='', port_id='', fixed_ip_address=''):
337 335
        floatingip = dict(floating_network_id=floating_network_id)
338 336
        if floating_ip_address:
339 337
            floatingip['floating_ip_address'] = floating_ip_address
......
341 339
            floatingip['port_id'] = port_id
342 340
        if fixed_ip_address:
343 341
            floatingip['fixed_ip_address'] = fixed_ip_address
344
        if args is not None:
345
            floatingip.update(args)
346 342
        r = self.floatingips_post(
347 343
            json_data=dict(floatingip=floatingip), success=200)
348 344
        return r.json['floatingip']

Also available in: Unified diff