Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support for services #474

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Documentation on the NSX platform can be found at the [NSX-T Documentation page]

The following versions of NSX are supported:

* NSX-T 4.1
* NSX-T 4.0
* NSX-T 3.2
* NSX-T 3.1
* NSX-T 3.0
Expand Down
3 changes: 2 additions & 1 deletion plugins/module_utils/nsxt_base_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
BASE_RESOURCES = {"NSXTSegment", "NSXTTier0", "NSXTTier1",
"NSXTSecurityPolicy", "NSXTPolicyGroup",
"NSXTIpBlock", "NSXTIpPool", "NSXTBFDProfile",
"NSXTGatewayPolicy", "NSXTL2BridgeEpProfile"}
"NSXTGatewayPolicy", "NSXTL2BridgeEpProfile",
"NSXTService"}


class NSXTBaseRealizableResource(ABC):
Expand Down
3 changes: 3 additions & 0 deletions plugins/module_utils/nsxt_resource_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

SECURITY_POLICY_URL = _DOMAIN_URL + '/{}/security-policies'

SERVICE_URL = '/infra/services'
SERVICE_ENTRIES_URL = SERVICE_URL + '/{}/service-entries'

SEGMENT_URL = '/infra/segments'
SEGMENT_PORT_URL = SEGMENT_URL + '/{}/ports'

Expand Down
64 changes: 64 additions & 0 deletions plugins/modules/nsxt_policy_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2018 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}

DOCUMENTATION = '''
---
module: nsxt_policy_service


'''

RETURN = '''# '''

import json
import time
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.nsxt_base_resource import NSXTBaseRealizableResource
from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.nsxt_resource_urls import (
SERVICE_ENTRIES_URL, SERVICE_URL)
from ansible.module_utils._text import to_native


class NSXTService(NSXTBaseRealizableResource):
@staticmethod
def get_resource_spec():
service_arg_spec = {}
service_arg_spec.update(
service_entries=dict(
type='list',
elements='dict'
),
)
return service_arg_spec

@staticmethod
def get_resource_base_url(baseline_args=None):
return SERVICE_URL

if __name__ == '__main__':
svc = NSXTService()
svc.realize()