Revision 1ad949a7 kamaki/clients/network/__init__.py

b/kamaki/clients/network/__init__.py
320 320
            port['security_groups'] = security_groups
321 321
        r = self.ports_put(port_id, json_data=dict(port=port), success=201)
322 322
        return r.json['port']
323

  
324
    def list_floatingip(self):
325
        r = self.floatingips_get(success=200)
326
        return r['floatingips']
327

  
328
    def get_floatingip_details(self, floatingip_id):
329
        r = self.floatingips_get(floatingip_id, success=201)
330
        return r['floatingip']
331

  
332
    def create_floatingip(
333
            self, floating_network_id,
334
            floating_ip_address='', port_id='', fixed_ip_address=''):
335
        floatingip = dict(floating_network_id=floating_network_id)
336
        if floating_ip_address != '':
337
            floatingip['floating_ip_address'] = floating_ip_address
338
        if port_id != '':
339
            floatingip['port_id'] = port_id
340
        if fixed_ip_address != '':
341
            floatingip['fixed_ip_address'] = fixed_ip_address
342
        r = self.floatingips_post(
343
            json_data=dict(floatingip=floatingip), success=201)
344
        return r.json['floatingip']
345

  
346
    def update_floatingip(
347
            self, floatingip_id,
348
            floating_ip_address='', port_id='', fixed_ip_address=''):
349
        """To nullify something optional, use None"""
350
        floatingip = dict()
351
        if floating_ip_address != '':
352
            floatingip['floating_ip_address'] = floating_ip_address
353
        if port_id != '':
354
            floatingip['port_id'] = port_id
355
        if fixed_ip_address != '':
356
            floatingip['fixed_ip_address'] = fixed_ip_address
357
        r = self.floatingips_put(
358
            floatingip_id, json_data=dict(floatingip=floatingip), success=201)
359
        return r['floatingip']
360

  
361
    def delete_floatingip(self, floatingip_id):
362
        r = self.floatingips_delete(floatingip_id, success=204)
363
        return r.headers

Also available in: Unified diff