-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from tsm1th/u/tsm1th-add-cloud-app-support
Add support for all new cloud models in Nautobot 2.3+
- Loading branch information
Showing
6 changed files
with
156 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Cloud | ||
|
||
::: pynautobot.models.cloud | ||
options: | ||
show_submodules: true |
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
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,17 @@ | ||
# (c) 2017 DigitalOcean | ||
# | ||
# 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. | ||
# | ||
# This file has been modified by NetworktoCode, LLC. | ||
|
||
# Reserved for cloud models |
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,129 @@ | ||
from packaging import version | ||
|
||
import pytest | ||
|
||
|
||
class TestCloudResourceType: | ||
@pytest.fixture | ||
def skipif_version(self, nb_client): | ||
"""Retrieve the current Nautobot version and skip the test if less than 2.3.""" | ||
status = nb_client.status() | ||
nautobot_version = status.get("nautobot-version") | ||
if version.parse(nautobot_version) < version.parse("2.3"): | ||
pytest.skip("Cloud resources are only in Nautobot 2.3+") | ||
|
||
return nautobot_version | ||
|
||
def test_cloud_resource_types(self, skipif_version, nb_client): | ||
"""Verify we can CRUD a cloud resource type.""" | ||
assert skipif_version | ||
|
||
# Create | ||
cloud_resource_type = nb_client.cloud.cloud_resource_types.create( | ||
name="Test", provider="Dell", content_types=["cloud.cloudservice"] | ||
) | ||
assert cloud_resource_type | ||
|
||
# Read | ||
test_cloud_resource_type = nb_client.cloud.cloud_resource_types.get(name="Test") | ||
assert test_cloud_resource_type.name == "Test" | ||
|
||
# Update | ||
test_cloud_resource_type.name = "Updated Test" | ||
test_cloud_resource_type.save() | ||
updated_cloud_resource_type = nb_client.cloud.cloud_resource_types.get(name="Updated Test") | ||
assert updated_cloud_resource_type.name == "Updated Test" | ||
|
||
# Delete | ||
updated_cloud_resource_type.delete() | ||
deleted_cloud_resource_type = nb_client.cloud.cloud_resource_types.get(name="Updated Test") | ||
assert not deleted_cloud_resource_type | ||
|
||
def test_cloud_accounts(self, skipif_version, nb_client): | ||
"""Verify we can CRUD a cloud account.""" | ||
assert skipif_version | ||
|
||
# Create | ||
cloud_account = nb_client.cloud.cloud_accounts.create(name="TestAcct", provider="Dell", account_number="424242") | ||
assert cloud_account | ||
|
||
# Read | ||
test_cloud_account = nb_client.cloud.cloud_accounts.get(name="TestAcct") | ||
assert test_cloud_account.name == "TestAcct" | ||
|
||
# Update | ||
test_cloud_account.name = "Updated TestAcct" | ||
test_cloud_account.save() | ||
updated_cloud_account = nb_client.cloud.cloud_accounts.get(name="Updated TestAcct") | ||
assert updated_cloud_account.name == "Updated TestAcct" | ||
|
||
# Delete | ||
updated_cloud_account.delete() | ||
deleted_cloud_account = nb_client.cloud.cloud_accounts.get(name="Updated TestAcct") | ||
assert not deleted_cloud_account | ||
|
||
def test_cloud_services(self, skipif_version, nb_client): | ||
"""Verify we can CRUD a cloud service.""" | ||
assert skipif_version | ||
|
||
# Create | ||
cloud_resource_type = nb_client.cloud.cloud_resource_types.create( | ||
name="Test", provider="Dell", content_types=["cloud.cloudservice"] | ||
) | ||
cloud_account = nb_client.cloud.cloud_accounts.create(name="TestAcct", provider="Dell", account_number="424242") | ||
cloud_service = nb_client.cloud.cloud_services.create( | ||
name="TestService", cloud_resource_type="Test", cloud_account="TestAcct" | ||
) | ||
assert cloud_service | ||
|
||
# Read | ||
test_cloud_service = nb_client.cloud.cloud_services.get(name="TestService") | ||
assert test_cloud_service.name == "TestService" | ||
|
||
# Update | ||
test_cloud_service.name = "Updated TestService" | ||
test_cloud_service.save() | ||
updated_cloud_service = nb_client.cloud.cloud_services.get(name="Updated TestService") | ||
assert updated_cloud_service.name == "Updated TestService" | ||
|
||
# Delete | ||
updated_cloud_service.delete() | ||
deleted_cloud_service = nb_client.cloud.cloud_services.get(name="Updated TestService") | ||
assert not deleted_cloud_service | ||
|
||
# Cleanup | ||
cloud_resource_type.delete() | ||
cloud_account.delete() | ||
|
||
def test_cloud_networks(self, skipif_version, nb_client): | ||
"""Verify we can CRUD a cloud service.""" | ||
assert skipif_version | ||
|
||
# Create | ||
cloud_resource_type = nb_client.cloud.cloud_resource_types.create( | ||
name="Test", provider="Dell", content_types=["cloud.cloudnetwork"] | ||
) | ||
cloud_account = nb_client.cloud.cloud_accounts.create(name="TestAcct", provider="Dell", account_number="424242") | ||
cloud_network = nb_client.cloud.cloud_networks.create( | ||
name="TestNetwork", cloud_resource_type="Test", cloud_account="TestAcct" | ||
) | ||
assert cloud_network | ||
|
||
# Read | ||
test_cloud_network = nb_client.cloud.cloud_networks.get(name="TestNetwork") | ||
assert test_cloud_network.name == "TestNetwork" | ||
|
||
# Update | ||
test_cloud_network.name = "Updated TestNetwork" | ||
test_cloud_network.save() | ||
updated_cloud_network = nb_client.cloud.cloud_networks.get(name="Updated TestNetwork") | ||
assert updated_cloud_network.name == "Updated TestNetwork" | ||
|
||
# Delete | ||
updated_cloud_network.delete() | ||
deleted_cloud_network = nb_client.cloud.cloud_networks.get(name="Updated TestNetwork") | ||
assert not deleted_cloud_network | ||
|
||
# Cleanup | ||
cloud_resource_type.delete() | ||
cloud_account.delete() |