Skip to content

Simple 7993 deprecated module names #156

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

Open
wants to merge 2 commits into
base: dev
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
6 changes: 2 additions & 4 deletions virl2_client/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any
import warnings
from typing import TYPE_CHECKING, Any

from ..utils import _deprecated_argument, get_url_from_template

Expand Down Expand Up @@ -165,9 +165,7 @@ def group_labs(self, group_id: str) -> list[str]:
:returns: A list of labs associated with this group.
"""
warnings.warn(
"'GroupManagement.group_labs()' is deprecated."
"Use '.associations' instead.",
DeprecationWarning,
"'GroupManagement.group_labs()' is deprecated.Use '.associations' instead.",
)
return [lab["id"] for lab in self.get_group(group_id)["labs"]]

Expand Down
27 changes: 27 additions & 0 deletions virl2_client/models/groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# This file is part of VIRL 2
# Copyright (c) 2019-2025, Cisco Systems, Inc.
# All rights reserved.
#
# Python bindings for the Cisco VIRL 2 Network Simulation Platform
#
# 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 warnings

from .group import * # noqa

warnings.warn(
"The module name 'virl2_client.models.groups' is deprecated."
"Use 'virl2_client.models.group' instead.",
)
7 changes: 0 additions & 7 deletions virl2_client/models/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def is_physical(self) -> bool:
"""
warnings.warn(
"'Interface.is_physical' is deprecated. Use '.physical' instead.",
DeprecationWarning,
)
return self.physical

Expand Down Expand Up @@ -324,7 +323,6 @@ def remove_on_server(self) -> None:
"""
warnings.warn(
"'Interface.remove_on_server()' is deprecated. Use '.remove()' instead.",
DeprecationWarning,
)
self._remove_on_server()

Expand All @@ -350,7 +348,6 @@ def peer_interfaces(self):
warnings.warn(
"'Interface.peer_interfaces()' is deprecated, "
"use '.peer_interface' instead.",
DeprecationWarning,
)
return {self.peer_interface}

Expand All @@ -363,7 +360,6 @@ def peer_nodes(self):
"""
warnings.warn(
"'Interface.peer_nodes() is deprecated. Use '.peer_node' instead.",
DeprecationWarning,
)
return {self.peer_node}

Expand All @@ -376,7 +372,6 @@ def links(self):
"""
warnings.warn(
"'Interface.links()' is deprecated. Use '.link' instead.",
DeprecationWarning,
)
link = self.link
if link is None:
Expand All @@ -392,7 +387,6 @@ def degree(self):
"""
warnings.warn(
"'Interface.degree()' is deprecated. Use '.connected' instead.",
DeprecationWarning,
)
return int(self.connected)

