From 3662db6ca8f0b617cd2a58bd8ef81c2d6001ca8c Mon Sep 17 00:00:00 2001 From: Joe Mills Date: Wed, 5 Nov 2014 17:27:29 +0900 Subject: [PATCH 1/4] update .gitreview to point to gerrithub Change-Id: Ifc467a534a4ae73bcd774c16e355f1b1a88752e8 Signed-off-by: Joe Mills --- .gitreview | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitreview b/.gitreview index 994b07a43..2e888b7a9 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] -host=review.openstack.org +host=review.gerrithub.io port=29418 -project=openstack/python-neutronclient.git +project=midonet/python-neutronclient.git From 41dbc89e3d8f4a3d07041651a3d2c5e2a1e17f12 Mon Sep 17 00:00:00 2001 From: Joe Mills Date: Wed, 12 Nov 2014 18:01:28 +0900 Subject: [PATCH 2/4] Add flush cli command Change-Id: Ic9b84fbc247a8af159dc64e33382b6b2512a04e8 Signed-off-by: Joe Mills --- neutronclient/neutron/client.py | 2 +- neutronclient/neutron/v2_0/midonet/client.py | 26 ++++++++++++++++ neutronclient/neutron/v2_0/midonet/cluster.py | 30 +++++++++++++++++++ neutronclient/neutron/v2_0/midonet/shell.py | 19 ++++++++++++ neutronclient/shell.py | 2 ++ 5 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 neutronclient/neutron/v2_0/midonet/client.py create mode 100644 neutronclient/neutron/v2_0/midonet/cluster.py create mode 100644 neutronclient/neutron/v2_0/midonet/shell.py diff --git a/neutronclient/neutron/client.py b/neutronclient/neutron/client.py index 7236a8a0a..75dd5ef2b 100644 --- a/neutronclient/neutron/client.py +++ b/neutronclient/neutron/client.py @@ -21,7 +21,7 @@ API_NAME = 'network' API_VERSIONS = { - '2.0': 'neutronclient.v2_0.client.Client', + '2.0': 'neutronclient.neutron.v2_0.midonet.client.MidonetClient', } diff --git a/neutronclient/neutron/v2_0/midonet/client.py b/neutronclient/neutron/v2_0/midonet/client.py new file mode 100644 index 000000000..acfdeed3f --- /dev/null +++ b/neutronclient/neutron/v2_0/midonet/client.py @@ -0,0 +1,26 @@ +# Copyright 2014 OpenStack Foundation +# +# 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.v2_0 import client + +APIParamsCall = client.APIParamsCall + + +class MidonetClient(client.Client): + + clusters_path = "/clusters" + + @APIParamsCall + def create_cluster(self, body=None): + return self.post(self.clusters_path, body=body) diff --git a/neutronclient/neutron/v2_0/midonet/cluster.py b/neutronclient/neutron/v2_0/midonet/cluster.py new file mode 100644 index 000000000..6686d5f27 --- /dev/null +++ b/neutronclient/neutron/v2_0/midonet/cluster.py @@ -0,0 +1,30 @@ +# Copyright 2014 OpenStack Foundation +# +# 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.neutron import v2_0 as neutronV20 +from neutronclient.openstack.common.gettextutils import _ + + +class CreateCluster(neutronV20.CreateCommand): + + resource = 'cluster' + + def add_known_arguments(self, parser): + pass + + def args2body(self, parsed_args): + body = {'cluster': {}} + if parsed_args.tenant_id: + body[self.resource].update({'tenant_id': parsed_args.tenant_id}) + return body diff --git a/neutronclient/neutron/v2_0/midonet/shell.py b/neutronclient/neutron/v2_0/midonet/shell.py new file mode 100644 index 000000000..5593a9eee --- /dev/null +++ b/neutronclient/neutron/v2_0/midonet/shell.py @@ -0,0 +1,19 @@ +# Copyright 2014 OpenStack Foundation +# +# 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.neutron.v2_0.midonet import cluster + +COMMANDS_MIDONET = { + 'cluster-rebuild': cluster.CreateCluster +} diff --git a/neutronclient/shell.py b/neutronclient/shell.py index 0329d5272..22931bc98 100644 --- a/neutronclient/shell.py +++ b/neutronclient/shell.py @@ -54,6 +54,7 @@ from neutronclient.neutron.v2_0.lb import pool as lb_pool from neutronclient.neutron.v2_0.lb import vip as lb_vip from neutronclient.neutron.v2_0 import metering +from neutronclient.neutron.v2_0.midonet import shell as mido_shell from neutronclient.neutron.v2_0.nec import packetfilter from neutronclient.neutron.v2_0 import netpartition from neutronclient.neutron.v2_0 import network @@ -299,6 +300,7 @@ def check_non_negative_int(value): } COMMANDS = {'2.0': COMMAND_V2} +COMMANDS['2.0'].update(mido_shell.COMMANDS_MIDONET) class HelpAction(argparse.Action): From be3cb16fdc9ae843d3d04426a5974c7010a153a3 Mon Sep 17 00:00:00 2001 From: Joe Mills Date: Tue, 27 Jan 2015 15:51:16 +0900 Subject: [PATCH 3/4] Separate flush/import into two commands Change-Id: I06ca5475046a5f3cb2e2e3cc57444b57d4ae755f Signed-off-by: Joe Mills --- neutronclient/neutron/v2_0/midonet/__init__.py | 15 +++++++++++++++ neutronclient/neutron/v2_0/midonet/cluster.py | 18 ++++++++++++++++-- neutronclient/neutron/v2_0/midonet/shell.py | 3 ++- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 neutronclient/neutron/v2_0/midonet/__init__.py diff --git a/neutronclient/neutron/v2_0/midonet/__init__.py b/neutronclient/neutron/v2_0/midonet/__init__.py new file mode 100644 index 000000000..1bda995c4 --- /dev/null +++ b/neutronclient/neutron/v2_0/midonet/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2012 OpenStack Foundation. +# 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. +# diff --git a/neutronclient/neutron/v2_0/midonet/cluster.py b/neutronclient/neutron/v2_0/midonet/cluster.py index 6686d5f27..41cdc2dfa 100644 --- a/neutronclient/neutron/v2_0/midonet/cluster.py +++ b/neutronclient/neutron/v2_0/midonet/cluster.py @@ -13,10 +13,9 @@ # under the License. from neutronclient.neutron import v2_0 as neutronV20 -from neutronclient.openstack.common.gettextutils import _ -class CreateCluster(neutronV20.CreateCommand): +class Flush(neutronV20.CreateCommand): resource = 'cluster' @@ -27,4 +26,19 @@ def args2body(self, parsed_args): body = {'cluster': {}} if parsed_args.tenant_id: body[self.resource].update({'tenant_id': parsed_args.tenant_id}) + body[self.resource].update({'op': 'FLUSH'}) + return body + +class Import(neutronV20.CreateCommand): + + resource = 'cluster' + + def add_known_arguments(self, parser): + pass + + def args2body(self, parsed_args): + body = {'cluster': {}} + if parsed_args.tenant_id: + body[self.resource].update({'tenant_id': parsed_args.tenant_id}) + body[self.resource].update({'op': 'IMPORT'}) return body diff --git a/neutronclient/neutron/v2_0/midonet/shell.py b/neutronclient/neutron/v2_0/midonet/shell.py index 5593a9eee..e4a285aca 100644 --- a/neutronclient/neutron/v2_0/midonet/shell.py +++ b/neutronclient/neutron/v2_0/midonet/shell.py @@ -15,5 +15,6 @@ from neutronclient.neutron.v2_0.midonet import cluster COMMANDS_MIDONET = { - 'cluster-rebuild': cluster.CreateCluster + 'cluster-flush': cluster.Flush, + 'cluster-import': cluster.Import } From 73bf124f926f73c915e4412b527e024a1e5c2338 Mon Sep 17 00:00:00 2001 From: Joe Mills Date: Fri, 27 Feb 2015 05:20:02 +0000 Subject: [PATCH 4/4] Add agent-membership CLI support Change-Id: Ia5b953719d15efd388995e394c164ab1a67cb0db Signed-off-by: Joe Mills --- .../neutron/v2_0/midonet/agent_membership.py | 51 +++++++++++++++++++ neutronclient/neutron/v2_0/midonet/client.py | 25 +++++++++ neutronclient/neutron/v2_0/midonet/shell.py | 7 ++- 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 neutronclient/neutron/v2_0/midonet/agent_membership.py diff --git a/neutronclient/neutron/v2_0/midonet/agent_membership.py b/neutronclient/neutron/v2_0/midonet/agent_membership.py new file mode 100644 index 000000000..783a9f5f9 --- /dev/null +++ b/neutronclient/neutron/v2_0/midonet/agent_membership.py @@ -0,0 +1,51 @@ +# Copyright 2015 OpenStack Foundation +# +# 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.neutron import v2_0 as neutronV20 + +class Create(neutronV20.CreateCommand): + + resource = 'agent_membership' + + def add_known_arguents(self, parser): + parser.add_argument( + '--id', + dest='id', metavar='ID', + help=_('id of the host.')) + parser.add_argument( + '--ip_address', + dest='ip_address', metavar='IP_ADDRESS', + help=_('ip address of the host.')) + + def args2body(self, parsed_args): + body = {self.resource: {}} + neutronV20.update_dict(parsed_args, body[self.resource], + ['id', 'ip_address']) + return body + +class Show(neutronV20.ShowCommand): + """Show information of a given agent membership.""" + + resource = 'agent_membership' + +class List(neutronV20.ListCommand): + """Show information of a given agent membership.""" + + resource = 'agent_membership' + list_columns = ['id', 'ip_address'] + +class Delete(neutronV20.DeleteCommand): + """Delete a given agent membership.""" + + resource = 'agent_membership' diff --git a/neutronclient/neutron/v2_0/midonet/client.py b/neutronclient/neutron/v2_0/midonet/client.py index acfdeed3f..8137b0f79 100644 --- a/neutronclient/neutron/v2_0/midonet/client.py +++ b/neutronclient/neutron/v2_0/midonet/client.py @@ -21,6 +21,31 @@ class MidonetClient(client.Client): clusters_path = "/clusters" + agent_memberships_path = "/agent_memberships" + agent_membership_path = "/agent_memberships/%s" + @APIParamsCall def create_cluster(self, body=None): return self.post(self.clusters_path, body=body) + + @APIParamsCall + def create_agent_membership(self, body=None): + """Creates the specified agent_membership.""" + return self.post(self.agent_memberships_path, body=body) + + @APIParamsCall + def show_agent_membership(self, agent_membership, **_params): + """Shows the specified agent_membership.""" + return self.get(self.agent_membership_path % (agent_membership), + params=_params) + + @APIParamsCall + def list_agent_memberships(self, retrieve_all=True, **_params): + """Lists all agent_memberships.""" + return self.list('agent_memberships', self.agent_memberships_path, + retrieve_all, **_params) + + @APIParamsCall + def delete_agent_membership(self, agent_membership): + """Deletes the specified agent_membership.""" + return self.delete(self.agent_membership_path % (agent_membership)) diff --git a/neutronclient/neutron/v2_0/midonet/shell.py b/neutronclient/neutron/v2_0/midonet/shell.py index e4a285aca..79b076c7b 100644 --- a/neutronclient/neutron/v2_0/midonet/shell.py +++ b/neutronclient/neutron/v2_0/midonet/shell.py @@ -12,9 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. +from neutronclient.neutron.v2_0.midonet import agent_membership from neutronclient.neutron.v2_0.midonet import cluster COMMANDS_MIDONET = { 'cluster-flush': cluster.Flush, - 'cluster-import': cluster.Import + 'cluster-import': cluster.Import, + 'agent-membership-show': agent_membership.Show, + 'agent-membership-list': agent_membership.List, + 'agent-membership-create': agent_membership.Create, + 'agent-membership-delete': agent_membership.Delete }