From b51310a4bb5997137a4b6c0cf3517f481e178474 Mon Sep 17 00:00:00 2001 From: Shashank Kumar Shankar Date: Mon, 28 Nov 2016 21:10:52 +0000 Subject: Introduce neutron flavor associate, disassociate to OSC This patch introduces network flavor associate and disassociate to OSC. The following neutron equivalent commands are implemented in OSC: - neutron flavor-associate - neutron flavor-disassociate Change-Id: Icba4dbf7300a36353142586359059cd6784049dc --- openstackclient/network/v2/network_flavor.py | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'openstackclient/network') diff --git a/openstackclient/network/v2/network_flavor.py b/openstackclient/network/v2/network_flavor.py index 3a3324c0..c9d368bf 100644 --- a/openstackclient/network/v2/network_flavor.py +++ b/openstackclient/network/v2/network_flavor.py @@ -58,6 +58,34 @@ def _get_attrs(client_manager, parsed_args): return attrs +class AddNetworkFlavorToProfile(command.Command): + _description = _("Add a service profile to a network flavor") + + def get_parser(self, prog_name): + parser = super( + AddNetworkFlavorToProfile, self).get_parser(prog_name) + parser.add_argument( + 'flavor', + metavar="", + help=_("Network flavor (name or ID)") + ) + parser.add_argument( + 'service_profile', + metavar="", + help=_("Service profile (ID only)") + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.network + obj_flavor = client.find_flavor( + parsed_args.flavor, ignore_missing=False) + obj_service_profile = client.find_service_profile( + parsed_args.service_profile, ignore_missing=False) + client.associate_flavor_with_service_profile( + obj_flavor, obj_service_profile) + + # TODO(dasanind): Use the SDK resource mapped attribute names once the # OSC minimum requirements include SDK 1.0. class CreateNetworkFlavor(command.ShowOne): @@ -175,6 +203,35 @@ class ListNetworkFlavor(command.Lister): ) for s in data)) +class RemoveNetworkFlavorFromProfile(command.Command): + _description = _( + "Remove service profile from network flavor") + + def get_parser(self, prog_name): + parser = super( + RemoveNetworkFlavorFromProfile, self).get_parser(prog_name) + parser.add_argument( + 'flavor', + metavar="", + help=_("Network flavor (name or ID)") + ) + parser.add_argument( + 'service_profile', + metavar="", + help=_("Service profile (ID only)") + ) + return parser + + def take_action(self, parsed_args): + client = self.app.client_manager.network + obj_flavor = client.find_flavor( + parsed_args.flavor, ignore_missing=False) + obj_service_profile = client.find_service_profile( + parsed_args.service_profile, ignore_missing=False) + client.disassociate_flavor_from_service_profile( + obj_flavor, obj_service_profile) + + # TODO(dasanind): Use only the SDK resource mapped attribute names once the # OSC minimum requirements include SDK 1.0. class SetNetworkFlavor(command.Command): -- cgit v1.2.1