~joeborg/charms/trusty/contrail-configuration/rbac-switch

« back to all changes in this revision

Viewing changes to scripts/deactivate_floating_pool.py

  • Committer: Robert Ayres
  • Date: 2015-04-24 14:27:43 UTC
  • Revision ID: robert.ayres@canonical.com-20150424142743-3mnfmmgs50sdqysh
Add floating pool functionality

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
"""Deactivate Floating IP pool for project.
 
4
 
 
5
This is a workaround whilst OpenContrail doesn't provide the needed
 
6
functionality in *_floating_pool.py scripts.
 
7
"""
 
8
 
 
9
import argparse
 
10
 
 
11
from vnc_api import vnc_api
 
12
 
 
13
parser = argparse.ArgumentParser()
 
14
 
 
15
parser.add_argument("project_name", help="Colon separated fully qualified name")
 
16
 
 
17
parser.add_argument("floating_ip_pool_name",
 
18
                    help="Name of the floating IP pool")
 
19
 
 
20
parser.add_argument("--api_server_ip", help="IP address of api server",
 
21
                    default="127.0.0.1")
 
22
 
 
23
parser.add_argument("--api_server_port", help="Port of api server",
 
24
                    default="8082")
 
25
 
 
26
parser.add_argument("--admin_user", help="Name of keystone admin user")
 
27
 
 
28
parser.add_argument("--admin_password", help="Password of keystone admin user")
 
29
 
 
30
parser.add_argument("--admin_tenant_name",
 
31
                    help="Tenant name for keystone admin user")
 
32
 
 
33
args = parser.parse_args()
 
34
 
 
35
vnc_lib = vnc_api.VncApi(api_server_host=args.api_server_ip,
 
36
                         api_server_port=args.api_server_port,
 
37
                         username=args.admin_user,
 
38
                         password=args.admin_password,
 
39
                         tenant_name=args.admin_tenant_name)
 
40
 
 
41
project = vnc_lib.project_read(fq_name=args.project_name.split(":"))
 
42
pool = vnc_lib.floating_ip_pool_read(fq_name=args.floating_ip_pool_name.split(":"))
 
43
project.del_floating_ip_pool(pool)
 
44
vnc_lib.project_update(project)