-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OSP-278: Add OpenStack CLI for force-bcf-sync
Also - update doc - remove py35 and use py36 to stay consistent with upstream References: - https://docs.openstack.org/python-openstackclient/latest/ - https://github.com/openstack/python-neutronclient/tree/master/neutronclient/osc
- Loading branch information
Weifan Fu
committed
Jun 6, 2019
1 parent
777ab24
commit 215dbc1
Showing
15 changed files
with
187 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,6 @@ ChangeLog | |
|
||
# Files created by releasenotes build | ||
releasenotes/build | ||
|
||
# intellij | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
23 changes: 11 additions & 12 deletions
23
...n_neutronclient/v2_0/bsn_plugin_client.py → ...eutronclient/neutron/bsn_plugin_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# 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. | ||
|
||
"""OpenStackClient plugin for bsn neutron plugin.""" | ||
|
||
import logging | ||
from osc_lib import utils | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
DEFAULT_API_VERSION = '2.0' | ||
API_VERSION_OPTION = 'os_network_api_version' | ||
# NOTE(rtheis): API_NAME must NOT be set to 'network' since | ||
# 'network' is owned by OSC! The OSC 'network' client uses | ||
# the OpenStack SDK. | ||
API_NAME = 'bsn_neutronclient' | ||
API_VERSIONS = { | ||
'2.0': 'python_bsn_neutronclient.v2_0.client.Client', | ||
'2': 'python_bsn_neutronclient.v2_0.client.Client', | ||
} | ||
|
||
|
||
def make_client(instance): | ||
"""Returns a bsn neutron client.""" | ||
bsn_neutron_client = utils.get_client_class( | ||
API_NAME, | ||
instance._api_version[API_NAME], | ||
API_VERSIONS) | ||
LOG.debug('Instantiating bsn neutron client: %s', bsn_neutron_client) | ||
|
||
client = bsn_neutron_client(session=instance.session, | ||
region_name=instance.region_name, | ||
endpoint_type=instance.interface, | ||
insecure=not instance.verify, | ||
ca_cert=instance.cacert) | ||
|
||
return client | ||
|
||
|
||
def build_option_parser(parser): | ||
"""Hook to add global options""" | ||
# OSC itself has an option for Network API version # and we refer to it. | ||
return parser |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# 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 osc_lib.command import command | ||
from osc_lib import exceptions | ||
|
||
|
||
class ForceBcfSync(command.Command): | ||
_description = _("Force BCF to to sync network configuration") | ||
|
||
def get_parser(self, prog_name): | ||
parser = super(ForceBcfSync, self).get_parser(prog_name) | ||
return parser | ||
|
||
def take_action(self, parsed_args): | ||
client = self.app.client_manager.bsn_neutronclient | ||
result = client.force_bcf_sync() | ||
|
||
try: | ||
return result['forcesynctopology']['status'] | ||
except Exception as e: | ||
raise exceptions.CommandError(e.message + '\n' + str(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# 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. | ||
|
||
import pbr.version | ||
|
||
|
||
__version__ = pbr.version.VersionInfo( | ||
'python-bsn-neutronclient').version_string() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# 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.client import Client as NeutronClientV2 | ||
|
||
|
||
class Client(NeutronClientV2): | ||
force_bcf_sync_path = "/forcesynctopologies/%s" | ||
force_bcf_sync_path_plural = "/forcesynctopologies" | ||
|
||
def force_bcf_sync(self, topo_sync_id=None): | ||
if not topo_sync_id: | ||
topo_sync_id = 1 | ||
|
||
body = {'forcesynctopology': {'timestamp_ms': 'now'}} | ||
return self.put(self.force_bcf_sync_path % topo_sync_id, body=body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# The order of packages is significant, because pip processes them in the order | ||
# of appearance. Changing the order has an impact on the overall integration | ||
# process, which may cause wedges in the gate later. | ||
|
||
pbr>=2.0 # Apache-2.0 | ||
python-neutronclient>=6.3.0 # Apache-2.0 | ||
osc_lib>=1.8.0 # Apache-2.0 | ||
oslo.i18n>=3.15.3 # Apache-2.0 | ||
python_neutronclient>=6.3.0 # Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters