updated GraphQL for Netbox 4.4
This commit is contained in:
parent
d25f7aeec3
commit
23fb524f0a
2 changed files with 11 additions and 4 deletions
|
|
@ -21,6 +21,9 @@ from pynetbox_config_helper import build_argparser, resolve_graphql_config
|
|||
|
||||
import importlib.resources
|
||||
|
||||
class GraphQlError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -72,6 +75,10 @@ def graphql_query(client: GraphqlClient, query, variables: Optional[Dict] = None
|
|||
|
||||
data = client.execute(query, variables=variables)
|
||||
|
||||
errors = data.get("errors")
|
||||
if errors:
|
||||
raise GraphQlError(errors)
|
||||
|
||||
logger.debug(f"received data from GraphQL:\n{pformat(data)}")
|
||||
return data
|
||||
|
||||
|
|
@ -161,8 +168,8 @@ def build_vm():
|
|||
query,
|
||||
variables={
|
||||
"address": str(interface_addr.ip),
|
||||
"prefix_length": str(interface_addr.network.prefixlen),
|
||||
"vrf": "null",
|
||||
"prefix_length": "/" + str(interface_addr.network.prefixlen),
|
||||
"vrf": None,
|
||||
},
|
||||
)["data"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue