File: _fox_sockets.py

package info (click to toggle)
python-neutronclient 1%3A6.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,856 kB
  • ctags: 3,289
  • sloc: python: 19,731; sh: 274; makefile: 21
file content (93 lines) | stat: -rw-r--r-- 2,692 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright 2015 Rackspace Hosting 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.
#

from neutronclient._i18n import _
from neutronclient.common import extension


def _add_updatable_args(parser):
    parser.add_argument(
        'name',
        help=_('Name of this fox socket.'))


def _updatable_args2body(parsed_args, body, client):
    if parsed_args.name:
        body['name'] = parsed_args.name


class FoxInSocket(extension.NeutronClientExtension):
    """Define required variables for resource operations."""

    resource = 'fox_socket'
    resource_plural = '%ss' % resource
    object_path = '/%s' % resource_plural
    resource_path = '/%s/%%s' % resource_plural
    versions = ['2.0']


class FoxInSocketsList(extension.ClientExtensionList, FoxInSocket):
    """List fox sockets."""

    shell_command = 'fox-sockets-list'
    list_columns = ['id', 'name']
    pagination_support = True
    sorting_support = True


class FoxInSocketsCreate(extension.ClientExtensionCreate, FoxInSocket):
    """Create a fox socket."""

    shell_command = 'fox-sockets-create'
    list_columns = ['id', 'name']

    def add_known_arguments(self, parser):
        _add_updatable_args(parser)

    def args2body(self, parsed_args):
        body = {}
        client = self.get_client()
        _updatable_args2body(parsed_args, body, client)
        return {'fox_socket': body}


class FoxInSocketsUpdate(extension.ClientExtensionUpdate, FoxInSocket):
    """Update a fox socket."""

    shell_command = 'fox-sockets-update'
    list_columns = ['id', 'name']

    def add_known_arguments(self, parser):
        # _add_updatable_args(parser)
        parser.add_argument(
            '--name',
            help=_('Name of this fox socket.'))

    def args2body(self, parsed_args):
        body = {'name': parsed_args.name}
        return {'fox_socket': body}


class FoxInSocketsDelete(extension.ClientExtensionDelete, FoxInSocket):
    """Delete a fox socket."""

    shell_command = 'fox-sockets-delete'


class FoxInSocketsShow(extension.ClientExtensionShow, FoxInSocket):
    """Show a fox socket."""

    shell_command = 'fox-sockets-show'