|
| 1 | +## About |
| 2 | +```python |
| 3 | +class NetworkManager(): |
| 4 | + """ |
| 5 | + Functions for managing networks. Intended to be used as a mixin for CloudManager. |
| 6 | + """ |
| 7 | +``` |
| 8 | +`NetworkManager` is a mixed into `CloudManager` and the following methods are available by |
| 9 | + |
| 10 | +```python |
| 11 | +manager = CloudManager("api-username", "password") |
| 12 | +manager.method() |
| 13 | +``` |
| 14 | + |
| 15 | +## Methods |
| 16 | + |
| 17 | +```python |
| 18 | +def get_networks(self, zone="fi-hel1"): |
| 19 | + """ |
| 20 | + Get a list of all networks. |
| 21 | + Zone can be passed to return networks in a specific zone but is not mandatory. |
| 22 | + """ |
| 23 | +``` |
| 24 | + |
| 25 | +```python |
| 26 | +def get_network(self, uuid): |
| 27 | + """ |
| 28 | + Retrieves the details of a specific network. |
| 29 | + """ |
| 30 | +``` |
| 31 | + |
| 32 | +```python |
| 33 | +def create_network( |
| 34 | + name='test network', |
| 35 | + zone='fi-hel1', |
| 36 | + address='172.16.0.0/22', |
| 37 | + dhcp='yes', |
| 38 | + family='IPv4', |
| 39 | + ): |
| 40 | + """ |
| 41 | + Creates a new SDN private network that cloud servers from the same zone can be attached to. |
| 42 | + Name, zone, address, dhcp and family arguments are required. |
| 43 | + Router, dhcp_default_route, dhcp_dns, dhcp_bootfile_url and gateway arguments are optional. |
| 44 | + Dhcp and dhcp_default_route accept yes or no (string) as a value. |
| 45 | + Dhcp_dns accepts an array of addresses. |
| 46 | + Returns a Network object. |
| 47 | + """ |
| 48 | +``` |
| 49 | + |
| 50 | +```python |
| 51 | +def modify_network( |
| 52 | + network='036df3d0-8629-4549-984e-dc86fc3fa1b0', |
| 53 | + dhcp='yes', |
| 54 | + family='IPv4', |
| 55 | + router='04b65749-61e2-4f08-a259-c75afbe81abf', |
| 56 | + ): |
| 57 | + """ |
| 58 | + Modifies the details of a specific SDN private network. The Utility and public networks cannot be modified. |
| 59 | + Network, dhcp, family and router arguments are required (router can be an id of a router or a router object, same goes for network). |
| 60 | + Name, router, dhcp_default_route, dhcp_dns, dhcp_bootfile_url and gateway arguments are optional. |
| 61 | + Dhcp and dhcp_default_route accept yes or no (string) as a value. |
| 62 | + Dhcp_dns accepts an array of addresses. |
| 63 | + Returns a Network object. |
| 64 | + """ |
| 65 | +``` |
| 66 | + |
| 67 | +```python |
| 68 | +def delete_network(self, network): |
| 69 | + """ |
| 70 | + Deletes an SDN private network. All attached cloud servers must first be detached before SDN private networks can be deleted. |
| 71 | + Network argument must be provided (can be an id or a Network object). |
| 72 | + Returns an empty response. |
| 73 | + """ |
| 74 | +``` |
| 75 | + |
| 76 | +```python |
| 77 | +def get_server_networks(self, server): |
| 78 | + """ |
| 79 | + List all networks the specific cloud server is connected to. |
| 80 | + Server argument must be passed (can be an id or a Server object). |
| 81 | + Returns a list of Interface objects. |
| 82 | +
|
| 83 | + """ |
| 84 | +``` |
| 85 | + |
| 86 | +```python |
| 87 | +def create_network_interface( |
| 88 | + server='0082c083-9847-4f9f-ae04-811251309b35', |
| 89 | + network='036df3d0-8629-4549-984e-dc86fc3fa1b0', |
| 90 | + type='private', |
| 91 | + ip_addresses=[{'family': 'IPv4', 'address': '172.16.1.10'}] |
| 92 | + ): |
| 93 | + """ |
| 94 | + Creates a new network interface on the specific cloud server and attaches the specified SDN private network to the new interface. |
| 95 | + Server, network, type and ip_addresses arguments must be passed. |
| 96 | + Index, source_ip_filtering and bootable arguments are optional. |
| 97 | + Server and network arguments can be ids or objects. |
| 98 | + Ip_addresses argument must be a list of dicts which contain family and address. |
| 99 | + Index must be an integer. |
| 100 | + Source_ip_filtering and bootable arguments accept a yes or a no string. |
| 101 | + Returns an Interface object. |
| 102 | + """ |
| 103 | +``` |
| 104 | + |
| 105 | +```python |
| 106 | +def modify_network_interface( |
| 107 | + server='0082c083-9847-4f9f-ae04-811251309b35', |
| 108 | + index_in_path=7 |
| 109 | + ): |
| 110 | + """ |
| 111 | + Modifies the network interface at the selected index on the specific cloud server. |
| 112 | + Server and index_in_path arguments are mandatory. |
| 113 | + Index_in_body, ip_addresses, source_ip_filtering and bootable arguments are optional. |
| 114 | + Server argument can be an id or an object. |
| 115 | + Index arguments must be integers. |
| 116 | + Ip_addresses argument must be a list of dicts which contain family and address. |
| 117 | + Source_ip_filtering and bootable arguments accept a yes or a no string. |
| 118 | + Returns an Interface object. |
| 119 | + """ |
| 120 | +``` |
| 121 | + |
| 122 | +```python |
| 123 | +def delete_network_interface(self, server, index): |
| 124 | + """ |
| 125 | + Detaches an SDN private network from a cloud server by deleting the network interface at the selected index on the specific cloud server. |
| 126 | + Server and index arguments are mandatory. |
| 127 | + Server argument can be an id or an object. |
| 128 | + Index argument must be an integer. |
| 129 | + Returns an empty response |
| 130 | + """ |
| 131 | +``` |
| 132 | + |
| 133 | +```python |
| 134 | +def get_routers(self): |
| 135 | + """ |
| 136 | + Returns a list of all available routers associated with the current account (list of Router objects). |
| 137 | + """ |
| 138 | +``` |
| 139 | + |
| 140 | +```python |
| 141 | +def get_router(self, uuid): |
| 142 | + """ |
| 143 | + Returns detailed information about a specific router (router object). |
| 144 | + UUID argument is mandatory |
| 145 | + """ |
| 146 | +``` |
| 147 | + |
| 148 | +```python |
| 149 | +def create_router(self, name): |
| 150 | + """ |
| 151 | + Creates a new router. |
| 152 | + Name is a mandatory argument. |
| 153 | + Returns a Router object. |
| 154 | + """ |
| 155 | +``` |
| 156 | + |
| 157 | +```python |
| 158 | +def modify_router(self, router, name): |
| 159 | + """ |
| 160 | + Modify an existing router. |
| 161 | + Router and name arguments are mandatory. |
| 162 | + Router can be an id or a Router object. |
| 163 | + Returns a Router object. |
| 164 | + """ |
| 165 | +``` |
| 166 | + |
| 167 | +```python |
| 168 | +def delete_router(self, router): |
| 169 | + """ |
| 170 | + Delete an existing router. |
| 171 | + Router argument is mandatory. |
| 172 | + Router can be an id or a Router object. |
| 173 | + Returns a Router object. |
| 174 | + """ |
| 175 | +``` |
0 commit comments