Exemplo n.º 1
0
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))
Exemplo n.º 2
0
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))
Exemplo n.º 3
0
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'))
Exemplo n.º 4
0
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'))
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
    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')
Exemplo n.º 7
0
    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')
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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))
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
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))
Exemplo n.º 14
0
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)