From f00ff74385318e74c9ff0194f840397cea21b989 Mon Sep 17 00:00:00 2001 From: Chandra Mohan Babu Nadiminti Date: Wed, 10 Sep 2014 15:53:46 -0500 Subject: [PATCH 1/2] LBaaS and Service-VM code from nsao-neutronclient-havana Change-Id: I801b218642d5c6010d72672972b0380d7aa99291 --- .../neutron/v2_0/lb/sslassociation.py | 118 ++++++++++++++ .../neutron/v2_0/lb/sslcertificate.py | 86 +++++++++++ neutronclient/neutron/v2_0/lb/sslpolicy.py | 110 +++++++++++++ .../neutron/v2_0/lb/ssltrustedcertificate.py | 80 ++++++++++ .../neutron/v2_0/servicevm/__init__.py | 0 .../neutron/v2_0/servicevm/devicetemplate.py | 109 +++++++++++++ neutronclient/v2_0/client.py | 144 +++++++++++++++++- 7 files changed, 646 insertions(+), 1 deletion(-) create mode 100644 neutronclient/neutron/v2_0/lb/sslassociation.py create mode 100644 neutronclient/neutron/v2_0/lb/sslcertificate.py create mode 100644 neutronclient/neutron/v2_0/lb/sslpolicy.py create mode 100644 neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py create mode 100644 neutronclient/neutron/v2_0/servicevm/__init__.py create mode 100755 neutronclient/neutron/v2_0/servicevm/devicetemplate.py diff --git a/neutronclient/neutron/v2_0/lb/sslassociation.py b/neutronclient/neutron/v2_0/lb/sslassociation.py new file mode 100644 index 000000000..fa45862f4 --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/sslassociation.py @@ -0,0 +1,118 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + +class ShowSslAssociation(neutronV20.ShowCommand): + + """Show information of a given healthmonitor.""" + + resource = 'ssl_association' + log = logging.getLogger(__name__ + '.ShowSslAssociation') + + + +class AssociateSslPolicy(neutronV20.NeutronCommand): + """Associate SSL policy with a VIP""" + + log = logging.getLogger(__name__ + '.AssociateSslPolicy') + resource = 'ssl_association' + + def get_parser(self, prog_name): + parser = super(AssociateSslPolicy, self).get_parser(prog_name) + + parser.add_argument( + 'vip_id', metavar='VIP', + help=_('Id of VIP')) + + parser.add_argument( + 'ssl_policy_id', metavar='SSL_POLICY_ID', + help=_('SSL Policy to associate')) + + parser.add_argument( + '--ssl_trusted_certificate_id', + help=_('SSL Trusted Certificate to associate')) + + parser.add_argument( + '--ssl_certificate_id', + help=_('SSL certificate to associate')) + + parser.add_argument( + '--private_key', + help=_('Private key for the SSL certificate')) + return parser + + def run(self, parsed_args): + neutron_client = self.get_client() + neutron_client.format = parsed_args.request_format + body = {'ssl_association': { + 'id': parsed_args.vip_id, + 'ssl_policy':{'id':parsed_args.ssl_policy_id}, + 'ssl_certificates': [], + 'ssl_trusted_certificates':[], + }} + if parsed_args.ssl_certificate_id: + body[self.resource]['ssl_certificates'].append( + {'id':parsed_args.ssl_certificate_id, + 'private_key': parsed_args.private_key + }) + + if parsed_args.ssl_trusted_certificate_id: + body[self.resource]['ssl_trusted_certificates'].append( + {'id':parsed_args.ssl_trusted_certificate_id }) + + neutronV20.update_dict(parsed_args, body[self.resource], + ['tenant_id']) + + vip_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, 'vip', parsed_args.vip_id) + neutron_client.create_ssl_policy_association(vip_id, body) + + +class DisassociateSslPolicy(neutronV20.NeutronCommand): + """Remove a mapping from a health monitor to a pool.""" + + log = logging.getLogger(__name__ + '.DisassociateSslPolicy') + resource = 'ssl_association' + + def get_parser(self, prog_name): + parser = super(DisassociateSslPolicy, self).get_parser(prog_name) + parser.add_argument( + 'vip_id', metavar='VIP_ID', + help=_('ID of the VIP to be disassociated with the SSL Policy')) + parser.add_argument( + 'ssl_policy_id', metavar='SSL_POLICY_ID', + help=_('SSL Policy to associate')) + return parser + + def run(self, parsed_args): + neutron_client = self.get_client() + neutron_client.format = parsed_args.request_format + + vip_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, 'vip', parsed_args.vip_id) + + ssl_policy_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, 'ssl_policy', parsed_args.ssl_policy_id) + + neutron_client.delete_ssl_policy_association(vip_id, ssl_policy_id) + diff --git a/neutronclient/neutron/v2_0/lb/sslcertificate.py b/neutronclient/neutron/v2_0/lb/sslcertificate.py new file mode 100644 index 000000000..2369ec9ec --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/sslcertificate.py @@ -0,0 +1,86 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class ListSslCertificate(neutronV20.ListCommand): + """List SSL Certificates that belong to a given tenant.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.ListSslCertificate') + list_columns = ['id', 'tenant_id', 'name', 'certificate', 'passphrase', 'certificate_chain'] + pagination_support = True + sorting_support = True + + +class ShowSslCertificate(neutronV20.ShowCommand): + """Show information of a given SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.ShowSslCertificate') + + +class CreateSslCertificate(neutronV20.CreateCommand): + """Create a SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.CreateSslCertificate') + + def add_known_arguments(self, parser): + parser.add_argument( + '--name', + required=True, + help=_('Name of the certificate')) + parser.add_argument( + '--certificate', + required=True, + help=_('Certificate content')) + parser.add_argument( + '--passphrase', + help=_('Passphrase used to encrypt the private key')) + parser.add_argument( + '--certificate_chain', + help=_('Chain of the issuer\'s certificates')) + + def args2body(self, parsed_args): + body = { + self.resource: { + }, + } + neutronV20.update_dict(parsed_args, body[self.resource], + ['name', 'certificate', 'passphrase', 'certificate_chain', 'tenant_id']) + return body + + +class UpdateSslCertificate(neutronV20.UpdateCommand): + """Update a given SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.UpdateSslCertificate') + + +class DeleteSslCertificate(neutronV20.DeleteCommand): + """Delete a given SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.DeleteSslCertificate') diff --git a/neutronclient/neutron/v2_0/lb/sslpolicy.py b/neutronclient/neutron/v2_0/lb/sslpolicy.py new file mode 100644 index 000000000..730b53b68 --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/sslpolicy.py @@ -0,0 +1,110 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class ListSslPolicy(neutronV20.ListCommand): + """List SSL Policies that belong to a given tenant.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.ListSslPolicy') + list_columns = ['id', 'name', 'description', 'front_end_enabled', 'front_end_protocols', + 'front_end_cipher_suites', 'back_end_enabled', 'back_end_protocols', + 'back_end_cipher_suites'] + pagination_support = True + sorting_support = True + + +class ShowSslPolicy(neutronV20.ShowCommand): + """Show information of a given SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.ShowSslPolicy') + + +class CreateSslPolicy(neutronV20.CreateCommand): + """Create a SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.CreateSslPolicy') + + def add_known_arguments(self, parser): + parser.add_argument( + '--front_end_enabled', + required=True, + choices=['True', 'False'], + help=_('Enable front end SSL offloading')) + parser.add_argument( + '--front_end_protocols', + help=_('Front end protocol to be used.Comma seperated list of SSLv2,SSLv3,TLSv1')) + parser.add_argument( + '--front_end_cipher_suites', + choices=['ALL', 'LOW', 'MEDIUM', 'HIGH'], + help=_('Openssl cipher suites.One of ALL,HIGH,MEDIUM,LOW')) + parser.add_argument( + '--back_end_enabled', + required=True, + choices=['True', 'False'], + help=_('Enable back end SSL offloading')) + parser.add_argument( + '--back_end_protocols', + help=_('Back end protocol to be used.Comma seperated list of SSLv2,SSLv3,TLSv1')) + parser.add_argument( + '--back_end_cipher_suites', + choices=['ALL', 'LOW', 'MEDIUM', 'HIGH'], + help=_('Openssl cipher suites.One of ALL,HIGH,MEDIUM,LOW')) + parser.add_argument( + '--description', + help=_('Description of the SSL Policy')) + parser.add_argument( + '--name', + required=True, + help=_('Name of the SSL Policy')) + + def args2body(self, parsed_args): + body = { + self.resource: { + }, + } + neutronV20.update_dict(parsed_args, body[self.resource], + ['name', 'description', 'front_end_enabled', 'front_end_protocols', + 'front_end_cipher_suites', 'back_end_enabled', 'back_end_protocols', + 'back_end_cipher_suites', 'tenant_id']) + return body + + +class UpdateSslPolicy(neutronV20.UpdateCommand): + """Update a given SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.UpdateSslPolicy') + + +class DeleteSslPolicy(neutronV20.DeleteCommand): + """Delete a given SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.DeleteSslPolicy') + + + diff --git a/neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py b/neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py new file mode 100644 index 000000000..fc814683d --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py @@ -0,0 +1,80 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class ListSslTrustedCertificate(neutronV20.ListCommand): + """List SSL Trusted Certificates that belong to a given tenant.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.ListSslTrustedCertificate') + list_columns = ['id', 'name', 'tenant_id', 'certificate', 'vips'] + pagination_support = True + sorting_support = True + + +class ShowSslTrustedCertificate(neutronV20.ShowCommand): + """Show information of a given SSL Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.ShowSslTrustedCertificate') + + +class CreateSslTrustedCertificate(neutronV20.CreateCommand): + """Create a SSL Trusted Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.CreateSslTrustedCertificate') + + def add_known_arguments(self, parser): + parser.add_argument( + '--name', + required=True, + help=_('Name of the certificate')) + parser.add_argument( + '--certificate', + required=True, + help=_('Certificate content')) + + def args2body(self, parsed_args): + body = { + self.resource: { + }, + } + neutronV20.update_dict(parsed_args, body[self.resource], + ['name', 'certificate', 'tenant_id']) + return body + + +class UpdateSslTrustedCertificate(neutronV20.UpdateCommand): + """Update a given SSL Trusted Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.UpdateSslTrustedCertificate') + + +class DeleteSslTrustedCertificate(neutronV20.DeleteCommand): + """Delete a given SSL Trusted Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.DeleteSslTrustedCertificate') diff --git a/neutronclient/neutron/v2_0/servicevm/__init__.py b/neutronclient/neutron/v2_0/servicevm/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/neutronclient/neutron/v2_0/servicevm/devicetemplate.py b/neutronclient/neutron/v2_0/servicevm/devicetemplate.py new file mode 100755 index 000000000..f7a2f9686 --- /dev/null +++ b/neutronclient/neutron/v2_0/servicevm/devicetemplate.py @@ -0,0 +1,109 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging +import argparse +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ +from neutronclient.common import utils +import pdb + +class ListDeviceTemplate(neutronV20.ListCommand): + """List device templates that belong to a given tenant.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.ListDeviceTemplate') + list_columns = ['id', 'name', 'description', 'device_driver', 'mgmt_driver', + 'service_types', 'attributes'] + pagination_support = True + sorting_support = True + + +class ShowDeviceTemplate(neutronV20.ShowCommand): + """Show information of a given device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.ShowDeviceTemplate') + + +class CreateDeviceTemplate(neutronV20.CreateCommand): + """Create a device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.CreateDeviceTemplate') + def add_known_arguments(self, parser): + mandatory_attributes= "\n MANDATORY-ATTRIBUTES : ['admin_user', 'admin_password','platform'] \n " + optional_attributes = """ 'OPTIONAL-ATTRIBUTES : [enable_ha','version','throughput_level', + 'feature_level','availability_zone','availability_zone_primary', + 'availability_zone_secondary','license_category']""" + parser.add_argument( + '--description', + help='description of the device template') + parser.add_argument( + '--service-type', + required=True, dest='service_types', + #choices=['lbaas', 'l3_router'], + help='the service type of the Cisco device template are [l3router,lbaas]') + parser.add_argument( + '--name', + required=True, + help='the name of the device template') + parser.add_argument( + '--attribute', + dest='attributes', + required=True, + help='attributes for the Cisco device template are ' + + mandatory_attributes + optional_attributes) + parser.add_argument( + '--scope', + help=' Scope of the device template, for global scope --scope=global') + def args2body(self, parsed_args): + body = { + 'device_template': { + 'name': parsed_args.name, + 'description': parsed_args.description, + 'mgmt_driver': 'noop', + 'device_driver': 'noop', + 'scope': parsed_args.scope + } + } + attr_dict = utils.str2dict(parsed_args.attributes) + body['device_template'].update({'attributes':attr_dict}) + services = [] + serv_dict = utils.str2dict(parsed_args.service_types) + services.append(serv_dict) + body['device_template'].update({'service_types':services}) + if parsed_args.tenant_id: + body['device_template'].update({'tenant_id': parsed_args.tenant_id}) + return body + + +class UpdateDeviceTemplate(neutronV20.UpdateCommand): + """Update a given device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.UpdateDeviceTemplate') + + +class DeleteDeviceTemplate(neutronV20.DeleteCommand): + """Delete a given device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.DeleteDeviceTemplate') + diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 3a90daa8b..f110c6a4c 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -189,6 +189,14 @@ class Client(object): associate_pool_health_monitors_path = "/lb/pools/%s/health_monitors" disassociate_pool_health_monitors_path = ( "/lb/pools/%(pool)s/health_monitors/%(health_monitor)s") + associate_vip_ssl_policy_path = "/lb/vips/%s/ssl_associations" + disassociate_vip_ssl_policy_path = "/lb/vips/%(vip)s/ssl_associations/%(ssl_policy)s" + ssl_policies_path = "/lb/ssl_policies" + ssl_policy_path = "/lb/ssl_policies/%s" + ssl_certificates_path = "/lb/ssl_certificates" + ssl_certificate_path = "/lb/ssl_certificates/%s" + ssl_trusted_certificates_path = "/lb/ssl_trusted_certificates" + ssl_trusted_certificate_path = "/lb/ssl_trusted_certificates/%s" qos_queues_path = "/qos-queues" qos_queue_path = "/qos-queues/%s" agents_path = "/agents" @@ -222,6 +230,8 @@ class Client(object): firewall_policy_remove_path = "/fw/firewall_policies/%s/remove_rule" firewalls_path = "/fw/firewalls" firewall_path = "/fw/firewalls/%s" + device_templates_path = "/servicevm/device-templates" + device_template_path = "/servicevm/device-templates/%s" # API has no way to report plurals, so we have to hard code them EXTED_PLURALS = {'routers': 'router', @@ -238,13 +248,20 @@ class Client(object): 'pools': 'pool', 'members': 'member', 'health_monitors': 'health_monitor', + 'ssl_policies': 'ssl_policy', + 'ssl_certificates': 'ssl_certificate', + 'ssl_trusted_certificates': 'ssl_trusted_certificate', + 'ssl_associations': 'ssl_associate', 'quotas': 'quota', 'service_providers': 'service_provider', 'firewall_rules': 'firewall_rule', 'firewall_policies': 'firewall_policy', 'firewalls': 'firewall', 'metering_labels': 'metering_label', - 'metering_label_rules': 'metering_label_rule' + 'metering_label_rules': 'metering_label_rule', + 'service_deploy_policies': 'service_deploy_policy', + 'device_templates': 'device_template', + 'device-templates': 'device-template', } # 8192 Is the default max URI len for eventlet.wsgi.server MAX_URI_LEN = 8192 @@ -775,6 +792,101 @@ def disassociate_health_monitor(self, pool, health_monitor): path = (self.disassociate_pool_health_monitors_path % {'pool': pool, 'health_monitor': health_monitor}) return self.delete(path) + @APIParamsCall + def list_ssl_policies(self, retrieve_all=True, **_params): + """Fetches a list of all load balancer health monitors for a tenant.""" + # Pass filters in "params" argument to do_request + return self.list('ssl_policies', self.ssl_policies_path, + retrieve_all, **_params) + + @APIParamsCall + def show_ssl_policy(self, ssl_policy, **_params): + """Fetches information of a certain load balancer health monitor.""" + return self.get(self.ssl_policy_path % (ssl_policy), + params=_params) + + @APIParamsCall + def create_ssl_policy(self, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.ssl_policies_path, body=body) + + @APIParamsCall + def update_ssl_policy(self, ssl_policy, body=None): + """Updates a load balancer health monitor.""" + return self.put(self.ssl_policy_path % (ssl_policy), body=body) + + @APIParamsCall + def delete_ssl_policy(self, ssl_policy): + """Deletes the specified load balancer health monitor.""" + return self.delete(self.ssl_policy_path % (ssl_policy)) + @APIParamsCall + def list_ssl_certificates(self, retrieve_all=True, **_params): + """Fetches a list of all load balancer health monitors for a tenant.""" + # Pass filters in "params" argument to do_request + return self.list('ssl_certificates', self.ssl_certificates_path, + retrieve_all, **_params) + + + @APIParamsCall + def show_ssl_certificate(self, ssl_certificate, **_params): + """Fetches information of a certain load balancer health monitor.""" + return self.get(self.ssl_certificate_path % (ssl_certificate), + params=_params) + + @APIParamsCall + def create_ssl_certificate(self, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.ssl_certificates_path, body=body) + + @APIParamsCall + def update_ssl_certificate(self, ssl_certificate, body=None): + """Updates a load balancer health monitor.""" + return self.put(self.ssl_certificate_path % (ssl_certificate), body=body) + + @APIParamsCall + def delete_ssl_certificate(self, ssl_certificate): + """Deletes the specified load balancer health monitor.""" + return self.delete(self.ssl_certificate_path % (ssl_certificate)) + + @APIParamsCall + def list_ssl_trusted_certificates(self, retrieve_all=True, **_params): + """Fetches a list of all load balancer health monitors for a tenant.""" + # Pass filters in "params" argument to do_request + return self.list('ssl_trusted_certificates', self.ssl_trusted_certificates_path, + retrieve_all, **_params) + + @APIParamsCall + def show_ssl_trusted_certificate(self, ssl_trusted_certificate, **_params): + """Fetches information of a certain load balancer health monitor.""" + return self.get(self.ssl_trusted_certificate_path % (ssl_trusted_certificate), + params=_params) + + @APIParamsCall + def create_ssl_trusted_certificate(self, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.ssl_trusted_certificates_path, body=body) + + @APIParamsCall + def update_ssl_trusted_certificate(self, ssl_trusted_certificate, body=None): + """Updates a load balancer health monitor.""" + return self.put(self.ssl_trusted_certificate_path % (ssl_trusted_certificate), body=body) + + @APIParamsCall + def delete_ssl_trusted_certificate(self, ssl_trusted_certificate): + """Deletes the specified load balancer health monitor.""" + return self.delete(self.ssl_trusted_certificate_path % (ssl_trusted_certificate)) + + @APIParamsCall + def create_ssl_policy_association(self, vip, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.associate_vip_ssl_policy_path% (vip), body=body) + + @APIParamsCall + def delete_ssl_policy_association(self, vip, ssl_policy): + """Creates a new load balancer health monitor.""" + path = (self.disassociate_vip_ssl_policy_path % + {'vip': vip, 'ssl_policy': ssl_policy}) + return self.delete(path) @APIParamsCall def create_qos_queue(self, body=None): @@ -1138,6 +1250,36 @@ def show_metering_label_rule(self, metering_label_rule, **_params): """Fetches information of a certain metering label rule.""" return self.get(self.metering_label_rule_path % (metering_label_rule), params=_params) + @APIParamsCall + def list_device_templates(self, retrieve_all=True, **_params): + """Fetches a list of all device templates for a tenant.""" + # Pass filters in "params" argument to do_request + + return self.list('device_templates', self.device_templates_path, + retrieve_all, **_params) + + @APIParamsCall + def show_device_template(self, device_template, **_params): + """Fetches information of a certain device template.""" + return self.get(self.device_template_path % (device_template), + params=_params) + + @APIParamsCall + def create_device_template(self, body=None): + """Creates a new device template.""" + return self.post(self.device_templates_path, body=body) + + @APIParamsCall + def update_device_template(self, device_template, body=None): + """Updates a device template.""" + return self.put(self.device_template_path % (device_template), + body=body) + + @APIParamsCall + def delete_device_template(self, device_template): + """Deletes the specified device template.""" + return self.delete(self.device_template_path % (device_template)) + def __init__(self, **kwargs): """Initialize a new client for the Neutron v2.0 API.""" From eda71cd32b0e62113e9aadc7e27186c23bd1ab50 Mon Sep 17 00:00:00 2001 From: Chandra Mohan Babu Nadiminti Date: Mon, 15 Sep 2014 15:36:24 -0500 Subject: [PATCH 2/2] LBaaS and Service-VM code from nsao-neutronclient-havana Change-Id: I801b218642d5c6010d72672972b0380d7aa99291 --- .../neutron/v2_0/lb/sslassociation.py | 118 ++++++++++++++ .../neutron/v2_0/lb/sslcertificate.py | 86 +++++++++++ neutronclient/neutron/v2_0/lb/sslpolicy.py | 110 +++++++++++++ .../neutron/v2_0/lb/ssltrustedcertificate.py | 80 ++++++++++ .../neutron/v2_0/servicevm/__init__.py | 0 .../neutron/v2_0/servicevm/devicetemplate.py | 109 +++++++++++++ neutronclient/shell.py | 29 ++++ neutronclient/v2_0/client.py | 144 +++++++++++++++++- 8 files changed, 675 insertions(+), 1 deletion(-) create mode 100644 neutronclient/neutron/v2_0/lb/sslassociation.py create mode 100644 neutronclient/neutron/v2_0/lb/sslcertificate.py create mode 100644 neutronclient/neutron/v2_0/lb/sslpolicy.py create mode 100644 neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py create mode 100644 neutronclient/neutron/v2_0/servicevm/__init__.py create mode 100755 neutronclient/neutron/v2_0/servicevm/devicetemplate.py diff --git a/neutronclient/neutron/v2_0/lb/sslassociation.py b/neutronclient/neutron/v2_0/lb/sslassociation.py new file mode 100644 index 000000000..fa45862f4 --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/sslassociation.py @@ -0,0 +1,118 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + +class ShowSslAssociation(neutronV20.ShowCommand): + + """Show information of a given healthmonitor.""" + + resource = 'ssl_association' + log = logging.getLogger(__name__ + '.ShowSslAssociation') + + + +class AssociateSslPolicy(neutronV20.NeutronCommand): + """Associate SSL policy with a VIP""" + + log = logging.getLogger(__name__ + '.AssociateSslPolicy') + resource = 'ssl_association' + + def get_parser(self, prog_name): + parser = super(AssociateSslPolicy, self).get_parser(prog_name) + + parser.add_argument( + 'vip_id', metavar='VIP', + help=_('Id of VIP')) + + parser.add_argument( + 'ssl_policy_id', metavar='SSL_POLICY_ID', + help=_('SSL Policy to associate')) + + parser.add_argument( + '--ssl_trusted_certificate_id', + help=_('SSL Trusted Certificate to associate')) + + parser.add_argument( + '--ssl_certificate_id', + help=_('SSL certificate to associate')) + + parser.add_argument( + '--private_key', + help=_('Private key for the SSL certificate')) + return parser + + def run(self, parsed_args): + neutron_client = self.get_client() + neutron_client.format = parsed_args.request_format + body = {'ssl_association': { + 'id': parsed_args.vip_id, + 'ssl_policy':{'id':parsed_args.ssl_policy_id}, + 'ssl_certificates': [], + 'ssl_trusted_certificates':[], + }} + if parsed_args.ssl_certificate_id: + body[self.resource]['ssl_certificates'].append( + {'id':parsed_args.ssl_certificate_id, + 'private_key': parsed_args.private_key + }) + + if parsed_args.ssl_trusted_certificate_id: + body[self.resource]['ssl_trusted_certificates'].append( + {'id':parsed_args.ssl_trusted_certificate_id }) + + neutronV20.update_dict(parsed_args, body[self.resource], + ['tenant_id']) + + vip_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, 'vip', parsed_args.vip_id) + neutron_client.create_ssl_policy_association(vip_id, body) + + +class DisassociateSslPolicy(neutronV20.NeutronCommand): + """Remove a mapping from a health monitor to a pool.""" + + log = logging.getLogger(__name__ + '.DisassociateSslPolicy') + resource = 'ssl_association' + + def get_parser(self, prog_name): + parser = super(DisassociateSslPolicy, self).get_parser(prog_name) + parser.add_argument( + 'vip_id', metavar='VIP_ID', + help=_('ID of the VIP to be disassociated with the SSL Policy')) + parser.add_argument( + 'ssl_policy_id', metavar='SSL_POLICY_ID', + help=_('SSL Policy to associate')) + return parser + + def run(self, parsed_args): + neutron_client = self.get_client() + neutron_client.format = parsed_args.request_format + + vip_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, 'vip', parsed_args.vip_id) + + ssl_policy_id = neutronV20.find_resourceid_by_name_or_id( + neutron_client, 'ssl_policy', parsed_args.ssl_policy_id) + + neutron_client.delete_ssl_policy_association(vip_id, ssl_policy_id) + diff --git a/neutronclient/neutron/v2_0/lb/sslcertificate.py b/neutronclient/neutron/v2_0/lb/sslcertificate.py new file mode 100644 index 000000000..2369ec9ec --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/sslcertificate.py @@ -0,0 +1,86 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class ListSslCertificate(neutronV20.ListCommand): + """List SSL Certificates that belong to a given tenant.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.ListSslCertificate') + list_columns = ['id', 'tenant_id', 'name', 'certificate', 'passphrase', 'certificate_chain'] + pagination_support = True + sorting_support = True + + +class ShowSslCertificate(neutronV20.ShowCommand): + """Show information of a given SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.ShowSslCertificate') + + +class CreateSslCertificate(neutronV20.CreateCommand): + """Create a SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.CreateSslCertificate') + + def add_known_arguments(self, parser): + parser.add_argument( + '--name', + required=True, + help=_('Name of the certificate')) + parser.add_argument( + '--certificate', + required=True, + help=_('Certificate content')) + parser.add_argument( + '--passphrase', + help=_('Passphrase used to encrypt the private key')) + parser.add_argument( + '--certificate_chain', + help=_('Chain of the issuer\'s certificates')) + + def args2body(self, parsed_args): + body = { + self.resource: { + }, + } + neutronV20.update_dict(parsed_args, body[self.resource], + ['name', 'certificate', 'passphrase', 'certificate_chain', 'tenant_id']) + return body + + +class UpdateSslCertificate(neutronV20.UpdateCommand): + """Update a given SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.UpdateSslCertificate') + + +class DeleteSslCertificate(neutronV20.DeleteCommand): + """Delete a given SSL Certificate.""" + + resource = 'ssl_certificate' + log = logging.getLogger(__name__ + '.DeleteSslCertificate') diff --git a/neutronclient/neutron/v2_0/lb/sslpolicy.py b/neutronclient/neutron/v2_0/lb/sslpolicy.py new file mode 100644 index 000000000..730b53b68 --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/sslpolicy.py @@ -0,0 +1,110 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class ListSslPolicy(neutronV20.ListCommand): + """List SSL Policies that belong to a given tenant.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.ListSslPolicy') + list_columns = ['id', 'name', 'description', 'front_end_enabled', 'front_end_protocols', + 'front_end_cipher_suites', 'back_end_enabled', 'back_end_protocols', + 'back_end_cipher_suites'] + pagination_support = True + sorting_support = True + + +class ShowSslPolicy(neutronV20.ShowCommand): + """Show information of a given SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.ShowSslPolicy') + + +class CreateSslPolicy(neutronV20.CreateCommand): + """Create a SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.CreateSslPolicy') + + def add_known_arguments(self, parser): + parser.add_argument( + '--front_end_enabled', + required=True, + choices=['True', 'False'], + help=_('Enable front end SSL offloading')) + parser.add_argument( + '--front_end_protocols', + help=_('Front end protocol to be used.Comma seperated list of SSLv2,SSLv3,TLSv1')) + parser.add_argument( + '--front_end_cipher_suites', + choices=['ALL', 'LOW', 'MEDIUM', 'HIGH'], + help=_('Openssl cipher suites.One of ALL,HIGH,MEDIUM,LOW')) + parser.add_argument( + '--back_end_enabled', + required=True, + choices=['True', 'False'], + help=_('Enable back end SSL offloading')) + parser.add_argument( + '--back_end_protocols', + help=_('Back end protocol to be used.Comma seperated list of SSLv2,SSLv3,TLSv1')) + parser.add_argument( + '--back_end_cipher_suites', + choices=['ALL', 'LOW', 'MEDIUM', 'HIGH'], + help=_('Openssl cipher suites.One of ALL,HIGH,MEDIUM,LOW')) + parser.add_argument( + '--description', + help=_('Description of the SSL Policy')) + parser.add_argument( + '--name', + required=True, + help=_('Name of the SSL Policy')) + + def args2body(self, parsed_args): + body = { + self.resource: { + }, + } + neutronV20.update_dict(parsed_args, body[self.resource], + ['name', 'description', 'front_end_enabled', 'front_end_protocols', + 'front_end_cipher_suites', 'back_end_enabled', 'back_end_protocols', + 'back_end_cipher_suites', 'tenant_id']) + return body + + +class UpdateSslPolicy(neutronV20.UpdateCommand): + """Update a given SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.UpdateSslPolicy') + + +class DeleteSslPolicy(neutronV20.DeleteCommand): + """Delete a given SSL Policy.""" + + resource = 'ssl_policy' + log = logging.getLogger(__name__ + '.DeleteSslPolicy') + + + diff --git a/neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py b/neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py new file mode 100644 index 000000000..fc814683d --- /dev/null +++ b/neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py @@ -0,0 +1,80 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging + +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class ListSslTrustedCertificate(neutronV20.ListCommand): + """List SSL Trusted Certificates that belong to a given tenant.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.ListSslTrustedCertificate') + list_columns = ['id', 'name', 'tenant_id', 'certificate', 'vips'] + pagination_support = True + sorting_support = True + + +class ShowSslTrustedCertificate(neutronV20.ShowCommand): + """Show information of a given SSL Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.ShowSslTrustedCertificate') + + +class CreateSslTrustedCertificate(neutronV20.CreateCommand): + """Create a SSL Trusted Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.CreateSslTrustedCertificate') + + def add_known_arguments(self, parser): + parser.add_argument( + '--name', + required=True, + help=_('Name of the certificate')) + parser.add_argument( + '--certificate', + required=True, + help=_('Certificate content')) + + def args2body(self, parsed_args): + body = { + self.resource: { + }, + } + neutronV20.update_dict(parsed_args, body[self.resource], + ['name', 'certificate', 'tenant_id']) + return body + + +class UpdateSslTrustedCertificate(neutronV20.UpdateCommand): + """Update a given SSL Trusted Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.UpdateSslTrustedCertificate') + + +class DeleteSslTrustedCertificate(neutronV20.DeleteCommand): + """Delete a given SSL Trusted Certificate.""" + + resource = 'ssl_trusted_certificate' + log = logging.getLogger(__name__ + '.DeleteSslTrustedCertificate') diff --git a/neutronclient/neutron/v2_0/servicevm/__init__.py b/neutronclient/neutron/v2_0/servicevm/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/neutronclient/neutron/v2_0/servicevm/devicetemplate.py b/neutronclient/neutron/v2_0/servicevm/devicetemplate.py new file mode 100755 index 000000000..f7a2f9686 --- /dev/null +++ b/neutronclient/neutron/v2_0/servicevm/devicetemplate.py @@ -0,0 +1,109 @@ +# Copyright 2013 Mirantis Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# @author: Ilya Shakhat, Mirantis Inc. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import logging +import argparse +from neutronclient.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ +from neutronclient.common import utils +import pdb + +class ListDeviceTemplate(neutronV20.ListCommand): + """List device templates that belong to a given tenant.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.ListDeviceTemplate') + list_columns = ['id', 'name', 'description', 'device_driver', 'mgmt_driver', + 'service_types', 'attributes'] + pagination_support = True + sorting_support = True + + +class ShowDeviceTemplate(neutronV20.ShowCommand): + """Show information of a given device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.ShowDeviceTemplate') + + +class CreateDeviceTemplate(neutronV20.CreateCommand): + """Create a device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.CreateDeviceTemplate') + def add_known_arguments(self, parser): + mandatory_attributes= "\n MANDATORY-ATTRIBUTES : ['admin_user', 'admin_password','platform'] \n " + optional_attributes = """ 'OPTIONAL-ATTRIBUTES : [enable_ha','version','throughput_level', + 'feature_level','availability_zone','availability_zone_primary', + 'availability_zone_secondary','license_category']""" + parser.add_argument( + '--description', + help='description of the device template') + parser.add_argument( + '--service-type', + required=True, dest='service_types', + #choices=['lbaas', 'l3_router'], + help='the service type of the Cisco device template are [l3router,lbaas]') + parser.add_argument( + '--name', + required=True, + help='the name of the device template') + parser.add_argument( + '--attribute', + dest='attributes', + required=True, + help='attributes for the Cisco device template are ' + + mandatory_attributes + optional_attributes) + parser.add_argument( + '--scope', + help=' Scope of the device template, for global scope --scope=global') + def args2body(self, parsed_args): + body = { + 'device_template': { + 'name': parsed_args.name, + 'description': parsed_args.description, + 'mgmt_driver': 'noop', + 'device_driver': 'noop', + 'scope': parsed_args.scope + } + } + attr_dict = utils.str2dict(parsed_args.attributes) + body['device_template'].update({'attributes':attr_dict}) + services = [] + serv_dict = utils.str2dict(parsed_args.service_types) + services.append(serv_dict) + body['device_template'].update({'service_types':services}) + if parsed_args.tenant_id: + body['device_template'].update({'tenant_id': parsed_args.tenant_id}) + return body + + +class UpdateDeviceTemplate(neutronV20.UpdateCommand): + """Update a given device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.UpdateDeviceTemplate') + + +class DeleteDeviceTemplate(neutronV20.DeleteCommand): + """Delete a given device template.""" + + resource = 'device_template' + log = logging.getLogger(__name__ + '.DeleteDeviceTemplate') + diff --git a/neutronclient/shell.py b/neutronclient/shell.py index 971860446..c32d2e4c1 100644 --- a/neutronclient/shell.py +++ b/neutronclient/shell.py @@ -26,6 +26,7 @@ from cliff import app from cliff import commandmanager +from neutronclient.neutron import v2_0 as neutronV20 from neutronclient.common import clientmanager from neutronclient.common import exceptions as exc from neutronclient.common import utils @@ -41,6 +42,11 @@ from neutronclient.neutron.v2_0.lb import member as lb_member from neutronclient.neutron.v2_0.lb import pool as lb_pool from neutronclient.neutron.v2_0.lb import vip as lb_vip +from neutronclient.neutron.v2_0.lb import sslpolicy as lb_ssl_policy +from neutronclient.neutron.v2_0.lb import sslcertificate as lb_ssl_certificate +from neutronclient.neutron.v2_0.lb import ssltrustedcertificate as lb_ssl_trusted_certificate +from neutronclient.neutron.v2_0.lb import sslassociation as lb_ssl_association +from neutronclient.neutron.v2_0.servicevm import devicetemplate from neutronclient.neutron.v2_0 import metering from neutronclient.neutron.v2_0 import network from neutronclient.neutron.v2_0 import networkprofile @@ -166,6 +172,29 @@ def env(*_vars, **kwargs): 'lb-healthmonitor-disassociate': ( lb_healthmonitor.DisassociateHealthMonitor ), + 'lb-ssl-policy-list': lb_ssl_policy.ListSslPolicy, + 'lb-ssl-policy-show': lb_ssl_policy.ShowSslPolicy, + 'lb-ssl-policy-create': lb_ssl_policy.CreateSslPolicy, + 'lb-ssl-policy-update': lb_ssl_policy.UpdateSslPolicy, + 'lb-ssl-policy-delete': lb_ssl_policy.DeleteSslPolicy, + 'lb-ssl-policy-associate-show': lb_ssl_association.ShowSslAssociation, + 'lb-ssl-policy-associate': lb_ssl_association.AssociateSslPolicy, + 'lb-ssl-policy-disassociate': lb_ssl_association.DisassociateSslPolicy, + 'lb-ssl-certificate-list': lb_ssl_certificate.ListSslCertificate, + 'lb-ssl-certificate-show': lb_ssl_certificate.ShowSslCertificate, + 'lb-ssl-certificate-create': lb_ssl_certificate.CreateSslCertificate, + 'lb-ssl-certificate-update': lb_ssl_certificate.UpdateSslCertificate, + 'lb-ssl-certificate-delete': lb_ssl_certificate.DeleteSslCertificate, + 'lb-ssl-trusted-certificate-list': lb_ssl_trusted_certificate.ListSslTrustedCertificate, + 'lb-ssl-trusted-certificate-show': lb_ssl_trusted_certificate.ShowSslTrustedCertificate, + 'lb-ssl-trusted-certificate-create': lb_ssl_trusted_certificate.CreateSslTrustedCertificate, + 'lb-ssl-trusted-certificate-update': lb_ssl_trusted_certificate.UpdateSslTrustedCertificate, + 'lb-ssl-trusted-certificate-delete': lb_ssl_trusted_certificate.DeleteSslTrustedCertificate, + 'service-deploy-policy-list': devicetemplate.ListDeviceTemplate, + 'service-deploy-policy-show': devicetemplate.ShowDeviceTemplate, + 'service-deploy-policy-create': devicetemplate.CreateDeviceTemplate, + 'service-deploy-policy-update': devicetemplate.UpdateDeviceTemplate, + 'service-deploy-policy-delete': devicetemplate.DeleteDeviceTemplate, 'queue-create': qos_queue.CreateQoSQueue, 'queue-delete': qos_queue.DeleteQoSQueue, 'queue-show': qos_queue.ShowQoSQueue, diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 3a90daa8b..f110c6a4c 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -189,6 +189,14 @@ class Client(object): associate_pool_health_monitors_path = "/lb/pools/%s/health_monitors" disassociate_pool_health_monitors_path = ( "/lb/pools/%(pool)s/health_monitors/%(health_monitor)s") + associate_vip_ssl_policy_path = "/lb/vips/%s/ssl_associations" + disassociate_vip_ssl_policy_path = "/lb/vips/%(vip)s/ssl_associations/%(ssl_policy)s" + ssl_policies_path = "/lb/ssl_policies" + ssl_policy_path = "/lb/ssl_policies/%s" + ssl_certificates_path = "/lb/ssl_certificates" + ssl_certificate_path = "/lb/ssl_certificates/%s" + ssl_trusted_certificates_path = "/lb/ssl_trusted_certificates" + ssl_trusted_certificate_path = "/lb/ssl_trusted_certificates/%s" qos_queues_path = "/qos-queues" qos_queue_path = "/qos-queues/%s" agents_path = "/agents" @@ -222,6 +230,8 @@ class Client(object): firewall_policy_remove_path = "/fw/firewall_policies/%s/remove_rule" firewalls_path = "/fw/firewalls" firewall_path = "/fw/firewalls/%s" + device_templates_path = "/servicevm/device-templates" + device_template_path = "/servicevm/device-templates/%s" # API has no way to report plurals, so we have to hard code them EXTED_PLURALS = {'routers': 'router', @@ -238,13 +248,20 @@ class Client(object): 'pools': 'pool', 'members': 'member', 'health_monitors': 'health_monitor', + 'ssl_policies': 'ssl_policy', + 'ssl_certificates': 'ssl_certificate', + 'ssl_trusted_certificates': 'ssl_trusted_certificate', + 'ssl_associations': 'ssl_associate', 'quotas': 'quota', 'service_providers': 'service_provider', 'firewall_rules': 'firewall_rule', 'firewall_policies': 'firewall_policy', 'firewalls': 'firewall', 'metering_labels': 'metering_label', - 'metering_label_rules': 'metering_label_rule' + 'metering_label_rules': 'metering_label_rule', + 'service_deploy_policies': 'service_deploy_policy', + 'device_templates': 'device_template', + 'device-templates': 'device-template', } # 8192 Is the default max URI len for eventlet.wsgi.server MAX_URI_LEN = 8192 @@ -775,6 +792,101 @@ def disassociate_health_monitor(self, pool, health_monitor): path = (self.disassociate_pool_health_monitors_path % {'pool': pool, 'health_monitor': health_monitor}) return self.delete(path) + @APIParamsCall + def list_ssl_policies(self, retrieve_all=True, **_params): + """Fetches a list of all load balancer health monitors for a tenant.""" + # Pass filters in "params" argument to do_request + return self.list('ssl_policies', self.ssl_policies_path, + retrieve_all, **_params) + + @APIParamsCall + def show_ssl_policy(self, ssl_policy, **_params): + """Fetches information of a certain load balancer health monitor.""" + return self.get(self.ssl_policy_path % (ssl_policy), + params=_params) + + @APIParamsCall + def create_ssl_policy(self, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.ssl_policies_path, body=body) + + @APIParamsCall + def update_ssl_policy(self, ssl_policy, body=None): + """Updates a load balancer health monitor.""" + return self.put(self.ssl_policy_path % (ssl_policy), body=body) + + @APIParamsCall + def delete_ssl_policy(self, ssl_policy): + """Deletes the specified load balancer health monitor.""" + return self.delete(self.ssl_policy_path % (ssl_policy)) + @APIParamsCall + def list_ssl_certificates(self, retrieve_all=True, **_params): + """Fetches a list of all load balancer health monitors for a tenant.""" + # Pass filters in "params" argument to do_request + return self.list('ssl_certificates', self.ssl_certificates_path, + retrieve_all, **_params) + + + @APIParamsCall + def show_ssl_certificate(self, ssl_certificate, **_params): + """Fetches information of a certain load balancer health monitor.""" + return self.get(self.ssl_certificate_path % (ssl_certificate), + params=_params) + + @APIParamsCall + def create_ssl_certificate(self, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.ssl_certificates_path, body=body) + + @APIParamsCall + def update_ssl_certificate(self, ssl_certificate, body=None): + """Updates a load balancer health monitor.""" + return self.put(self.ssl_certificate_path % (ssl_certificate), body=body) + + @APIParamsCall + def delete_ssl_certificate(self, ssl_certificate): + """Deletes the specified load balancer health monitor.""" + return self.delete(self.ssl_certificate_path % (ssl_certificate)) + + @APIParamsCall + def list_ssl_trusted_certificates(self, retrieve_all=True, **_params): + """Fetches a list of all load balancer health monitors for a tenant.""" + # Pass filters in "params" argument to do_request + return self.list('ssl_trusted_certificates', self.ssl_trusted_certificates_path, + retrieve_all, **_params) + + @APIParamsCall + def show_ssl_trusted_certificate(self, ssl_trusted_certificate, **_params): + """Fetches information of a certain load balancer health monitor.""" + return self.get(self.ssl_trusted_certificate_path % (ssl_trusted_certificate), + params=_params) + + @APIParamsCall + def create_ssl_trusted_certificate(self, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.ssl_trusted_certificates_path, body=body) + + @APIParamsCall + def update_ssl_trusted_certificate(self, ssl_trusted_certificate, body=None): + """Updates a load balancer health monitor.""" + return self.put(self.ssl_trusted_certificate_path % (ssl_trusted_certificate), body=body) + + @APIParamsCall + def delete_ssl_trusted_certificate(self, ssl_trusted_certificate): + """Deletes the specified load balancer health monitor.""" + return self.delete(self.ssl_trusted_certificate_path % (ssl_trusted_certificate)) + + @APIParamsCall + def create_ssl_policy_association(self, vip, body=None): + """Creates a new load balancer health monitor.""" + return self.post(self.associate_vip_ssl_policy_path% (vip), body=body) + + @APIParamsCall + def delete_ssl_policy_association(self, vip, ssl_policy): + """Creates a new load balancer health monitor.""" + path = (self.disassociate_vip_ssl_policy_path % + {'vip': vip, 'ssl_policy': ssl_policy}) + return self.delete(path) @APIParamsCall def create_qos_queue(self, body=None): @@ -1138,6 +1250,36 @@ def show_metering_label_rule(self, metering_label_rule, **_params): """Fetches information of a certain metering label rule.""" return self.get(self.metering_label_rule_path % (metering_label_rule), params=_params) + @APIParamsCall + def list_device_templates(self, retrieve_all=True, **_params): + """Fetches a list of all device templates for a tenant.""" + # Pass filters in "params" argument to do_request + + return self.list('device_templates', self.device_templates_path, + retrieve_all, **_params) + + @APIParamsCall + def show_device_template(self, device_template, **_params): + """Fetches information of a certain device template.""" + return self.get(self.device_template_path % (device_template), + params=_params) + + @APIParamsCall + def create_device_template(self, body=None): + """Creates a new device template.""" + return self.post(self.device_templates_path, body=body) + + @APIParamsCall + def update_device_template(self, device_template, body=None): + """Updates a device template.""" + return self.put(self.device_template_path % (device_template), + body=body) + + @APIParamsCall + def delete_device_template(self, device_template): + """Deletes the specified device template.""" + return self.delete(self.device_template_path % (device_template)) + def __init__(self, **kwargs): """Initialize a new client for the Neutron v2.0 API."""