From 24688a32dd2868cc8ebac64f606c706396761447 Mon Sep 17 00:00:00 2001 From: Yusei Nishioka Date: Tue, 23 Aug 2016 23:58:34 +0900 Subject: [PATCH 01/21] Update API Documentation in README.rst. --- README.rst | 104 +++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/README.rst b/README.rst index 43b89ff..0a9c2d9 100644 --- a/README.rst +++ b/README.rst @@ -46,54 +46,56 @@ Python Vultr is supported on a volunteer basis. **API** -* def __init__(self, api_key): -* def snapshot.list(self): -* def snapshot.destroy(self, snapshotid): -* def snapshot.create(self, subid): -* def iso.list(self): -* def plans.list(self): -* def regions.list(self): -* def regions.availability(self, dcid): -* def startupscript.list(self): -* def startupscript.destroy(self, scriptid): -* def startupscript.create(self, name, script): -* def startupscript.update(self, scriptid, name, script): -* def dns.list(self): -* def dns.records(self, domain): -* def dns.create_domain(self, domain, serverip): -* def dns.delete_domain(self, domain): -* def dns.delete_record(self, domain, recordid): -* def dns.create_record(self, domain, name, type, data, ttl=None, -* def sshkey.list(self): -* def sshkey.destroy(self, sshkeyid): -* def sshkey.create(self): -* def sshkey.update(self, sshkeyid, name=None, ssh_key=None): -* def backup.list(self): -* def server.list(self, subid): -* def server.bandwidth(self): -* def server.reboot(self): -* def server.halt(self): -* def server.start(self): -* def server.destroy(self): -* def server.reinstall(self): -* def server.restore_snapshot(self, subid, snapshotid): -* def server.restore_backup(self, subid, backupid): -* def server.create(self, dcid, vpsplanid, osid, ipxe_chain_url=None, -* def server.list_ipv4(self, subid): -* def server.reverse_set_ipv4(self): -* def server.reverse_default_ipv4(self, subid, ip): -* def server.list_ipv6(self): -* def server.reverse_list_ipv6(self): -* def server.reverse_set_ipv6(self, subid, ip, entry): -* def server.reverse_delete_ipv6(self, subid, ip): -* def server.label_set(self, subid, label): -* def server.create_ipv4(self, subid, reboot): -* def server.destroy_ipv4(self, subid, ip): -* def server.os_change_list(self): -* def server.os_change(self, subid, osid): -* def server.upgrade_plan_list(self): -* def server.upgrade_plan(self, subid, vpsplanid): -* def app.list(self): -* def account.info(self): -* def os.list(self): -* def request(self, path, params={}, method='GET'): +* def account.info(self, params=None): +* def app.list(self, params=None): +* def backup.list(self, params=None): +* def dns.create_domain(self, domain, ipaddr, params=None): +* def dns.create_record(self, domain, name, _type, data, params=None): +* def dns.delete_domain(self, domain, params=None): +* def dns.delete_record(self, domain, recordid, params=None): +* def dns.list(self, params=None): +* def dns.records(self, domain, params=None): +* def dns.update_record(self, domain, recordid, params=None): +* def iso.list(self, params=None): +* def os.list(self, params=None): +* def plans.list(self, params=None): +* def regions.availability(self, dcid, params=None): +* def regions.list(self, params=None): +* def server.ipv4.create(self, subid, params=None): +* def server.ipv4.destroy(self, subid, ipaddr, params=None): +* def server.ipv4.list(self, subid, params=None): +* def server.ipv4.reverse_default(self, subid, ipaddr, params=None): +* def server.ipv4.reverse_set(self, subid, ipaddr, entry, params=None): +* def server.ipv6.list_ipv6(self, subid, params=None): +* def server.ipv6.reverse_delete_ipv6(self, subid, ipaddr, params=None): +* def server.ipv6.reverse_list_ipv6(self, subid, params=None): +* def server.ipv6.reverse_set_ipv6(self, subid, ipaddr, entry, params=None): +* def server.bandwidth(self, subid, params=None): +* def server.create(self, dcid, vpsplanid, osid, params=None): +* def server.destroy(self, subid, params=None): +* def server.get_user_data(self, subid, params=None): +* def server.halt(self, subid, params=None): +* def server.label_set(self, subid, label, params=None): +* def server.list(self, subid=None, params=None): +* def server.neighbors(self, subid, params=None): +* def server.os_change(self, subid, osid, params=None): +* def server.os_change_list(self, subid, params=None): +* def server.reboot(self, subid, params=None): +* def server.reinstall(self, subid, params=None): +* def server.restore_backup(self, subid, backupid, params=None): +* def server.restore_snapshot(self, subid, snapshotid, params=None): +* def server.set_user_data(self, subid, userdata, params=None): +* def server.start(self, subid, params=None): +* def server.upgrade_plan(self, subid, vpsplanid, params=None): +* def server.upgrade_plan_list(self, subid, params=None): +* def snapshot.create(self, subid, params=None): +* def snapshot.destroy(self, snapshotid, params=None): +* def snapshot.list(self, params=None): +* def sshkey.create(self, name, ssh_key, params=None): +* def sshkey.destroy(self, sshkeyid, params=None): +* def sshkey.list(self, params=None): +* def sshkey.update(self, sshkeyid, params=None): +* def startupscript.create(self, name, script, params=None): +* def startupscript.destroy(self, scriptid, params=None): +* def startupscript.list(self, params=None): +* def startupscript.update(self, scriptid, params=None): From c5ab495fb11db30effa2a818bd24d5e17d057be2 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Thu, 22 Sep 2016 01:30:48 -0400 Subject: [PATCH 02/21] remove py3.2 build and add py3.5 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5feb263..daba867 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: python python: - "2.7" - - "3.2" - "3.3" - "3.4" + - "3.5" - "nightly" install: - "pip install ." From 75de46558109cf48d416a085423236cd3694c222 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Thu, 22 Sep 2016 01:32:28 -0400 Subject: [PATCH 03/21] update setup.py to include 3.4 and 3.5. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index dfdb766..03aed6c 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,8 @@ def read(filename): 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Topic :: Software Development :: Libraries :: Python Modules' ], license=read('LICENSE'), From bf64c159989585a8a77417f7fd868f0e3fc63c77 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Thu, 22 Sep 2016 02:23:38 -0400 Subject: [PATCH 04/21] Update tests to manually run live server start and stop. --- .gitignore | 2 ++ tests/test_vultr.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c15c68f..35531c0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ Lib Scripts *.egg-info *.pyc + +venv diff --git a/tests/test_vultr.py b/tests/test_vultr.py index f68696b..61478dd 100644 --- a/tests/test_vultr.py +++ b/tests/test_vultr.py @@ -3,6 +3,7 @@ import os from time import sleep import warnings +import pprint from vultr import Vultr, VultrError VULTR_TEST_LABEL = 'python-vultr: test' @@ -86,7 +87,7 @@ def test_server_create(self): response = self.vultr.server.create( 1, # DCID (New Jersey, USA) 29, # VPSPLANID (768 MB RAM,15 GB SSD,1.00 TB BW) - 191, # OSID (Ubuntu 15.04 x64) + 216, # OSID (Ubuntu 16.04 i386) { 'label': VULTR_TEST_LABEL } @@ -100,7 +101,6 @@ def test_server_create(self): def test_server_list(self): '''List servers''' AuthenticatedTests.server_list = self.vultr.server.list() - warnings.warn(str(AuthenticatedTests.server_list)) def test_server_list_by_subid(self): '''List server by SUBID''' From 5c059dac382b89c7a89908949b923348fe634c21 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Thu, 22 Sep 2016 02:24:09 -0400 Subject: [PATCH 05/21] add a referral link in hopes of generating some money to cover testing costs. --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 0a9c2d9..9a5cddd 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ Vultr .. image:: https://travis-ci.org/spry-group/python-vultr.svg?branch=master :target: https://travis-ci.org/spry-group/python-vultr -Vultr provides a client library to the Vultr.com API. +Vultr provides a client library to the `Vultr.com ` API. **Usage** From 2a7b3770c673102f20699813405b5e9bff19378e Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Wed, 18 Apr 2018 02:13:53 +0700 Subject: [PATCH 06/21] Add iso/create_from_url --- README.rst | 1 + vultr/v1_iso.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9a5cddd..63a6f40 100644 --- a/README.rst +++ b/README.rst @@ -57,6 +57,7 @@ Python Vultr is supported on a volunteer basis. * def dns.records(self, domain, params=None): * def dns.update_record(self, domain, recordid, params=None): * def iso.list(self, params=None): +* def iso.create_from_url(self, url, params=None) * def os.list(self, params=None): * def plans.list(self, params=None): * def regions.availability(self, dcid, params=None): diff --git a/vultr/v1_iso.py b/vultr/v1_iso.py index e77364e..1c5f190 100644 --- a/vultr/v1_iso.py +++ b/vultr/v1_iso.py @@ -1,5 +1,5 @@ '''Partial class to handle Vultr ISO API calls''' -from .utils import VultrBase +from .utils import VultrBase, update_params class VultrISO(VultrBase): @@ -16,3 +16,18 @@ def list(self, params=None): ''' params = params if params else dict() return self.request('/v1/iso/list', params, 'GET') + + def create_from_url(self, url, params=None): + ''' /vi/iso/create_from_url + POST - account + Create a new ISO image on the current account. + The ISO image will be downloaded from a given URL. + Download status can be checked with the v1/iso/list call. + + Link: https://www.vultr.com/api/#iso_create_from_url + ''' + params = update_params(params, { + 'url': url, + }) + return self.request('/v1/iso/create_from_url', params, 'POST') + From 7bf476108a9e40fbd3add837e9993fb7e6a8ca23 Mon Sep 17 00:00:00 2001 From: cpburnz Date: Mon, 23 Apr 2018 23:25:16 -0400 Subject: [PATCH 07/21] Add partial support for firewall --- tests/test_vultr.py | 4 ++++ vultr/v1_firewall.py | 18 ++++++++++++++++++ vultr/vultr.py | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 vultr/v1_firewall.py diff --git a/tests/test_vultr.py b/tests/test_vultr.py index 61478dd..93a0891 100644 --- a/tests/test_vultr.py +++ b/tests/test_vultr.py @@ -49,6 +49,10 @@ def test_dns_list(self): '''List DNS records''' self.vultr.dns.list() + def test_firewall_group_list(self): + '''List firewall groups''' + self.vultr.firewall.group_list() + def test_iso_list(self): '''List ISOs / images''' self.vultr.iso.list() diff --git a/vultr/v1_firewall.py b/vultr/v1_firewall.py new file mode 100644 index 0000000..1669ada --- /dev/null +++ b/vultr/v1_firewall.py @@ -0,0 +1,18 @@ +'''Partial class to handle Vultr Firewall API calls''' +from .utils import VultrBase + + +class VultrFirewall(VultrBase): + '''Handles Bultr Firewall API calls''' + def __init__(self, api_key): + VultrBase.__init__(self, api_key) + + def group_list(self, params=None): + ''' /v1/firewall/group_list + GET - account + List all firewall groups on the current account. + + Link: https://www.vultr.com/api/#firewall_group_list + ''' + params = params if params else dict() + return self.request('/v1/firewall/group_list', params, 'GET') diff --git a/vultr/vultr.py b/vultr/vultr.py index c7670d4..d9684c8 100644 --- a/vultr/vultr.py +++ b/vultr/vultr.py @@ -4,6 +4,7 @@ from .v1_app import VultrApp from .v1_backup import VultrBackup from .v1_dns import VultrDNS +from .v1_firewall import VultrFirewall from .v1_iso import VultrISO from .v1_os import VultrOS from .v1_plans import VultrPlans @@ -25,6 +26,7 @@ def __init__(self, api_key): self.app = VultrApp(api_key) self.backup = VultrBackup(api_key) self.dns = VultrDNS(api_key) + self.firewall = VultrFirewall(api_key) self.iso = VultrISO(api_key) # pylint: disable=invalid-name # OS is the Vultr API namespace name From 9f9db6242c3bac5626caf922487209f6f9af1cd8 Mon Sep 17 00:00:00 2001 From: cpburnz Date: Mon, 23 Apr 2018 23:29:22 -0400 Subject: [PATCH 08/21] Add partial support for firewall --- vultr/v1_firewall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vultr/v1_firewall.py b/vultr/v1_firewall.py index 1669ada..2b20c03 100644 --- a/vultr/v1_firewall.py +++ b/vultr/v1_firewall.py @@ -3,7 +3,7 @@ class VultrFirewall(VultrBase): - '''Handles Bultr Firewall API calls''' + '''Handles Vultr Firewall API calls''' def __init__(self, api_key): VultrBase.__init__(self, api_key) From 9b7d1a5417bf182724d44d7473d4444f2dfc8233 Mon Sep 17 00:00:00 2001 From: Luke Hodkinson Date: Thu, 25 Jan 2018 12:06:37 +1100 Subject: [PATCH 09/21] Add reservedip to endpoints --- vultr/v1_reservedip.py | 22 ++++++++++++++++++++++ vultr/vultr.py | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 vultr/v1_reservedip.py diff --git a/vultr/v1_reservedip.py b/vultr/v1_reservedip.py new file mode 100644 index 0000000..c869b33 --- /dev/null +++ b/vultr/v1_reservedip.py @@ -0,0 +1,22 @@ +'''Partial class to handle Vultr ReservedIP API calls''' +from .utils import VultrBase, update_params + + +class VultrReservedIP(VultrBase): + '''Handles Vultr ReservedIP API calls''' + def __init__(self, api_key): + VultrBase.__init__(self, api_key) + + def create(self, dcid, ip_type, params=None): + ''' /v1/reservedip/create + POST - account + Create a new reserved IP. Reserved IPs can only be used within the + same datacenter for which they were created. + + Link: https://www.vultr.com/api/#reservedip_create + ''' + params = update_params(params, { + 'DCID': dcid, + 'ip_type': ip_type + }) + return self.request('/v1/reservedip/create', params, 'POST') diff --git a/vultr/vultr.py b/vultr/vultr.py index d9684c8..87d78db 100644 --- a/vultr/vultr.py +++ b/vultr/vultr.py @@ -9,6 +9,7 @@ from .v1_os import VultrOS from .v1_plans import VultrPlans from .v1_regions import VultrRegions +from .v1_reservedip import VultrReservedIP from .v1_server import VultrServer from .v1_snapshot import VultrSnapshot from .v1_sshkey import VultrSSHKey @@ -33,6 +34,7 @@ def __init__(self, api_key): self.os = VultrOS(api_key) self.plans = VultrPlans(api_key) self.regions = VultrRegions(api_key) + self.reservedip = VultrReservedIP(api_key) self.server = VultrServer(api_key) self.snapshot = VultrSnapshot(api_key) self.sshkey = VultrSSHKey(api_key) From 9a7bebe5ae6c5484bb7a45891259c950578a43b4 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Mon, 4 Jun 2018 13:58:56 -0400 Subject: [PATCH 10/21] chore: update contributor guidelines and add requirements.txt --- CONTRIBUTING.md | 11 ++++++++--- requirements.txt | Bin 0 -> 162 bytes setup.cfg | 7 +++++-- setup.py | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 requirements.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3368817..d5a6625 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,10 +17,15 @@ Please send an email to darrel.opry@spry-group.com if you are interested in beco ## Development ``` - pip install setuptools virtualenv pep8 wheel twine +# dependencies +pip install -r requirements.txt +# development dependencies +pip install setuptools virtualenv pep8 wheel twine ``` +When makeing commit messages please follow the [Angular Git Commit Guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) + ## Testing Tests spawn and destroy instances labelled 'python-vultr: test' @@ -39,10 +44,10 @@ python setup.py test Releases are tracked by creating a pull request from master to release. Ensure the version has been properly upticked before creating the release candidate pull request. The merged commit should be tagged with the proper version and built and uploaded to pypi. Currently the release process is manual. Once a more mature testing suite in place, it should be automated with TravisCI. ``` +rm -rf dist/ python setup.py sdist python setup.py bdist_wheel -python setup.py sdist upload -r pypi -python setup.py bdist_wheel upload -r pypi +twine upload -r pypi .\dist\vultr* ``` based on: [Sharing Your Labor of Love: PyPI Quick and Dirty](https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..194585636eccc8613993e69598a76edd4d078e2d GIT binary patch literal 162 zcmX|(NeX~45CrQi_?2K(#EXw{#efKI-&Z?vp_#cnsH^ y5iKLN%ufCuyi7C+mgi1nmhmi@x3$V%IP^EQwx53czIkYMQXCCgFsxQn#nT&M$`_&l literal 0 HcmV?d00001 diff --git a/setup.cfg b/setup.cfg index d7de2b1..008ce81 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,5 @@ -[wheel] -universal=1 \ No newline at end of file +[bdist_wheel] +universal=1 + +[metadata] +license_file=LICENSE \ No newline at end of file diff --git a/setup.py b/setup.py index f3116fa..b02ac78 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(filename): setup( name='vultr', - version='1.0rc1', + version='1.0.0', install_requires=[ "requests" ], From 97f1ece085611c408cbe979e503215d2baa8bca0 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Mon, 4 Jun 2018 17:16:59 -0400 Subject: [PATCH 11/21] chore: fix copyright notice --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index bfa56f5..e7a140e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013 devo.ps +Copyright (c) 2018 The Spry Group, LLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From a4da15d3e8da830799ce53a988dea0f3044256b4 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Mon, 4 Jun 2018 17:23:15 -0400 Subject: [PATCH 12/21] chore: convert README to markdown. --- README.rst => README.md | 53 +++++++++++++++++------------------------ setup.py | 3 ++- 2 files changed, 24 insertions(+), 32 deletions(-) rename README.rst => README.md (78%) diff --git a/README.rst b/README.md similarity index 78% rename from README.rst rename to README.md index 63a6f40..b1e091b 100644 --- a/README.rst +++ b/README.md @@ -1,50 +1,41 @@ -Vultr -===== -.. image:: https://travis-ci.org/spry-group/python-vultr.svg?branch=master - :target: https://travis-ci.org/spry-group/python-vultr +# Vultr -Vultr provides a client library to the `Vultr.com ` API. +[![build status](https://travis-ci.org/spry-group/python-vultr.svg?branch=master)](https://travis-ci.org/spry-group/python-vultr) -**Usage** +Vultr provides a client library to the [Vultr.com](http://www.vultr.com/?ref=6989379-3B) API. -.. code:: python +## Usage - api_key = 'XXXXXXXXX' - vultr = Vultr(api_key) - plans_json = vultr.plans.list() +```python +api_key = 'XXXXXXXXX' +vultr = Vultr(api_key) +plans_json = vultr.plans.list() +``` +## Testing - -**Testing** - - From the repo root directory - Performs generic, unauthenticated tests - -.. code:: shell +From the repo root directory +Performs generic, unauthenticated tests - python -m unittest -v tests.test_vultr.UnauthenticatedTests - +```shell +python -m unittest -v tests.test_vultr.UnauthenticatedTests +``` Requires the environment variable VULTR_KEY to be set -.. code:: shell - - python -m unittest -v tests.test_vultr.AuthenticatedTests - - -**Support** +```shell +python -m unittest -v tests.test_vultr.AuthenticatedTests +``` +## Support Python Vultr is supported on a volunteer basis. -* `Open an Issue `_ - -* .. image:: https://badges.gitter.im/Join%20Chat.svg - :target: https://gitter.im/spry-group/python-vultr - +* [Open an Issue](https://github.com/spry-group/python-vultr/issues/new) +* [![Gitter.im](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spry-group/python-vultr) -**API** +## API * def account.info(self, params=None): * def app.list(self, params=None): diff --git a/setup.py b/setup.py index b02ac78..c0d6ec7 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,8 @@ def read(filename): "requests" ], description='Vultr.com API Client', - long_description=(read('README.rst')), + long_description=(read('README.md')), + long_description_content_type='text/markdown', url='http://github.com/spry-group/python-vultr', author='Darrel O\'Pry', author_email='darrel.opry@spry-group.com', From 564e198f54e101f8ec6f28249a3cff3246a31c29 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Mon, 4 Jun 2018 18:38:04 -0400 Subject: [PATCH 13/21] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c0d6ec7..4ce4c62 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(filename): setup( name='vultr', - version='1.0.0', + version='1.0.1', install_requires=[ "requests" ], From 14926b4e1ab7cdb03b46250de9b7fb3b598be897 Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 16 Jun 2018 22:29:08 +0900 Subject: [PATCH 14/21] - inital code to fetch server list --- examples/basic_running.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 examples/basic_running.py diff --git a/examples/basic_running.py b/examples/basic_running.py new file mode 100644 index 0000000..a1f0a50 --- /dev/null +++ b/examples/basic_running.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +'''Basic app to list requestsunning servers''' + +import logging +from os import environ +from json import dumps +from vultr import Vultr, VultrError + +# Looks for an environment variable named "VULTR_KEY" +API_KEY = environ.get('VULTR_KEY') +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s %(levelname)s [%(funcName)s():%(lineno)d] %(message)s' +) +logging.getLogger("requests").setLevel(logging.WARNING) + +def servers_running(): + '''Shows various details about the account & servers''' + vultr = Vultr(API_KEY) + + try: + serverList = vultr.server.list() + logging.info('Listing servers:\n%s', dumps( + serverList, indent=2 + )) + except VultrError as ex: + logging.error('VultrError: %s', ex) + + +def main(): + '''Entry point''' + logging.info('Vultr API Client Python Library') + logging.info('URL: https://www.vultr.com/api/') + servers_running() + +main() From ecb9cacabe2b460f16846ca4217f9687ff3d966f Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 16 Jun 2018 22:42:20 +0900 Subject: [PATCH 15/21] - shows running servers --- examples/basic_running.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/basic_running.py b/examples/basic_running.py index a1f0a50..e55ec2c 100644 --- a/examples/basic_running.py +++ b/examples/basic_running.py @@ -4,7 +4,7 @@ import logging from os import environ -from json import dumps +from json import dumps, load from vultr import Vultr, VultrError # Looks for an environment variable named "VULTR_KEY" @@ -16,17 +16,20 @@ logging.getLogger("requests").setLevel(logging.WARNING) def servers_running(): - '''Shows various details about the account & servers''' + '''Shows running servers''' vultr = Vultr(API_KEY) try: serverList = vultr.server.list() - logging.info('Listing servers:\n%s', dumps( - serverList, indent=2 - )) + #logging.info('Listing servers:\n%s', dumps( + #serverList, indent=2 + #)) except VultrError as ex: logging.error('VultrError: %s', ex) + for key in serverList: + if serverList[key]['power_status'] == 'running': + logging.info(serverList[key]['label'] + " is up and running.") def main(): '''Entry point''' From 4291eefe42af7a3809142fef4c4705d98c687a0b Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 16 Jun 2018 22:45:28 +0900 Subject: [PATCH 16/21] - Added script to halt all running VMs --- examples/basic_haltRunning.py | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/basic_haltRunning.py diff --git a/examples/basic_haltRunning.py b/examples/basic_haltRunning.py new file mode 100644 index 0000000..09d1290 --- /dev/null +++ b/examples/basic_haltRunning.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +'''Basic app to hallt all running servers''' + +import logging +from os import environ +from json import dumps, load +from vultr import Vultr, VultrError + +# Looks for an environment variable named "VULTR_KEY" +API_KEY = environ.get('VULTR_KEY') +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s %(levelname)s [%(funcName)s():%(lineno)d] %(message)s' +) +logging.getLogger("requests").setLevel(logging.WARNING) + +def servers_running(): + '''Halts all running servers''' + vultr = Vultr(API_KEY) + + try: + serverList = vultr.server.list() + #logging.info('Listing servers:\n%s', dumps( + #serverList, indent=2 + #)) + except VultrError as ex: + logging.error('VultrError: %s', ex) + + for key in serverList: + if serverList[key]['power_status'] == 'running': + logging.info(serverList[key]['label'] + " will be gracefully shutdown.") + vultr.halt(key) + +def main(): + '''Entry point''' + logging.info('Vultr API Client Python Library') + logging.info('URL: https://www.vultr.com/api/') + servers_running() + +main() From 63cca35428b256146a1f3708a3c50ba191d93552 Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 16 Jun 2018 22:46:21 +0900 Subject: [PATCH 17/21] - Typo --- examples/basic_running.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic_running.py b/examples/basic_running.py index e55ec2c..2166bd1 100644 --- a/examples/basic_running.py +++ b/examples/basic_running.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -'''Basic app to list requestsunning servers''' +'''Basic app to list all running servers''' import logging from os import environ From fada15e35de1e464137a240bea6c979414a2df0b Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 16 Jun 2018 22:56:35 +0900 Subject: [PATCH 18/21] - halt is actually in the server class --- examples/basic_haltRunning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic_haltRunning.py b/examples/basic_haltRunning.py index 09d1290..44b3253 100644 --- a/examples/basic_haltRunning.py +++ b/examples/basic_haltRunning.py @@ -30,7 +30,7 @@ def servers_running(): for key in serverList: if serverList[key]['power_status'] == 'running': logging.info(serverList[key]['label'] + " will be gracefully shutdown.") - vultr.halt(key) + vultr.server.halt(key) def main(): '''Entry point''' From fff9a2f3cc8c5d85cf38f190e75b69e03789f96c Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Sat, 16 Jun 2018 23:20:53 +0900 Subject: [PATCH 19/21] - Renamed function in haltRunning - Fixed hallt typo - renamed key -> serverID --- examples/basic_haltRunning.py | 14 +++++++------- examples/basic_running.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/basic_haltRunning.py b/examples/basic_haltRunning.py index 44b3253..7521992 100644 --- a/examples/basic_haltRunning.py +++ b/examples/basic_haltRunning.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -'''Basic app to hallt all running servers''' +'''Basic app to halt all running servers''' import logging from os import environ @@ -15,7 +15,7 @@ ) logging.getLogger("requests").setLevel(logging.WARNING) -def servers_running(): +def halt_running(): '''Halts all running servers''' vultr = Vultr(API_KEY) @@ -27,15 +27,15 @@ def servers_running(): except VultrError as ex: logging.error('VultrError: %s', ex) - for key in serverList: - if serverList[key]['power_status'] == 'running': - logging.info(serverList[key]['label'] + " will be gracefully shutdown.") - vultr.server.halt(key) + for serverID in serverList: + if serverList[serverID]['power_status'] == 'running': + logging.info(serverList[serverID]['label'] + " will be gracefully shutdown.") + vultr.server.halt(serverID) def main(): '''Entry point''' logging.info('Vultr API Client Python Library') logging.info('URL: https://www.vultr.com/api/') - servers_running() + halt_running() main() diff --git a/examples/basic_running.py b/examples/basic_running.py index 2166bd1..b688c28 100644 --- a/examples/basic_running.py +++ b/examples/basic_running.py @@ -27,9 +27,9 @@ def servers_running(): except VultrError as ex: logging.error('VultrError: %s', ex) - for key in serverList: - if serverList[key]['power_status'] == 'running': - logging.info(serverList[key]['label'] + " is up and running.") + for serverID in serverList: + if serverList[serverID]['power_status'] == 'running': + logging.info(serverList[serverID]['label'] + " is up and running.") def main(): '''Entry point''' From 55382d94a0c15079cd171e0f99e60a6d4b406a35 Mon Sep 17 00:00:00 2001 From: Darrel O'Pry Date: Tue, 4 Feb 2020 23:40:46 -0500 Subject: [PATCH 20/21] fix(ci): update python versions - travis updated build image to 16.04 - 3.3 isn't packaged for 16.04 - add newer python versions for testing. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index daba867..58b89a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,12 @@ language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" + - "3.6" + - "3.7" + - "3.8" - "nightly" install: - "pip install ." -script: "python setup.py develop && python setup.py test" \ No newline at end of file +script: "python setup.py develop && python setup.py test" From 9e4803d789ec88fd83c5d0b88bdfe2b91b81be7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2020 04:41:52 +0000 Subject: [PATCH 21/21] Bump requests from 2.18.4 to 2.20.0 Bumps [requests](https://github.com/requests/requests) from 2.18.4 to 2.20.0. - [Release notes](https://github.com/requests/requests/releases) - [Changelog](https://github.com/psf/requests/blob/master/HISTORY.md) - [Commits](https://github.com/requests/requests/compare/v2.18.4...v2.20.0) Signed-off-by: dependabot[bot] --- requirements.txt | Bin 162 -> 83 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index 194585636eccc8613993e69598a76edd4d078e2d..4598c01ddcaf18314bd33c049cce0db2702ce595 100644 GIT binary patch literal 83 zcmaFAdw+6jQAuW6rmd}!fuV(-iJqYuFIRF#Vo^$JiLI@%o`IeTFIQ$tULsI|9#E<% iwXig`xTF}wH8RjM;N>bU%E`%0GPbof)H5>TnsH^ y5iKLN%ufCuyi7C+mgi1nmhmi@x3$V%IP^EQwx53czIkYMQXCCgFsxQn#nT&M$`_&l