commit d5841e902a324bcfa3575c5c8891f531d0acd2e1
Author: Giorgos Korfiatis <gkorf@grnet.gr>
Date:   Mon Sep 16 15:03:42 2013 +0300

    Adapt cyclades commands for new projects
    
    Add optional argument --project in create subcommands;
    add subcommand reassign for servers, networks and ips.

diff --git a/kamaki/clients/cyclades/__init__.py b/kamaki/clients/cyclades/__init__.py
index 02ea9d0..c9e5817 100644
--- a/kamaki/clients/cyclades/__init__.py
+++ b/kamaki/clients/cyclades/__init__.py
@@ -42,7 +42,7 @@ class CycladesClient(CycladesRestClient, Waiter):
 
     def create_server(
             self, name, flavor_id, image_id,
-            metadata=None, personality=None, networks=None):
+            metadata=None, personality=None, networks=None, project=None):
         """Submit request to create a new server
 
         :param name: (str)
@@ -64,6 +64,8 @@ class CycladesClient(CycladesRestClient, Waiter):
             ATTENTION: Empty list is different to None. None means ' do not
             mention it', empty list means 'automatically get an ip'
 
+        :param project: the project where to assign the server
+
         :returns: a dict with the new virtual server details
 
         :raises ClientError: wraps request errors
@@ -78,7 +80,8 @@ class CycladesClient(CycladesRestClient, Waiter):
 
         return super(CycladesClient, self).create_server(
             name, flavor_id, image_id,
-            metadata=metadata, personality=personality, networks=networks)
+            metadata=metadata, personality=personality, networks=networks,
+            project=project)
 
     def start_server(self, server_id):
         """Submit a startup request
@@ -112,6 +115,11 @@ class CycladesClient(CycladesRestClient, Waiter):
         r = self.servers_action_post(server_id, json_data=req, success=200)
         return r.json['console']
 
+    def reassign_server(self, server_id, project):
+        req = {'reassign': {'project': project}}
+        r = self.servers_action_post(server_id, json_data=req, success=200)
+        return r.headers
+
     def get_server_stats(self, server_id):
         """
         :param server_id: integer (str or int)
@@ -169,15 +177,22 @@ class CycladesNetworkClient(NetworkClient):
         r = self.get(path, success=200)
         return r.json['networks']
 
-    def create_network(self, type, name=None, shared=None):
+    def create_network(self, type, name=None, shared=None, project=None):
         req = dict(network=dict(type=type, admin_state_up=True))
         if name:
             req['network']['name'] = name
         if shared not in (None, ):
             req['network']['shared'] = bool(shared)
+        if project is not None:
+            req['network']['project'] = project
         r = self.networks_post(json_data=req, success=201)
         return r.json['network']
 
+    def reassign_network(self, network_id, project):
+        req = {'reassign': {'project': project}}
+        r = self.networks_action_post(network_id, json_data=req, success=200)
+        return r.headers
+
     def list_ports(self, detail=None):
         path = path4url('ports', 'detail' if detail else '')
         r = self.get(path, success=200)
@@ -204,7 +219,8 @@ class CycladesNetworkClient(NetworkClient):
         r = self.ports_post(json_data=dict(port=port), success=201)
         return r.json['port']
 
-    def create_floatingip(self, floating_network_id, floating_ip_address=''):
+    def create_floatingip(self, floating_network_id, floating_ip_address='',
+                          project=None):
         return super(CycladesNetworkClient, self).create_floatingip(
             floating_network_id, floating_ip_address=floating_ip_address)
 
@@ -212,3 +228,7 @@ class CycladesNetworkClient(NetworkClient):
         """To nullify something optional, use None"""
         return super(CycladesNetworkClient, self).update_floatingip(
             floating_network_id, floating_ip_address=floating_ip_address)
+
+    def reassign_floating_ip(self, floating_network_id, project):
+        req = {'reassign': {'project': project}}
+        r = self.floating_ip_action_post(floating_network_id, json_data=req)
