Exemple #1
0
    return result


def list_all_images(client):
    """Get list of all images from all tenants"""
    # NOTE(imelnikov): When is_public is True (the default), images
    # available for current tenant are returned (public images and
    # images from current tenant). When is_public is set to None
    # explicitly, current tenant is ignored.
    return client.list(filters={'is_public': None})


_SCHEMA = Schema(
    (st.String('id'), st.String('name'), st.String('status'),
     st.String('disk-format'), st.String('container-format'),
     st.String('md5sum'), st.Int('size'), st.Timestamp('created'),
     st.Boolean('global'),
     st.LinkObject('project',
                   add_search_matchers={'for': st.not_implemented_matcher}),
     st.LinkObject('kernel'), st.LinkObject('ramdisk')),
    create_required=('name', 'container-format', 'disk-format'),
    create_allowed=('project', 'global', 'kernel', 'ramdisk'),
    updatable=('name'))


def _images_for_tenant(tenant_id, is_public):
    try:
        tenant = auth.admin_client_set().identity_admin \
                .tenants.get(tenant_id)
    except osc_exc.NotFound:
        return []  # consistent with project:eq
Exemple #2
0
 def test_date_is_parsed(self):
     timestamp = datetime(2012, 5, 11, 17, 42, 53)
     schema = Schema((st.Timestamp('test'), ))
     params = {'test': '2012-05-11T17:42:53Z'}
     with self.request_context(params):
         self.assertEquals({'test': timestamp}, parse_request_data(schema))
Exemple #3
0
    auth.assert_admin()
    role_id = member_role_id()
    for project in projects:
        try:
            g.client_set.identity_admin.roles.add_user_role(user=user,
                                                            role=role_id,
                                                            tenant=project)
        except osc_exc.NotFound:
            raise exc.InvalidElementValue('projects', 'link object', project,
                                          'Project does not exist')


_SCHEMA = Schema(
    (st.String('id'), st.String('name'), st.String(
        'fullname', allow_empty=True), st.String('email'), st.Boolean('admin'),
     st.Boolean('completed-registration'), st.Timestamp('invited-at'),
     st.List(st.LinkObject('projects')), st.Boolean('invite'),
     st.String('password'), st.Boolean('send-invite-mail'),
     st.String('link-template')),
    create_required=('email', ),
    create_allowed=('name', 'fullname', 'admin', 'projects', 'invite',
                    'link-template', 'send-invite-mail', 'password'),
    updatable=('name', 'email', 'fullname', 'admin', 'password'),
    list_args=('id', 'name', 'fullname', 'email', 'projects', 'admin',
               'completed-registration', 'invited-at'))


@BP.route('/', methods=('GET', ))
@root_endpoint('users')
@user_endpoint
def list_users():
Exemple #4
0
    if record.project_id is not None and project_name is None:
        try:
            project_name = iadm.tenants.get(record.project_id).name
        except osc_exc.NotFound:
            pass
    return _record_to_dict(record, user_name, project_name)


_SCHEMA = Schema((
    st.String('id'),
    st.String('message'),
    st.String('method'),
    st.String('resource'),
    st.Ipv4('remote_address'),
    st.Int('response_status'),
    st.Timestamp('timestamp'),
    st.LinkObject('user'),
    st.LinkObject('project'),
))


@BP.route('/')
@root_endpoint('audit-log')
def list_all_records():
    parse_collection_request(_SCHEMA)
    result = [record_to_view(record)
              for record in AuditDAO.list_all()]
    return make_collection_response(u'audit-log', result)


@BP.route('/<record_id>')
Exemple #5
0
 def test_nullable_timestamp(self):
     ts = st.Timestamp('nullable', is_nullable=True)
     self.assertEquals(None, ts.from_request(None))
Exemple #6
0
 def test_timestamp_list_from_request(self):
     lts = st.List(st.Timestamp('test'))
     self.assertEquals(lts.from_request(['2012-09-13T19:46:00Z']), [self.d])
Exemple #7
0
 def setUp(self):
     super(TimestampTestCase, self).setUp()
     self.ts = st.Timestamp('test')
     self.d = datetime(2012, 9, 13, 19, 46, 0)
     self.ge = self.ts.get_search_matcher('ge')