Expand All @@ -405,7 +399,6 @@ def is_connected(self):
"""
warnings.warn(
"'Interface.is_connected()' is deprecated. Use '.connected' instead.",
DeprecationWarning,
)
return self.connected

Expand Down
7 changes: 0 additions & 7 deletions virl2_client/models/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ def get_link_by_nodes(node1: Node, node2: Node) -> Link:
warnings.warn(
"'Lab.get_link_by_nodes()' is deprecated. "
"Use 'Node.get_link_to()' or 'Node.get_links_to()' instead.",
DeprecationWarning,
)
if not (links := node1.get_links_to(node2)):
raise LinkNotFound
Expand All @@ -520,7 +519,6 @@ def get_link_by_interfaces(iface1: Interface, iface2: Interface) -> Link | None:
warnings.warn(
"'Lab.get_link_by_interfaces()' is deprecated. "
"Use 'Interface.get_link_to()' instead.",
DeprecationWarning,
)
if (link := iface1.link) is not None and iface2 in link.interfaces:
return link
Expand Down Expand Up @@ -653,7 +651,6 @@ def add_node_local(self, *args, **kwargs):
"'Lab.add_node_local()' is deprecated. You probably want Lab.create_node() "
"instead. (If you really want to create a node locally only, "
"use '._create_node_local()'.)",
DeprecationWarning,
)
return self._create_node_local(*args, **kwargs)

Expand Down Expand Up @@ -1353,7 +1350,6 @@ def sync(
"Lab.sync(): The argument 'with_node_configurations' is deprecated, "
"as it does the opposite of what is expected. "
"Use exclude_configurations instead.",
DeprecationWarning,
)
exclude_configurations = with_node_configurations

Expand Down Expand Up @@ -1433,7 +1429,6 @@ def _import_lab(self, topology: dict, created: bool = False) -> None:
warnings.warn(
"Labs created in older CML releases (schema version 0.0.5 or lower)"
" are deprecated. Use labs with schema version 0.1.0 or higher.",
DeprecationWarning,
)
self._title = topology["lab_title"]
self._description = topology["lab_description"]
Expand Down Expand Up @@ -2116,7 +2111,6 @@ def groups(self) -> list[dict[str, str]]:
"""
warnings.warn(
"'Lab.groups' is deprecated. Use '.associations' instead.",
DeprecationWarning,
)
url = self._url_for("lab")
return self._session.get(url).json()["groups"]
Expand All @@ -2137,7 +2131,6 @@ def update_lab_groups(
warnings.warn(
"'Lab.update_lab_groups()' is deprecated. Use '.update_associations()'"
" instead.",
DeprecationWarning,
)
url = self._url_for("lab")
data = {"groups": group_list}
Expand Down
6 changes: 3 additions & 3 deletions virl2_client/models/licensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def get_certificate(self) -> str | None:
"""
if self._is_cert_deprecated:
warnings.warn(
"'Licensing.get_certificate()' is deprecated.", DeprecationWarning
"'Licensing.get_certificate()' is deprecated.",
)
return None
url = self._url_for("certificate")
Expand All @@ -148,7 +148,7 @@ def install_certificate(self, cert: str) -> bool:
"""
if self._is_cert_deprecated:
warnings.warn(
"'Licensing.install_certificate()' is deprecated.", DeprecationWarning
"'Licensing.install_certificate()' is deprecated.",
)
return False
url = self._url_for("certificate")
Expand All @@ -166,7 +166,7 @@ def remove_certificate(self) -> bool:
"""
if self._is_cert_deprecated:
warnings.warn(
"'Licensing.remove_certificate()' is deprecated.", DeprecationWarning
"'Licensing.remove_certificate()' is deprecated.",
)
return False
url = self._url_for("certificate")
Expand Down
1 change: 0 additions & 1 deletion virl2_client/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ def remove_on_server(self) -> None:
"""
warnings.warn(
"'Link.remove_on_server()' is deprecated. Use '.remove()' instead.",
DeprecationWarning,
)
self._remove_on_server()

Expand Down
3 changes: 0 additions & 3 deletions virl2_client/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ def config(self) -> str | None:
"""
warnings.warn(
"'Node.config' is deprecated. Use '.configuration' instead.",
DeprecationWarning,
)
return self.configuration

Expand All @@ -477,7 +476,6 @@ def config(self, value: str) -> None:
"""
warnings.warn(
"'Node.config' is deprecated. Use '.configuration' instead.",
DeprecationWarning,
)
self.configuration = value

Expand Down Expand Up @@ -771,7 +769,6 @@ def remove_on_server(self) -> None:
"""
warnings.warn(
"'Node.remove_on_server()' is deprecated. Use '.remove()' instead.",
DeprecationWarning,
)
# To not change behavior of scripts, this will still remove on server only.
self._remove_on_server()
Expand Down
2 changes: 0 additions & 2 deletions virl2_client/models/node_image_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def upload_node_definition(
"'NodeImageDefinitions.upload_node_definition()': "
"The argument 'json' is deprecated as the content type "
"is determined from the provided 'body'.",
DeprecationWarning,
)
is_json = True
url = self._url_for("node_defs")
Expand Down Expand Up @@ -170,7 +169,6 @@ def upload_image_definition(
"'NodeImageDefinitions.upload_image_definition()': "
"The argument 'json' is deprecated as the content type "
"is determined from the provided 'body'.",
DeprecationWarning,
)
is_json = True
url = self._url_for("image_defs")
Expand Down
27 changes: 27 additions & 0 deletions virl2_client/models/node_image_definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# This file is part of VIRL 2
# Copyright (c) 2019-2025, Cisco Systems, Inc.
# All rights reserved.
#
# Python bindings for the Cisco VIRL 2 Network Simulation Platform
#
# 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 warnings

from .node_image_definition import * # noqa

warnings.warn(
"The module name 'virl2_client.models.node_image_definitions' is deprecated."
"Use 'virl2_client.models.node_image_definition' instead.",
)
27 changes: 27 additions & 0 deletions virl2_client/models/resource_pools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# This file is part of VIRL 2
# Copyright (c) 2019-2025, Cisco Systems, Inc.
# All rights reserved.
#
# Python bindings for the Cisco VIRL 2 Network Simulation Platform
#
# 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 warnings

from .resource_pool import * # noqa

warnings.warn(
"The module name 'virl2_client.models.resource_pools' is deprecated."
"Use 'virl2_client.models.resource_pool' instead.",
)
3 changes: 1 addition & 2 deletions virl2_client/models/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

import logging
import time
from typing import TYPE_CHECKING, Any
import warnings
from typing import TYPE_CHECKING, Any

from virl2_client.exceptions import ControllerNotFound

Expand Down Expand Up @@ -482,7 +482,6 @@ def nodes(self) -> list[str]:
warnings.warn(
"'ComputeHost.nodes' is deprecated. Use 'ComputeHost.node_counts' or "
"'ClientLibrary.get_diagnostics(DiagnosticsCategory.COMPUTES)' instead.",
DeprecationWarning,
)
self._system.sync_compute_hosts_if_outdated()
return self._nodes
Expand Down
27 changes: 27 additions & 0 deletions virl2_client/models/users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# This file is part of VIRL 2
# Copyright (c) 2019-2025, Cisco Systems, Inc.
# All rights reserved.
#
# Python bindings for the Cisco VIRL 2 Network Simulation Platform
#
# 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 warnings

from .user import * # noqa

warnings.warn(
"The module name 'virl2_client.models.users' is deprecated."
"Use 'virl2_client.models.user' instead.",
)