Update the README.rst file
This patch will change the markdown syntax from the README.rst with the reStructuredText syntax.
This commit is contained in:
parent
29ab864163
commit
5d6e403a30
135
README.rst
135
README.rst
@ -2,7 +2,8 @@
|
|||||||
python-hnvclient
|
python-hnvclient
|
||||||
================
|
================
|
||||||
|
|
||||||
[](https://travis-ci.org/cloudbase/python-hnvclient)
|
.. image:: https://travis-ci.org/cloudbase/python-hnvclient.svg?branch=master
|
||||||
|
:target: https://travis-ci.org/cloudbase/python-hnvclient
|
||||||
|
|
||||||
Python client for the HNV (Hyper-V Network Virtualization) REST API.
|
Python client for the HNV (Hyper-V Network Virtualization) REST API.
|
||||||
|
|
||||||
@ -18,87 +19,85 @@ Features
|
|||||||
|
|
||||||
The Python interface matches the underlying REST API and can be employed in 3rd party projects.
|
The Python interface matches the underlying REST API and can be employed in 3rd party projects.
|
||||||
|
|
||||||
```python
|
.. code:: python
|
||||||
>>> from hnv import client
|
|
||||||
>>> logical_networks = client.LogicalNetworks.get()
|
|
||||||
>>> for logical_network in logical_networks:
|
|
||||||
... print(logical_network.resource_id)
|
|
||||||
...
|
|
||||||
"63606911-e053-42cf-842e-29f67c90d5c6"
|
|
||||||
"c4cd42ff-5efb-4006-ac56-479730557926"
|
|
||||||
"cd804db3-df59-4f57-8a7d-11cc3f3c4d98"
|
|
||||||
|
|
||||||
>>> logical_network = client.LogicalNetworks.get(resource_id="cd804db3-df59-4f57-8a7d-11cc3f3c4d98")
|
>>> from hnv import client
|
||||||
>>> logical_network
|
>>> logical_networks = client.LogicalNetworks.get()
|
||||||
<hnv.client.LogicalNetworks object at 0x7fcd79419910>
|
>>> for logical_network in logical_networks:
|
||||||
>>> logical_network.provisioning_state
|
... print(logical_network.resource_id)
|
||||||
u'Succeeded'
|
...
|
||||||
>>> logical_network.subnetworks
|
"63606911-e053-42cf-842e-29f67c90d5c6"
|
||||||
[<hnv.client.LogicalSubnetworks object at 0x7fcd79419150>]
|
"c4cd42ff-5efb-4006-ac56-479730557926"
|
||||||
>>> logical_network.subnetworks[0].resource_id
|
"cd804db3-df59-4f57-8a7d-11cc3f3c4d98"
|
||||||
u'4390e3d8-c527-4534-882f-906c47ffd0bb'
|
|
||||||
```
|
|
||||||
|
|
||||||
or
|
>>> logical_network = client.LogicalNetworks.get(resource_id="cd804db3-df59-4f57-8a7d-11cc3f3c4d98")
|
||||||
|
>>> logical_network
|
||||||
|
<hnv.client.LogicalNetworks object at 0x7fcd79419910>
|
||||||
|
>>> logical_network.provisioning_state
|
||||||
|
u'Succeeded'
|
||||||
|
>>> logical_network.subnetworks
|
||||||
|
[<hnv.client.LogicalSubnetworks object at 0x7fcd79419150>]
|
||||||
|
>>> logical_network.subnetworks[0].resource_id
|
||||||
|
u'4390e3d8-c527-4534-882f-906c47ffd0bb'
|
||||||
|
|
||||||
```python
|
.. code:: python
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import json
|
from __future__ import print_function
|
||||||
import sys
|
|
||||||
|
|
||||||
from hnv import config
|
import json
|
||||||
from hnv import client
|
import sys
|
||||||
|
|
||||||
|
from hnv import config
|
||||||
|
from hnv import client
|
||||||
|
|
||||||
|
|
||||||
def view_logical_networks():
|
def view_logical_networks():
|
||||||
"""List all the available logical networks."""
|
"""List all the available logical networks."""
|
||||||
logical_networks = client.LogicalNetworks.get()
|
logical_networks = client.LogicalNetworks.get()
|
||||||
print("Logical networks:")
|
print("Logical networks:")
|
||||||
for logical_network in logical_networks:
|
for logical_network in logical_networks:
|
||||||
print("\t - ", logical_network.resource_ref)
|
print("\t - ", logical_network.resource_ref)
|
||||||
print("\t\t", "Logical subnetworks:")
|
print("\t\t", "Logical subnetworks:")
|
||||||
for logical_subnetwork in logical_network.subnetworks:
|
for logical_subnetwork in logical_network.subnetworks:
|
||||||
print("\t\t - %s (%s)" % (logical_subnetwork.resource_id,
|
print("\t\t - %s (%s)" % (logical_subnetwork.resource_id,
|
||||||
logical_subnetwork.address_prefix))
|
logical_subnetwork.address_prefix))
|
||||||
|
|
||||||
print("\t\t", "Virtual networks:")
|
print("\t\t", "Virtual networks:")
|
||||||
for virtual_network in logical_network.virtual_networks:
|
for virtual_network in logical_network.virtual_networks:
|
||||||
print("\t\t - %s" % virtual_network.resource_ref)
|
print("\t\t - %s" % virtual_network.resource_ref)
|
||||||
|
|
||||||
|
|
||||||
def create_virtual_network():
|
def create_virtual_network():
|
||||||
"""Create a new virtual network on the first logical network."""
|
"""Create a new virtual network on the first logical network."""
|
||||||
print("Creating a new virtual network.")
|
print("Creating a new virtual network.")
|
||||||
address_space = client.AddressSpace(
|
address_space = client.AddressSpace(
|
||||||
address_prefixes=["192.168.133.0/24"])
|
address_prefixes=["192.168.133.0/24"])
|
||||||
|
|
||||||
logical_network = client.Resource(
|
logical_network = client.Resource(
|
||||||
resource_ref=client.LogicalNetworks.get()[0].resource_ref)
|
resource_ref=client.LogicalNetworks.get()[0].resource_ref)
|
||||||
|
|
||||||
virtual_network = client.VirtualNetworks(
|
virtual_network = client.VirtualNetworks(
|
||||||
resource_id="hvn-test",
|
resource_id="hvn-test",
|
||||||
address_space=address_space,
|
address_space=address_space,
|
||||||
logical_network=logical_network,
|
logical_network=logical_network,
|
||||||
)
|
)
|
||||||
virtual_network.commit()
|
virtual_network.commit()
|
||||||
|
|
||||||
print("The raw content of the new Virtual Network")
|
print("The raw content of the new Virtual Network")
|
||||||
print(json.dumps(virtual_network.dump(), indent=4))
|
print(json.dumps(virtual_network.dump(), indent=4))
|
||||||
|
|
||||||
|
|
||||||
def remove_virtual_network():
|
def remove_virtual_network():
|
||||||
"""Remove the new virtual network."""
|
"""Remove the new virtual network."""
|
||||||
print("Remove the new virtual network")
|
print("Remove the new virtual network")
|
||||||
client.VirtualNetworks.remove(resource_id="hvn-test")
|
client.VirtualNetworks.remove(resource_id="hvn-test")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Logical networks sample entry point."""
|
"""Logical networks sample entry point."""
|
||||||
config.CONFIG(sys.argv[1:])
|
config.CONFIG(sys.argv[1:])
|
||||||
view_logical_networks()
|
view_logical_networks()
|
||||||
create_virtual_network()
|
create_virtual_network()
|
||||||
view_logical_networks()
|
view_logical_networks()
|
||||||
remove_virtual_network()
|
remove_virtual_network()
|
||||||
view_logical_networks()
|
view_logical_networks()
|
||||||
```
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user