| 1 |
# Copyright 2015 Hewlett-Packard Development Company, L.P. |
| 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 |
import argparse |
| 17 |
|
| 18 |
from neutronclient._i18n import _ |
| 19 |
from neutronclient.common import utils |
| 20 |
from neutronclient.neutron import v2_0 as neutronV20 |
| 21 |
|
| 22 |
|
| 23 |
class ListFlavorProfile(neutronV20.ListCommand): |
| 24 |
"""List Neutron service flavor profiles.""" |
| 25 |
|
| 26 |
resource = 'service_profile' |
| 27 |
list_columns = ['id', 'description', 'enabled', 'metainfo'] |
| 28 |
pagination_support = True |
| 29 |
sorting_support = True |
| 30 |
|
| 31 |
|
| 32 |
class ShowFlavorProfile(neutronV20.ShowCommand): |
| 33 |
"""Show information about a given Neutron service flavor profile.""" |
| 34 |
|
| 35 |
resource = 'service_profile' |
| 36 |
|
| 37 |
|
| 38 |
class CreateFlavorProfile(neutronV20.CreateCommand): |
| 39 |
"""Create a Neutron service flavor profile.""" |
| 40 |
|
| 41 |
resource = 'service_profile' |
| 42 |
|
| 43 |
def add_known_arguments(self, parser): |
| 44 |
parser.add_argument( |
| 45 |
'--description', |
| 46 |
help=_('Description for the flavor profile.')) |
| 47 |
parser.add_argument( |
| 48 |
'--driver', |
| 49 |
help=_('Python module path to driver.')) |
| 50 |
parser.add_argument( |
| 51 |
'--metainfo', |
| 52 |
help=_('Metainfo for the flavor profile.')) |
| 53 |
utils.add_boolean_argument( |
| 54 |
parser, |
| 55 |
'--enabled', |
| 56 |
default=argparse.SUPPRESS, |
| 57 |
help=_('Sets enabled flag.')) |
| 58 |
|
| 59 |
def args2body(self, parsed_args): |
| 60 |
body = {} |
| 61 |
neutronV20.update_dict(parsed_args, body, |
| 62 |
['description', 'driver', 'enabled', |
| 63 |
'metainfo']) |
| 64 |
return {self.resource: body} |
| 65 |
|
| 66 |
|
| 67 |
class DeleteFlavorProfile(neutronV20.DeleteCommand): |
| 68 |
"""Delete a given Neutron service flavor profile.""" |
| 69 |
|
| 70 |
resource = 'service_profile' |
| 71 |
|
| 72 |
|
| 73 |
class UpdateFlavorProfile(neutronV20.UpdateCommand): |
| 74 |
"""Update a given Neutron service flavor profile.""" |
| 75 |
|
| 76 |
resource = 'service_profile' |
| 77 |
|
| 78 |
def add_known_arguments(self, parser): |
| 79 |
parser.add_argument( |
| 80 |
'--description', |
| 81 |
help=_('Description for the flavor profile.')) |
| 82 |
parser.add_argument( |
| 83 |
'--driver', |
| 84 |
help=_('Python module path to driver.')) |
| 85 |
parser.add_argument( |
| 86 |
'--metainfo', |
| 87 |
help=_('Metainfo for the flavor profile.')) |
| 88 |
utils.add_boolean_argument( |
| 89 |
parser, |
| 90 |
'--enabled', |
| 91 |
default=argparse.SUPPRESS, |
| 92 |
help=_('Sets enabled flag.')) |
| 93 |
|
| 94 |
def args2body(self, parsed_args): |
| 95 |
body = {} |
| 96 |
neutronV20.update_dict(parsed_args, body, |
| 97 |
['description', 'driver', 'enabled', |
| 98 |
'metainfo']) |
| 99 |
return {self.resource: body} |