Add support for log snapshotting API

Change-Id: I00a5bfdd3dd5c3632150cd9d4a1dcb94b881a7ee
This commit is contained in:
Andrew Hutchings 2013-03-27 20:24:25 +00:00
parent 7269763333
commit 8f95966fb9
4 changed files with 31 additions and 1 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
python-libraclient (1.2.5-1) UNRELEASED; urgency=low
* Adds support for Load Balancer log snapshotting
-- Andrew Hutchings <andrew@linuxjedi.co.uk> Wed, 27 Mar 2013 20:24:06 +0000
python-libraclient (1.2.4-1) UNRELEASED; urgency=low
* Adds input filtering and error handling for --node options

View File

@ -12,4 +12,4 @@
# License for the specific language governing permissions and limitations
# under the License.
__version__ = "1.2.4"
__version__ = "1.2.5"

View File

@ -162,6 +162,15 @@ class ClientOptions(object):
sp.add_argument('--nodeid', help='node ID to get status from',
required=True)
sp = subparsers.add_parser(
'logs', help='send a snapshot of logs to an object store'
)
sp.add_argument('--id', help='load balancer ID', required=True)
sp.add_argument('--storage', help='storage type', choices=['Swift'])
sp.add_argument('--endpoint', help='object store endpoint to use')
sp.add_argument('--basepath', help='object store based directory')
sp.add_argument('--token', help='object store authentication token')
def run(self):
self._generate()
return self.options.parse_args()

View File

@ -188,6 +188,21 @@ class LibraAPI(object):
columns = ['id', 'address', 'port', 'condition', 'status']
self._render_dict(column_names, columns, body)
def logs_lb(self, args):
data = {}
if args.storage:
data['ObjectStoreType'] = args.storage
if args.endpoint:
data['ObjectStoreEndpoint'] = args.endpoint
if args.basepath:
data['ObjectStoreBasePath'] = args.basepath
if args.token:
data['ObjectStoreAuthToken'] = args.token
resp, body = self._post('/loadbalancers/{0}/logs'.format(args.id),
body=data)
def _render_list(self, column_names, columns, data):
table = prettytable.PrettyTable(column_names)
for item in data: