summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/openstack_utils.py
blob: 2c57b7c8db73f05aaf05c0ad64abba332202fd76 (plain)
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
#!/usr/bin/env python
#
# Copyright (c) 2018 xudan16@huawei.com and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#

import json
import os_client_config
import shade
from shade import exc


class OS_Utils(object):

    def __init__(self, **kwargs):
        self.cloud = shade.OperatorCloud(os_client_config.get_config(**kwargs))
        self.images = []
        self.flavors = []

    def list_endpoints(self):
        try:
            res = self.cloud.search_endpoints()
            endpoints = json.dumps(res)
            return True, endpoints
        except exc.OpenStackCloudException as o_exc:
            return False, o_exc.orig_message