summaryrefslogtreecommitdiff
path: root/example.py
diff options
context:
space:
mode:
authorRoberto Bertó <463349+robertoberto@users.noreply.github.com>2026-05-19 03:15:55 -0300
committerGitHub <noreply@github.com>2026-05-19 03:15:55 -0300
commit294d060ac1557ed70cab7a12f97d930f9dc4baf9 (patch)
tree25e03a160fb1dc05a27a9118a7a6f573f0ffd123 /example.py
parentffd5ba16eb1ada42a582db4ac8bdaf29f66a868f (diff)
parent6071528289e4a8b11a772433c33851136d30f133 (diff)
downloadpyvyos-294d060ac1557ed70cab7a12f97d930f9dc4baf9.tar.gz
pyvyos-294d060ac1557ed70cab7a12f97d930f9dc4baf9.zip
Merge pull request #31 from vyos-contrib/release/v0.4.0-cleanupv0.4.0
Release v0.4.0 — cleanup and consolidation
Diffstat (limited to 'example.py')
-rw-r--r--example.py113
1 files changed, 0 insertions, 113 deletions
diff --git a/example.py b/example.py
deleted file mode 100644
index e48983a..0000000
--- a/example.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# importing modules
-import warnings
-
-warnings.filterwarnings("ignore", category=RuntimeWarning)
-import os
-
-# adding pyvyos to sys.path
-# sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__))))
-
-from dotenv import load_dotenv
-import pprint
-import random
-import string
-
-# importing pyvyos modules
-from pyvyos.device import VyDevice
-
-# getting env variables
-load_dotenv()
-hostname = os.getenv("VYDEVICE_HOSTNAME")
-apikey = os.getenv("VYDEVICE_APIKEY")
-port = os.getenv("VYDEVICE_PORT")
-protocol = os.getenv("VYDEVICE_PROTOCOL")
-verify = os.getenv("VYDEVICE_VERIFY_SSL")
-
-if verify == "False":
- verify = False
-else:
- verify = True
-
-# running example
-if __name__ == "__main__":
- # preparing connection to vyos device
- device = VyDevice(
- hostname=hostname,
- apikey=apikey,
- port=port,
- protocol=protocol,
- verify=verify,
- timeout=60,
- )
-
- response = device.retrieve_show_config(["system"])
- pprint.pprint(response)
- response = device.configure_set(
- path=["interfaces", "dummy", "dum1", "address", "192.168.56.100/24"]
- )
- pprint.pprint(response)
-
- response = device.retrieve_return_values(
- path=["interfaces", "dummy", "dum1", "address"]
- )
- pprint.pprint(response)
-
- response = device.configure_delete(path=["interfaces", "dummy", "dum1"])
- pprint.pprint(response)
-
- randstring = "".join(
- random.choice(string.ascii_letters + string.digits) for _ in range(20)
- )
- keyrand = f"/tmp/key_{randstring}"
- response = device.generate(path=["ssh", "client-key", keyrand])
- pprint.pprint(response)
-
- response = device.show(path=["system", "image"])
- pprint.pprint(response)
-
- response = device.reset(path=["conntrack-sync", "internal-cache"])
- pprint.pprint(response)
-
- response = device.config_file_save(file="/config/test300.config")
- pprint.pprint(response)
-
- response = device.config_file_load(file="/config/test300.config")
- pprint.pprint(response)
-
- response = device.configure_multiple_op(
- op_path=[
- {
- "op": "set",
- "path": ["interfaces", "dummy", "dum1", "address", "192.168.56.100/24"],
- },
- {
- "op": "delete",
- "path": ["interfaces", "dummy", "dum1"],
- },
- ]
- )
- pprint.pprint(response)
-
- # print("### Generating ssh key ###")
- # randstring = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
- # keyrand = f'/tmp/key_{randstring}'
- # response = device.generate(path=["ssh", "client-key", keyrand])
- # pprint.pprint(response)
-
- # response = device.retrieve_return_values(path=["interfaces", "ethernet", "eth0", "address"])
- # pprint.pprint(response)
-
- # response = device.reset(path=["conntrack-sync", "internal-cache"])
- # pprint.pprint(response)
-
- # response = device.reboot(path=["now"])
- # pprint.pprint(response)
-
- # response = device.shutdown(path=["now"])
- # pprint.pprint(response)
-
- # response = device.image_add(url="https://github.com/vyos/vyos-rolling-nightly-builds/releases/download/1.5-rolling-202312130023/vyos-1.5-rolling-202312130023-amd64.iso")
- # pprint.pprint(response)
-
- # response = device.image_delete(name="foo")
- # pprint.pprint(response)