def create_my_ssh_key(): data = parse_request_data(_SCHEMA.allowed, _SCHEMA.required) try: kp = bound_client_set().compute.keypairs.create( data['name'], data.get('public-key')) except osc_exc.BadRequest, e: raise exc.InvalidRequest(str(e))
def list_my_ssh_keys(): parse_collection_request(_SCHEMA) result = [keypair_to_view(keypair) for keypair in bound_client_set().compute.keypairs.list()] return make_collection_response('ssh-keys', result, parent_href=url_for('me.get_current_user'))
def list_my_ssh_keys(): parse_collection_request(_SCHEMA) result = [ keypair_to_view(keypair) for keypair in bound_client_set().compute.keypairs.list() ] return make_collection_response('ssh-keys', result, parent_href=url_for('me.get_current_user'))
def get_instance_type(instance_type_id): # the following great code returns deleted flavors... #try: # flavor = g.client_set.compute.flavors.get(instance_type_id) #except osc_exc.NotFound: # abort(404) all_flavors = bound_client_set().compute.flavors.list() for flavor in all_flavors: if flavor.id == instance_type_id: return make_json_response(_instance_type_to_view(flavor)) abort(404)
def test_bound_client_user(self): # pretend we have unbound client set: self.fake_client_set.http_client.access['user']['roles'] = [] tenants = [doubles.make(self.mox, doubles.Tenant, id='PID1'), doubles.make(self.mox, doubles.Tenant, id='PID2')] self.fake_client_set.identity_public.tenants.list() \ .AndReturn(tenants) auth.client_set_for_tenant('PID1').AndReturn('FAKE_CS') self.mox.ReplayAll() with self.app.test_request_context(): self.install_fake_auth() self.assertEquals(auth.bound_client_set(), 'FAKE_CS')
def test_bound_client_user(self): # pretend we have unbound client set: self.fake_client_set.http_client.access['user']['roles'] = [] tenants = [ doubles.make(self.mox, doubles.Tenant, id='PID1'), doubles.make(self.mox, doubles.Tenant, id='PID2') ] self.fake_client_set.identity_public.tenants.list() \ .AndReturn(tenants) auth.client_set_for_tenant('PID1').AndReturn('FAKE_CS') self.mox.ReplayAll() with self.app.test_request_context(): self.install_fake_auth() self.assertEquals(auth.bound_client_set(), 'FAKE_CS')
def delete_my_ssh_key(key_name): try: bound_client_set().compute.keypairs.delete(key_name) except osc_exc.NotFound: abort(404) return make_json_response(None, 204)
def get_my_ssh_key(key_name): try: keypair = bound_client_set().compute.keypairs.find(name=key_name) except osc_exc.NotFound: abort(404) return make_json_response(keypair_to_view(keypair))
def test_bound_client_admin(self): self.mox.ReplayAll() with self.app.test_request_context(): self.install_fake_auth() self.assertEquals(auth.bound_client_set(), g.client_set)
def list_instance_types(): parse_collection_request(_SCHEMA) all_flavors = bound_client_set().compute.flavors.list() result = [_instance_type_to_view(flavor) for flavor in all_flavors] return make_collection_response(u'instance-types', result)