Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 1 | from storm.services.nova.json.images_client import ImagesClient |
| 2 | from storm.services.nova.json.flavors_client import FlavorsClient |
| 3 | from storm.services.nova.json.servers_client import ServersClient |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 4 | from storm.common.utils import data_utils |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 5 | import storm.config |
| 6 | |
| 7 | |
| 8 | class Manager(object): |
| 9 | |
| 10 | def __init__(self): |
| 11 | """ |
| 12 | Top level manager for all Openstack APIs |
| 13 | """ |
| 14 | |
| 15 | self.config = storm.config.StormConfig() |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 16 | self.auth_url = data_utils.build_url(self.config.nova.host, |
| 17 | self.config.nova.port, |
| 18 | self.config.nova.apiVer, |
| 19 | self.config.nova.path) |
| 20 | |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 21 | if self.config.env.authentication == 'keystone_v2': |
| 22 | self.servers_client = ServersClient(self.config.nova.username, |
| 23 | self.config.nova.api_key, |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 24 | self.auth_url, |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 25 | self.config.nova.tenant_name) |
| 26 | self.flavors_client = FlavorsClient(self.config.nova.username, |
| 27 | self.config.nova.api_key, |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 28 | self.auth_url, |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 29 | self.config.nova.tenant_name) |
| 30 | self.images_client = ImagesClient(self.config.nova.username, |
| 31 | self.config.nova.api_key, |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 32 | self.auth_url, |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 33 | self.config.nova.tenant_name) |
| 34 | else: |
| 35 | #Assuming basic/native authentication |
| 36 | self.servers_client = ServersClient(self.config.nova.username, |
| 37 | self.config.nova.api_key, |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 38 | self.auth_url) |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 39 | self.flavors_client = FlavorsClient(self.config.nova.username, |
| 40 | self.config.nova.api_key, |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 41 | self.auth_url) |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 42 | self.images_client = ImagesClient(self.config.nova.username, |
| 43 | self.config.nova.api_key, |
Rohit Karajgi | e1b050d | 2011-12-02 16:13:18 -0800 | [diff] [blame^] | 44 | self.auth_url) |