commit f1e451614522ba2f2196621e84be9175b9550210
Author: Stavros Sachtouris <saxtouri@admin.grnet.gr>
Date:   Mon Feb 17 17:27:25 2014 +0200

    Update project-related code to kamaki coding style
    
    Notable changes:
     in CLI, --project --> --project-id
     in clients, create_floating_ip overwrites OS/network method

diff --git a/kamaki/cli/commands/cyclades.py b/kamaki/cli/commands/cyclades.py
index d996b96..46b59dc 100644
--- a/kamaki/cli/commands/cyclades.py
+++ b/kamaki/cli/commands/cyclades.py
@@ -473,7 +473,7 @@ class server_create(_init_cyclades, _optional_json, _server_wait):
             'network policy is applied. These policies are set on the cloud, '
             'so kamaki is oblivious to them',
             '--no-network'),
-        project=ValueArgument('Assign the server to project', '--project'),
+        project_id=ValueArgument('Assign server to project', '--project-id'),
     )
     required = ('server_name', 'flavor_id', 'image_id')
 
@@ -519,7 +519,7 @@ class server_create(_init_cyclades, _optional_json, _server_wait):
     def _run(self, name, flavor_id, image_id):
         for r in self._create_cluster(
                 name, flavor_id, image_id, size=self['cluster_size'] or 1,
-                project=self['project']):
+                project=self['project_id']):
             if not r:
                 self.error('Create %s: server response was %s' % (name, r))
                 continue
@@ -659,8 +659,12 @@ class server_modify(_init_cyclades, _optional_output_cmd):
 
 @command(server_cmds)
 class server_reassign(_init_cyclades, _optional_json):
-    """Assign a VM to a different project
-    """
+    """Assign a virtual server to a different project"""
+
+    arguments = dict(
+        project_id=ValueArgument('The project to assign', '--project-id')
+    )
+    required = ('project_id', )
 
     @errors.generic.all
     @errors.cyclades.connection
@@ -670,7 +674,7 @@ class server_reassign(_init_cyclades, _optional_json):
 
     def main(self, server_id, project):
         super(self.__class__, self)._run()
-        self._run(server_id=server_id, project=project)
+        self._run(server_id=server_id, project=self['project'])
 
 
 @command(server_cmds)
diff --git a/kamaki/cli/commands/network.py b/kamaki/cli/commands/network.py
index fcecd00..d6f4aa9 100644
--- a/kamaki/cli/commands/network.py
+++ b/kamaki/cli/commands/network.py
@@ -189,7 +189,7 @@ class network_create(_init_network, _optional_json):
         name=ValueArgument('Network name', '--name'),
         shared=FlagArgument(
             'Make network shared (special privileges required)', '--shared'),
-        project=ValueArgument('Assign the network to project', '--project'),
+        project_id=ValueArgument('Assign network to project', '--project-id'),
         network_type=NetworkTypeArgument(
             'Valid network types: %s' % (', '.join(NetworkTypeArgument.types)),
             '--type')
@@ -200,9 +200,10 @@ class network_create(_init_network, _optional_json):
     @errors.cyclades.network_type
     def _run(self, network_type):
         net = self.client.create_network(
-            network_type, name=self['name'],
+            network_type,
+            name=self['name'],
             shared=self['shared'],
-            project=self['project'])
+            project=self['project_id'])
         self._print(net, self.print_dict)
 
     def main(self):
@@ -212,8 +213,12 @@ class network_create(_init_network, _optional_json):
 
 @command(network_cmds)
 class network_reassign(_init_network, _optional_json):
-    """Assign a network to a different project
-    """
+    """Assign a network to a different project"""
+
+    arguments = dict(
+        project_id=ValueArgument('Assign network to project', '--project-id'),
+    )
+    required = ('project_id', )
 
     @errors.generic.all
     @errors.cyclades.connection
@@ -221,9 +226,9 @@ class network_reassign(_init_network, _optional_json):
     def _run(self, network_id, project):
         self.client.reassign_network(network_id, project)
 
-    def main(self, network_id, project):
+    def main(self, network_id):
         super(self.__class__, self)._run()
-        self._run(network_id=network_id, project=project)
+        self._run(network_id=network_id, project=self['project'])
 
 
 @command(network_cmds)
@@ -647,16 +652,21 @@ class ip_create(_init_network, _optional_json):
 
 @command(ip_cmds)
 class ip_reassign(_init_network, _optional_output_cmd):
