/usr/lib/python2.7/dist-packages/profitbricks-2.3.1.egg-info/PKG-INFO is in python-profitbricks 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | Metadata-Version: 1.1
Name: profitbricks
Version: 2.3.1
Summary: ProfitBricks API Client Library for Python
Home-page: https://github.com/profitbricks/profitbricks-sdk-python
Author: Matt Baldwin (stackpointcloud.com)
Author-email: baldwin@stackpointcloud.com
License: Apache 2.0
Download-URL: https://github.com/profitbricks/profitbricks-sdk-python/tarball/2.3.1
Description: The ProfitBricks Client Library for Python provides you with access to the ProfitBricks REST API. The client library supports both simple and complex requests. It is designed for developers who are building applications in Python.
This guide will walk you through getting setup with the library and performing various actions against the API.
## Table of Contents
* [Concepts](#concepts)
* [Getting Started](#getting-started)
* [Installation](#installation)
* [Authenticating](#authenticating)
* [Using the Module](#using-the-module)
* [Additional Documentation and Support](#additional-documentation-and-support)
* [How to: Create a Datacenter](#how-to-create-a-datacenter)
* [How to: Delete a Datacenter](#how-to-delete-a-datacenter)
* [How to: Update Cores, Memory, and Disk](#how-to-update-cores-memory-and-disk)
* [How to: List Servers, Volumes, and Data Centers](#how-to-list-servers-volumes-and-data-centers)
* [How to: Create Additional Network Interfaces](#how-to-create-additional-network-interfaces)
* [Conclusion](#conclusion)
## Concepts
The Python Client Library wraps the latest version of the ProfitBricks REST API. All API operations are performed over SSL and authenticated using your ProfitBricks portal credentials. The API can be accessed within an instance running in ProfitBricks or directly over the Internet from any application that can send an HTTPS request and receive an HTTPS response.
## Getting Started
Before you begin you will need to have [signed-up](https://www.profitbricks.com/signup) for a ProfitBricks account. The credentials you setup during sign-up will be used to authenticate against the API.
## Installation
The Python Client Library is available on [PyPi](https://pypi.python.org/pypi/profitbricks). You can install the latest stable version using pip:
pip install profitbricks
Done!
## Authenticating
Connecting to ProfitBricks is handled by first setting up your authentication.
from profitbricks.client import ProfitBricksService
client = ProfitBricksService(
username='username', password='password')
You can now use `client` for any future request.
## Using the Module
Here are a few examples on how to use the module. In this first one we pull a list of our datacenters.
from profitbricks.client import ProfitBricksService
client = ProfitBricksService(
username='username', password='password')
datacenters = client.list_datacenters()
And in this one we reserve an IPBlock:
from profitbricks.client import ProfitBricksService, IPBlock
client = ProfitBricksService(
username='username', password='password')
i = IPBlock(location='de/fra', size=5)
ipblock = client.reserve_ipblock(i)
Some object creation supports simple and complex requests, such as a server which can be created simply by doing this:
from profitbricks.client import ProfitBricksService
from profitbricks.client import Server, NIC, Volume
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
client = ProfitBricksService(
username='username', password='password')
i = Server(
name='server1',
ram=4096,
cores=4
)
response = client.create_server(
datacenter_id=datacenter_id,
server=i)
or if you want one with some volumes and NICs you would do:
from profitbricks.client import ProfitBricksService
from profitbricks.client import Server, NIC, Volume
server_id = '700e1cab-99b2-4c30-ba8c-1d273ddba023'
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
client = ProfitBricksService(
username='username', password='password')
nic1 = NIC(
name='nic1',
ips=['10.2.2.3'],
dhcp='true',
lan=1,
firewall_active=True,
)
nic2 = NIC(
name='nic2',
ips=['10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True,
)
volume1 = Volume(
name='volume1',
size=56,
image='<IMAGE/SNAPSHOT-ID>',
bus='VIRTIO'
)
volume2 = Volume(
name='volume2',
size=56,
image='<IMAGE/SNAPSHOT-ID>',
bus='VIRTIO'
)
nics = [nic1, nic2]
create_volumes = [volume1, volume2]
i = Server(
name='server1',
ram=4096,
cores=4,
nics=nics,
create_volumes=create_volumes
)
response = client.create_server(
datacenter_id=datacenter_id, server=i)
## Additional Documentation and Support
You can find additional examples in our repo [here]. If you find any issues, please let us know via the DevOps Central community or GitHub's issue system and we'll check it out.
## How to: Create a Datacenter
ProfitBricks introduces the concept of Virtual Datacenters. These are logically separated from one and the other and allow you to have a self-contained environment for all servers, volumes, networking, snapshots, and so forth. The goal is to give you the same experience as you would have if you were running your own physical datacenter.
You will need a datacenter before you can create anything else. Like the server functions, the datacenter functions can be used to create a simple vDC or a complex one.
To create a simple one you would do this:
from profitbricks.client import ProfitBricksService
from profitbricks.client import Datacenter, Volume, Server
client = ProfitBricksService(
username='username', password='password')
i = Datacenter(
username='username',
password='password',
name='datacenter1',
description='My New Datacenter',
location='de/fkb'
)
response = client.create_datacenter(datacenter=i)
To create a complex datacenter you would do this. As you can see, you can create quite a few of the objects you will need later all in one request. These all get serialized in a request queue which you can check using the Requests functions:
from profitbricks.client import ProfitBricksService
from profitbricks.client import Datacenter, Volume, Server
from profitbricks.client import LAN, NIC, LoadBalancer, FirewallRule
client = ProfitBricksService(
username='username', password='password')
fwrule1 = FirewallRule(
name='Open SSH port',
protocol='TCP',
source_mac='01:23:45:67:89:00',
port_range_start=22
)
fwrule2 = FirewallRule(
name='Allow PING',
protocol='ICMP',
icmp_type=8,
icmp_code=0
)
fw_rules = [fwrule1, fwrule2]
nic1 = NIC(
name='nic1',
ips=['10.2.2.3'],
dhcp='true',
lan=1,
firewall_active=True,
firewall_rules=fw_rules
)
nic2 = NIC(
name='nic2',
ips=['10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True,
firewall_rules=fw_rules
)
nics = [nic1, nic2]
volume1 = Volume(
name='volume1',
size=56,
image='<IMAGE/SNAPSHOT-ID>',
bus='VIRTIO'
)
volume2 = Volume(
name='volume2',
size=56,
image='<IMAGE/SNAPSHOT-ID>',
bus='VIRTIO'
)
volumes = [volume2]
server1 = Server(
name='server1',
ram=4096,
cores=4,
nics=nics,
create_volumes=[volume1]
)
servers = [server1]
balancednics = ['<NIC-ID-1>', '<NIC-ID-2>']
loadbalancer1 = LoadBalancer(
name='My LB',
balancednics=balancednics)
loadbalancers = [loadbalancer1]
lan1 = LAN(
name='public Lan 4',
public=True
)
lan2 = LAN(
name='public Lan 4',
public=True
)
lans = [lan1, lan2]
d = Datacenter(
name='datacenter1',
description='my DC',
location='de/fkb',
servers=servers,
volumes=volumes,
loadbalancers=loadbalancers,
lans=lans
)
response = client.create_datacenter(datacenter=d)
## How to: Delete a Datacenter
You will want to exercise a bit of caution here. Removing a datacenter will **destroy** all objects contained within that datacenter -- servers, volumes, snapshots, and so on. The objects -- once removed -- will be unrecoverable.
from profitbricks.client import ProfitBricksService
client = ProfitBricksService(
username='username', password='password')
datacenter_id = '700e1cab-99b2-4c30-ba8c-
datacenter = client.delete_datacenter(datacenter_id=datacenter_id)
## How to: Update Cores, Memory, and Disk
ProfitBricks allows users to dynamically update cores, memory, and disk independently of each other. This removes the restriction of needing to upgrade to the next size up to receive an increase in memory. You can now simply increase the instances memory keeping your costs in-line with your resource needs.
The following code illustrates how you can update cores and memory:
from profitbricks.client import ProfitBricksService
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
server_id = '700e1cab-99b2-4c30-ba8c-1d273ddba023'
client = ProfitBricksService(
username='username', password='password')
server = client.update_server(
datacenter_id=datacenter_id,
server_id=server_id,
cores=16,
ram=2048)
This is how you would update your volume's size:
from profitbricks.client import ProfitBricksService, Volume
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
volume_id = '700e1cab-99b2-4c30-ba8c-1d273ddba025'
client = ProfitBricksService(
username='username', password='password')
volume = client.update_volume(
datacenter_id=datacenter_id,
volume_id=volume_id,
size=100,
name='Resized storage to 100 GB',
cpu_hot_unplug=True)
## How to: List Servers, Volumes, and Data Centers
Listing resources is fairly straight forward.
Grabbing the datacenters:
from profitbricks.client import ProfitBricksService
client = ProfitBricksService(
username='username', password='password')
datacenters = client.list_datacenters()
Your servers:
from profitbricks.client import ProfitBricksService
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
client = ProfitBricksService(
username='username', password='password')
servers = client.list_servers(datacenter_id=datacenter_id)
Finally, your volumes:
from profitbricks.client import ProfitBricksService
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
client = ProfitBricksService(
username='username', password='password')
volumes = self.volume.list_volumes(
datacenter_id=datacenter_id)
## How to: Create Additional Network Interfaces
The ProfitBricks platform supports adding multiple NICs to a server. These NICs can be used to create different, segmented networks on the platform.
The sample below shows you how to add a second NIC to an existing server:
from profitbricks.client import ProfitBricksService, FirewallRule, NIC
datacenter_id = '700e1cab-99b2-4c30-ba8c-1d273ddba022'
server_id = '700e1cab-99b2-4c30-ba8c-1d273ddba023'
client = ProfitBricksService(
username='username', password='password')
i = NIC(
name='nic1',
ips=['10.2.2.3','10.2.3.4'],
dhcp='true',
lan=1,
firewall_active=True
)
response = client.create_nic(
datacenter_id=datacenter_id,
server_id=server_id,
nic=i)
## Conclusion
We touched on only a few ways you can interact with the ProfitBricks API using python. Our repo, located [here], has further examples. If you have any other question, ping us in the community.
Keywords: profitbricks api client cloud
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Natural Language :: English
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Internet :: WWW/HTTP
|