Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
f856db3
#1059 adding toggle_ipmi.py to hardware cli
ATGE Nov 19, 2018
0f0030a
#1059 adding cli route for hardware toggle-ipmi
ATGE Nov 19, 2018
a5e70dc
#1059 adding server test for toggle-ipmi
ATGE Nov 19, 2018
cc2fed0
#1059 adding toggleManagementInterface to server fixtures
ATGE Nov 19, 2018
5aeff0c
#1059 updating toggle-ipmi test
ATGE Nov 21, 2018
b2a09e6
#1059 Updating click.option to Boolean Flag
ATGE Nov 21, 2018
3a1e016
Merge pull request #1080 from ATGE/fix_issue-1059
allmightyspiff Nov 21, 2018
a720e7e
#1074 have config setup cehck which transport was actually entered to…
allmightyspiff Nov 21, 2018
b0824f1
Fix file volume-cancel
Nov 27, 2018
f86e2d2
fixing a bug where the input endpoint differes from the config endpoint
allmightyspiff Nov 27, 2018
8a2088c
unit tests for config setup
allmightyspiff Nov 27, 2018
42cd438
Merge pull request #1083 from FernandoOjeda/file_cancel
allmightyspiff Nov 27, 2018
2c9e150
tox fixes
allmightyspiff Nov 27, 2018
5dc451f
fixed failing unit test
allmightyspiff Nov 28, 2018
c925e58
Merge pull request #1084 from allmightyspiff/1074
allmightyspiff Nov 28, 2018
427ff1d
tests/CLI/modules/vs_tests:test_upgrade_with_cpu_memory_and_flavor wa…
allmightyspiff Nov 29, 2018
b8c762c
mostly style changes
allmightyspiff Nov 29, 2018
4e426c4
Update provisionedIops reading to handle float-y values
Dec 3, 2018
5c3313e
Merge pull request #1085 from rtpg/patch-1
allmightyspiff Dec 3, 2018
a2643e7
refactored vs create to use Product_Order::placeOrder instead of Virt…
allmightyspiff Dec 4, 2018
6a72362
cdn purge returns a list of objects which indicate the status of each…
Dec 4, 2018
9e1af1b
fix help messages
acamacho82 Dec 4, 2018
08ca596
Merge pull request #1086 from acamacho82/#882
allmightyspiff Dec 5, 2018
66fe5bc
fixed and refactored the vs cli tests
allmightyspiff Dec 5, 2018
b442bc1
refactored more unit tests, and added order_guest unit tests
allmightyspiff Dec 5, 2018
f2d2a30
fixed unit tests
allmightyspiff Dec 6, 2018
e3e13f3
cleaned up code to make tox happy
allmightyspiff Dec 6, 2018
5af4b29
#676 added back in confirmation prompt and export flag. Unit test for…
allmightyspiff Dec 10, 2018
786cacf
#676 fixed userData not being sent in with the order, added a few mor…
allmightyspiff Dec 11, 2018
0b94a90
tox style fixes
allmightyspiff Dec 11, 2018
e478f1d
Merge pull request #1087 from allmightyspiff/676
allmightyspiff Jan 2, 2019
a12f8c1
removed power_state
acamacho82 Jan 11, 2019
d047447
Merge pull request #1090 from acamacho82/#1088
allmightyspiff Jan 11, 2019
7f6f0d2
#1069 basic support for virtual placement groups
allmightyspiff Jan 18, 2019
aa28ab8
unit tests for the cli portion of placement groups
allmightyspiff Jan 18, 2019
3d03455
#1069 unit tests for the placement manageR
allmightyspiff Jan 21, 2019
e3ed32b
unit test fixes
allmightyspiff Jan 22, 2019
ab5a167
style fixes
allmightyspiff Jan 22, 2019
c63e4ce
#1069 documentation for placement groups
allmightyspiff Jan 29, 2019
3af6f8f
added a few resolvers for backendrouters, rules, and placementgroups.…
allmightyspiff Jan 30, 2019
ed7b636
unit tests and style fixes
allmightyspiff Jan 31, 2019
e1d9a52
Added more exception handling.
Jan 31, 2019
3b5c37f
Formating changes.
Jan 31, 2019
ba14a92
More minor changes.
Jan 31, 2019
c81e791
Fixes for tox issues.
Jan 31, 2019
e4a51a9
More updates due to changes in TOX.
Jan 31, 2019
4660a2d
Fixed exception login after failing unit tests.
Jan 31, 2019
e9b6861
Updates to message handling.
Jan 31, 2019
0ceab62
Adjusted exception handler.
Jan 31, 2019
08b6ee4
Renforced a pylint exception.
Jan 31, 2019
63012e8
Added unit tests, and updated exception handling.
Feb 3, 2019
980d11c
Added initial unit tests for percentages.
Feb 4, 2019
effc9ff
Format changes.
Feb 4, 2019
7c23627
More changes for unit tests and lent.
Feb 4, 2019
5e6d45f
Updated documentation line.
Feb 4, 2019
27c9c6f
Merge pull request #1094 from erick-sapp/dev
erick-sapp Feb 4, 2019
9c84cb4
Added fix to shell help.
Feb 4, 2019
2bbbab1
Merge pull request #1091 from allmightyspiff/issues1069
allmightyspiff Feb 4, 2019
4a03ab1
#1093 properly send in hostId when creating a dedicated host VSI
allmightyspiff Feb 5, 2019
eeabb61
Merge pull request #1096 from allmightyspiff/issues1093
allmightyspiff Feb 5, 2019
bd55687
Changes to shell_tests.
Feb 5, 2019
a324f11
Removed a debug statement that was missing from 'git diff' before the…
Feb 5, 2019
08c8214
Merge pull request #1 from softlayer/master
erick-sapp Feb 5, 2019
21c5a8e
Updates for pylint.
Feb 5, 2019
0b83362
Merge pull request #1097 from erick-sapp/dev
allmightyspiff Feb 5, 2019
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
75 changes: 75 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,80 @@ Code is tested and style checked with tox, you can run the tox tests individuall
* create pull request