-    """Assign a floating IP to a different project
-    """
+    """Assign a floating IP to a different project"""
+
+    arguments = dict(
+        project_id=ValueArgument('Assign the IP to project', '--project-id'),
+    )
+    required = ('project_id', )
+
     @errors.generic.all
     @errors.cyclades.connection
     def _run(self, ip, project):
         self._optional_output(self.client.reassign_floating_ip(ip, project))
 
-    def main(self, IP, project):
+    def main(self, IP):
         super(self.__class__, self)._run()
-        self._run(ip=IP, project=project)
+        self._run(ip=IP, project=self['project_id'])
 
 
 @command(ip_cmds)
diff --git a/kamaki/clients/compute/rest_api.py b/kamaki/clients/compute/rest_api.py
index c3978d2..c6a243b 100644
--- a/kamaki/clients/compute/rest_api.py
+++ b/kamaki/clients/compute/rest_api.py
@@ -395,11 +395,7 @@ class ComputeRestClient(Client):
 
     def floating_ips_post(self, json_data, ip='', success=200, **kwargs):
         path = path4url('os-floating-ips', ip or '')
-        if json_data is not None:
-            json_data = json.dumps(json_data)
-            self.set_header('Content-Type', 'application/json')
-            self.set_header('Content-Length', len(json_data))
-        return self.post(path, data=json_data, success=success, **kwargs)
+        return self.post(path, json=json_data, success=success, **kwargs)
 
     def floating_ips_delete(self, ip='', success=204, **kwargs):
         path = path4url('os-floating-ips', ip or '')
diff --git a/kamaki/clients/cyclades/__init__.py b/kamaki/clients/cyclades/__init__.py
index 8facf4c..b8ca082 100644
--- a/kamaki/clients/cyclades/__init__.py
+++ b/kamaki/clients/cyclades/__init__.py
@@ -37,6 +37,7 @@ from kamaki.clients.utils import path4url
 from kamaki.clients import ClientError, Waiter
 import json
 
+
 class CycladesClient(CycladesRestClient, Waiter):
     """Synnefo Cyclades Compute API client"""
 
@@ -199,22 +200,14 @@ class CycladesNetworkClient(NetworkClient):
         r = self.networks_post(json_data=req, success=201)
         return r.json['network']
 
-    def networks_action_post(
-            self, network_id='', json_data=None, success=202, **kwargs):
+    def reassign_network(self, network_id, project, **kwargs):
         """POST base_url/networks/<network_id>/action
 
         :returns: request response
         """
-        if json_data:
-            json_data = json.dumps(json_data)
-            self.set_header('Content-Type', 'application/json')
-            self.set_header('Content-Length', len(json_data))
         path = path4url('networks', network_id, 'action')
-        return self.post(path, data=json_data, success=success, **kwargs)
-
-    def reassign_network(self, network_id, project):
         req = {'reassign': {'project': project}}
-        r = self.networks_action_post(network_id, json_data=req, success=200)
+        r = self.post(path, json=req, success=200, **kwargs)
         return r.headers
 
     def list_ports(self, detail=None):
@@ -257,7 +250,7 @@ class CycladesNetworkClient(NetworkClient):
             floatingip['floating_network_id'] = floating_network_id
         if floating_ip_address:
             floatingip['floating_ip_address'] = floating_ip_address
-        if project_id:
+        if project_id is not None:
             floatingip['project'] = project_id
         r = self.floatingips_post(
             json_data=dict(floatingip=floatingip), success=200)
diff --git a/kamaki/clients/network/__init__.py b/kamaki/clients/network/__init__.py
index 92f8fd2..ece8b4e 100644
--- a/kamaki/clients/network/__init__.py
+++ b/kamaki/clients/network/__init__.py
@@ -331,9 +331,7 @@ class NetworkClient(NetworkRestClient, Waiter):
 
     def create_floatingip(
             self, floating_network_id,
-            floating_ip_address='', port_id='', fixed_ip_address='',
-            args=None):
-        """Cyclades do not use port_id and fixed_ip_address"""
+            floating_ip_address='', port_id='', fixed_ip_address=''):
         floatingip = dict(floating_network_id=floating_network_id)
         if floating_ip_address:
             floatingip['floating_ip_address'] = floating_ip_address
@@ -341,8 +339,6 @@ class NetworkClient(NetworkRestClient, Waiter):
             floatingip['port_id'] = port_id
         if fixed_ip_address:
             floatingip['fixed_ip_address'] = fixed_ip_address
-        if args is not None:
-            floatingip.update(args)
         r = self.floatingips_post(
             json_data=dict(floatingip=floatingip), success=200)
         return r.json['floatingip']
