| 1 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 3 |
# not use this file except in compliance with the License. You may obtain |
| 4 |
# a copy of the License at |
| 5 |
# |
| 6 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
# |
| 8 |
# Unless required by applicable law or agreed to in writing, software |
| 9 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 10 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 11 |
# License for the specific language governing permissions and limitations |
| 12 |
# under the License. |
| 13 |
|
| 14 |
from seamicroclient import client |
| 15 |
from seamicroclient.v2 import chassis |
| 16 |
from seamicroclient.v2 import disks |
| 17 |
from seamicroclient.v2 import fantrays |
| 18 |
from seamicroclient.v2 import interfaces |
| 19 |
from seamicroclient.v2 import pools |
| 20 |
from seamicroclient.v2 import powersupplies |
| 21 |
from seamicroclient.v2 import scards |
| 22 |
from seamicroclient.v2 import servers |
| 23 |
from seamicroclient.v2 import smcards |
| 24 |
from seamicroclient.v2 import system |
| 25 |
from seamicroclient.v2 import volumes |
| 26 |
|
| 27 |
|
| 28 |
class Client(object): |
| 29 |
|
| 30 |
""" |
| 31 |
Top-level object to access the Seamicro Chassis API. |
| 32 |
|
| 33 |
Create an instance with your creds:: |
| 34 |
|
| 35 |
>>> client = Client(USERNAME, PASSWORD, AUTH_URL) |
| 36 |
|
| 37 |
Then call methods on its managers:: |
| 38 |
|
| 39 |
>>> client.servers.list() |
| 40 |
... |
| 41 |
>>> client.chassis.list() |
| 42 |
... |
| 43 |
|
| 44 |
""" |
| 45 |
|
| 46 |
def __init__(self, username, password, auth_url=None, |
| 47 |
timeout=None, http_log_debug=False): |
| 48 |
self.servers = servers.ServerManager(self) |
| 49 |
self.pools = pools.PoolManager(self) |
| 50 |
self.volumes = volumes.VolumeManager(self) |
| 51 |
self.disks = disks.DiskManager(self) |
| 52 |
self.chassis = chassis.ChassisManager(self) |
| 53 |
self.fantrays = fantrays.FanTrayManager(self) |
| 54 |
self.interfaces = interfaces.InterfaceManager(self) |
| 55 |
self.powersupplies = powersupplies.PowerSupplyManager(self) |
| 56 |
self.scards = scards.ScardManager(self) |
| 57 |
self.smcards = smcards.SMCardManager(self) |
| 58 |
self.system = system.SystemManager(self) |
| 59 |
|
| 60 |
self.client = client.HTTPClient(username, |
| 61 |
password, |
| 62 |
auth_url=auth_url, |
| 63 |
timeout=timeout, |
| 64 |
http_log_debug=http_log_debug) |
| 65 |
|
| 66 |
def get_timings(self): |
| 67 |
return self.client.get_timings() |
| 68 |
|
| 69 |
def reset_timings(self): |
| 70 |
self.client.reset_timings() |
| 71 |
|
| 72 |
def authenticate(self): |
| 73 |
""" |
| 74 |
Authenticate against the server. |
| 75 |
|
| 76 |
Normally this is called automatically when you first access the API, |
| 77 |
but you can call this method to force authentication right now. |
| 78 |
|
| 79 |
Returns on success; raises :exc:`exceptions.Unauthorized` if the |
| 80 |
credentials are wrong. |
| 81 |
""" |
| 82 |
self.client.authenticate() |