def __init__(self, username, apikey, auth_url='https://auth.api.rackspacecloud.com/v1.0'): self.backup_schedules = BackupScheduleManager(self) self.client = OpenStackClient(username, apikey, auth_url) self.flavors = FlavorManager(self) self.images = ImageManager(self) self.ipgroups = IPGroupManager(self) self.keys = KeyManager(self) self.servers = ServerManager(self) self.volumes = VolumeManager(self) self.zones = ZoneManager(self)
class OpenStack(object): """ Top-level object to access the OpenStack Nova API. Create an instance with your creds:: >>> os = OpenStack(USERNAME, API_KEY, AUTH_URL) Then call methods on its managers:: >>> os.servers.list() ... >>> os.flavors.list() ... &c. """ def __init__(self, username, apikey, auth_url='https://auth.api.rackspacecloud.com/v1.0'): self.backup_schedules = BackupScheduleManager(self) self.client = OpenStackClient(username, apikey, auth_url) self.flavors = FlavorManager(self) self.images = ImageManager(self) self.ipgroups = IPGroupManager(self) self.keys = KeyManager(self) self.servers = ServerManager(self) self.volumes = VolumeManager(self) self.zones = ZoneManager(self) def authenticate(self): """ Authenticate against the server. Normally this is called automatically when you first access the API, but you can call this method to force authentication right now. Returns on success; raises :exc:`novatools.Unauthorized` if the credentials are wrong. """ self.client.authenticate()
def client(): cl = OpenStackClient("username", "apikey", "auth_test") cl.management_url = "http://example.com" cl.auth_token = "token" return cl