| 1 |
# Copyright 2015 Rackspace Hosting Inc. |
| 2 |
# All Rights Reserved |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
# |
| 16 |
|
| 17 |
from neutronclient._i18n import _ |
| 18 |
from neutronclient.common import extension |
| 19 |
|
| 20 |
|
| 21 |
def _add_updatable_args(parser): |
| 22 |
parser.add_argument( |
| 23 |
'name', |
| 24 |
help=_('Name of this fox socket.')) |
| 25 |
|
| 26 |
|
| 27 |
def _updatable_args2body(parsed_args, body, client): |
| 28 |
if parsed_args.name: |
| 29 |
body['name'] = parsed_args.name |
| 30 |
|
| 31 |
|
| 32 |
class FoxInSocket(extension.NeutronClientExtension): |
| 33 |
"""Define required variables for resource operations.""" |
| 34 |
|
| 35 |
resource = 'fox_socket' |
| 36 |
resource_plural = '%ss' % resource |
| 37 |
object_path = '/%s' % resource_plural |
| 38 |
resource_path = '/%s/%%s' % resource_plural |
| 39 |
versions = ['2.0'] |
| 40 |
|
| 41 |
|
| 42 |
class FoxInSocketsList(extension.ClientExtensionList, FoxInSocket): |
| 43 |
"""List fox sockets.""" |
| 44 |
|
| 45 |
shell_command = 'fox-sockets-list' |
| 46 |
list_columns = ['id', 'name'] |
| 47 |
pagination_support = True |
| 48 |
sorting_support = True |
| 49 |
|
| 50 |
|
| 51 |
class FoxInSocketsCreate(extension.ClientExtensionCreate, FoxInSocket): |
| 52 |
"""Create a fox socket.""" |
| 53 |
|
| 54 |
shell_command = 'fox-sockets-create' |
| 55 |
list_columns = ['id', 'name'] |
| 56 |
|
| 57 |
def add_known_arguments(self, parser): |
| 58 |
_add_updatable_args(parser) |
| 59 |
|
| 60 |
def args2body(self, parsed_args): |
| 61 |
body = {} |
| 62 |
client = self.get_client() |
| 63 |
_updatable_args2body(parsed_args, body, client) |
| 64 |
return {'fox_socket': body} |
| 65 |
|
| 66 |
|
| 67 |
class FoxInSocketsUpdate(extension.ClientExtensionUpdate, FoxInSocket): |
| 68 |
"""Update a fox socket.""" |
| 69 |
|
| 70 |
shell_command = 'fox-sockets-update' |
| 71 |
list_columns = ['id', 'name'] |
| 72 |
|
| 73 |
def add_known_arguments(self, parser): |
| 74 |
# _add_updatable_args(parser) |
| 75 |
parser.add_argument( |
| 76 |
'--name', |
| 77 |
help=_('Name of this fox socket.')) |
| 78 |
|
| 79 |
def args2body(self, parsed_args): |
| 80 |
body = {'name': parsed_args.name} |
| 81 |
return {'fox_socket': body} |
| 82 |
|
| 83 |
|
| 84 |
class FoxInSocketsDelete(extension.ClientExtensionDelete, FoxInSocket): |
| 85 |
"""Delete a fox socket.""" |
| 86 |
|
| 87 |
shell_command = 'fox-sockets-delete' |
| 88 |
|
| 89 |
|
| 90 |
class FoxInSocketsShow(extension.ClientExtensionShow, FoxInSocket): |
| 91 |
"""Show a fox socket.""" |
| 92 |
|
| 93 |
shell_command = 'fox-sockets-show' |