Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions neutronclient/neutron/v2_0/lb/sslassociation.py
Original file line number Diff line number Diff line change
@@ -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)

86 changes: 86 additions & 0 deletions neutronclient/neutron/v2_0/lb/sslcertificate.py
Original file line number Diff line number Diff line change
@@ -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')
110 changes: 110 additions & 0 deletions neutronclient/neutron/v2_0/lb/sslpolicy.py
Original file line number Diff line number Diff line change
@@ -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')



80 changes: 80 additions & 0 deletions neutronclient/neutron/v2_0/lb/ssltrustedcertificate.py
Original file line number Diff line number Diff line change
@@ -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')
Empty file.
Loading