## Documentation

CLI command should have a more human readable style of documentation.
Manager methods should have a decent docblock describing any parameters and what the method does.

Docs are generated with [Sphinx](https://docs.readthedocs.io/en/latest/intro/getting-started-with-sphinx.html) and once Sphinx is setup, you can simply do

`make html` in the softlayer-python/docs directory, which should generate the HTML in softlayer-python/docs/_build/html for testing.


## Unit Tests

All new features should be 100% code covered, and your pull request should at the very least increase total code overage.

### Mocks
To tests results from the API, we keep mock results in SoftLayer/fixtures/<SoftLayer_Service>/ with the method name matching the variable name.

Any call to a service that doesn't have a fixture will result in a TransportError

### Overriding Fixtures

Adding your expected output in the fixtures file with a unique name is a good way to define a fixture that gets used frequently in a test.

```python
from SoftLayer.fixtures import SoftLayer_Product_Package

def test_test(self):
amock = self.set_mock('SoftLayer_Product_Package', 'getAllObjects')
amock.return_value = fixtures.SoftLayer_Product_Package.RESERVED_CAPACITY
```

Otherwise defining it on the spot works too.
```python
def test_test(self):
mock = self.set_mock('SoftLayer_Network_Storage', 'getObject')
mock.return_value = {
'billingItem': {'hourlyFlag': True, 'id': 449},
}
```


### Call testing
Testing your code to make sure it makes the correct API call is also very important.

The testing.TestCase class has a method call `assert_called_with` which is pretty handy here.

```python
self.assert_called_with(
'SoftLayer_Billing_Item', # Service
'cancelItem', # Method
args=(True, True, ''), # Args
identifier=449, # Id
mask=mock.ANY, # object Mask,
filter=mock.ANY, # object Filter
limit=0, # result Limit
offset=0 # result Offset
)
```

Making sure a API was NOT called

```python
self.assertEqual([], self.calls('SoftLayer_Account', 'getObject'))
```

Making sure an API call has a specific arg, but you don't want to list out the entire API call (like with a place order test)

```python
# Get the API Call signature
order_call = self.calls('SoftLayer_Product_Order', 'placeOrder')

# Get the args property of that API call, which is a tuple, with the first entry being our data.
order_args = getattr(order_call[0], 'args')[0]

# Test our specific argument value
self.assertEqual(123, order_args['hostId'])
```
192 changes: 192 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"

clean:
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/softlayer-python.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/softlayer-python.qhc"

applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/softlayer-python"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/softlayer-python"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."

xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ To get the exact API call that this library makes, you can do the following.
For the CLI, just use the -vvv option. If you are using the REST endpoint, this will print out a curl command that you can use, if using XML, this will print the minimal python code to make the request without the softlayer library.

.. code-block:: bash

$ slcli -vvv vs list


If you are using the library directly in python, you can do something like this.

.. code-bock:: python

import SoftLayer
import logging

Expand All @@ -118,6 +120,8 @@ If you are using the library directly in python, you can do something like this.
main.main()
main.debug()



System Requirements
-------------------
* Python 2.7, 3.3, 3.4, 3.5, 3.6, or 3.7.
Expand Down
20 changes: 18 additions & 2 deletions SoftLayer/CLI/cdn/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@

import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting


@click.command()
@click.argument('account_id')
@click.argument('content_url', nargs=-1)
@environment.pass_env
def cli(env, account_id, content_url):
"""Purge cached files from all edge nodes."""
"""Purge cached files from all edge nodes.

Examples:
slcli cdn purge 97794 http://example.com/cdn/file.txt
slcli cdn purge 97794 http://example.com/cdn/file.txt https://dal01.example.softlayer.net/image.png
"""

manager = SoftLayer.CDNManager(env.client)
manager.purge_content(account_id, content_url)
content_list = manager.purge_content(account_id, content_url)

table = formatting.Table(['url', 'status'])

for content in content_list:
table.add_row([
content['url'],
content['statusCode']
])

env.fout(table)
Loading