diff --git a/tools/python_nsxadmin/admin/plugins/common/constants.py b/tools/python_nsxadmin/admin/plugins/common/constants.py index d85b443226..19aa573eb8 100644 --- a/tools/python_nsxadmin/admin/plugins/common/constants.py +++ b/tools/python_nsxadmin/admin/plugins/common/constants.py @@ -25,3 +25,4 @@ SECURITY_GROUPS = 'security-groups' EDGES = 'edges' SPOOFGUARD_POLICY = 'spoofguard-policy' DHCP_BINDING = 'dhcp-binding' +BACKUP_EDGES = 'backup-edges' diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/backup_edges.py b/tools/python_nsxadmin/admin/plugins/nsxv/resources/backup_edges.py new file mode 100644 index 0000000000..1154a6fcc6 --- /dev/null +++ b/tools/python_nsxadmin/admin/plugins/nsxv/resources/backup_edges.py @@ -0,0 +1,52 @@ +# Copyright 2015 VMware, 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. + + +import logging + +from tools.python_nsxadmin.admin.plugins.common import constants +from tools.python_nsxadmin.admin.plugins.common import formatters + +import tools.python_nsxadmin.admin.plugins.common.utils as admin_utils +import tools.python_nsxadmin.admin.plugins.nsxv.resources.utils as utils +import tools.python_nsxadmin.admin.shell as shell + +from neutron.callbacks import registry + + +LOG = logging.getLogger(__name__) +nsxv = utils.get_nsxv_client() + + +def get_nsxv_backup_edges(): + edges = nsxv.get_edges()[1] + edges = edges['edgePage'].get('data', []) + backup_edges = [] + for edge in edges: + if edge['name'].startswith("backup-"): + backup_edges.append(edge) + return backup_edges + + +@admin_utils.output_header +def nsx_list_backup_edges(resource, event, trigger, **kwargs): + """List backup edges""" + backup_edges = get_nsxv_backup_edges() + LOG.info(formatters.output_formatter(constants.BACKUP_EDGES, backup_edges, + ['id'])) + + +registry.subscribe(nsx_list_backup_edges, + constants.BACKUP_EDGES, + shell.Operations.LIST.value) diff --git a/tools/python_nsxadmin/admin/shell.py b/tools/python_nsxadmin/admin/shell.py index 88726fba0e..88ac616dbc 100644 --- a/tools/python_nsxadmin/admin/shell.py +++ b/tools/python_nsxadmin/admin/shell.py @@ -87,6 +87,8 @@ nsxv_resources = { constants.DHCP_BINDING: Resource(constants.DHCP_BINDING, [Operations.LIST.value, Operations.NSX_UPDATE.value]), + constants.BACKUP_EDGES: Resource(constants.BACKUP_EDGES, + [Operations.LIST.value]), } nsxv3_resources_names = map(lambda res: res.name, nsxv3_resources.itervalues())