Пример #1
0
def testCreateUncheckedFile(t, env):
    """OPEN normal file with create and unchecked flags

    FLAGS: open all
    DEPEND: INIT
    CODE: OPEN2
    """
    c = env.c1
    c.init_connection()

    # Create the file
    orig_attrs = { FATTR4_MODE: 0644, FATTR4_SIZE: 32 }
    res = c.create_file(t.code, attrs=orig_attrs,  deny=OPEN4_SHARE_DENY_NONE)
    check(res, msg="Trying to create file %s" % t.code)
    fh, stateid = c.confirm(t.code, res)
    rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
    checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(),
              "Checking attrs on creation")
    # Create the file again...it should ignore attrs
    attrs = { FATTR4_MODE: 0600, FATTR4_SIZE: 16 }
    res = c.create_file(t.code, attrs=attrs,  deny=OPEN4_SHARE_DENY_NONE)
    check(res, msg="Trying to recreate file %s" % t.code)
    fh, stateid = c.confirm(t.code, res)
    rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
    checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(),
              "Attrs on recreate should be ignored")
    # Create the file again, should truncate size to 0 and ignore other attrs
    attrs = { FATTR4_MODE: 0600, FATTR4_SIZE: 0 }
    res = c.create_file(t.code, attrs=attrs,  deny=OPEN4_SHARE_DENY_NONE)
    check(res, msg="Trying to truncate file %s" % t.code)
    fh, stateid = c.confirm(t.code, res)
    rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
    expect = { FATTR4_MODE: 0644, FATTR4_SIZE: 0 }
    checkdict(expect, rcvd_attrs, get_bitnumattr_dict(),
              "Attrs on recreate should be ignored, except for size")
Пример #2
0
def testCreateUncheckedFile(t, env):
    """OPEN normal file with create and unchecked flags

    FLAGS: open all
    DEPEND: INIT
    CODE: OPEN2
    """
    c = env.c1
    c.init_connection()

    # Create the file
    orig_attrs = {FATTR4_MODE: 0644, FATTR4_SIZE: 32}
    res = c.create_file(t.code, attrs=orig_attrs, deny=OPEN4_SHARE_DENY_NONE)
    check(res, msg="Trying to create file %s" % t.code)
    fh, stateid = c.confirm(t.code, res)
    rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
    checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(),
              "Checking attrs on creation")
    # Create the file again...it should ignore attrs
    attrs = {FATTR4_MODE: 0600, FATTR4_SIZE: 16}
    res = c.create_file(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE)
    check(res, msg="Trying to recreate file %s" % t.code)
    fh, stateid = c.confirm(t.code, res)
    rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
    checkdict(orig_attrs, rcvd_attrs, get_bitnumattr_dict(),
              "Attrs on recreate should be ignored")
    # Create the file again, should truncate size to 0 and ignore other attrs
    attrs = {FATTR4_MODE: 0600, FATTR4_SIZE: 0}
    res = c.create_file(t.code, attrs=attrs, deny=OPEN4_SHARE_DENY_NONE)
    check(res, msg="Trying to truncate file %s" % t.code)
    fh, stateid = c.confirm(t.code, res)
    rcvd_attrs = c.do_getattrdict(fh, orig_attrs.keys())
    expect = {FATTR4_MODE: 0644, FATTR4_SIZE: 0}
    checkdict(expect, rcvd_attrs, get_bitnumattr_dict(),
              "Attrs on recreate should be ignored, except for size")
Пример #3
0
 def importops(self):
     d = self.locals
     for attr in dir(self.client):
         if attr.endswith("_op"):
             key = attr[:-3].upper()
             d[key] = getattr(self.client, attr)
     d["COMPOUND"] = self.client.compound
     d["NULL"] = self.client.null
     d['fattr4_from_dict'] = nfs4lib.dict2fattr
     d['fattr4_to_dict'] = nfs4lib.fattr2dict
     d['fattr4_names'] = nfs4lib.get_bitnumattr_dict()
     d['bitmap4_from_list'] = nfs4lib.list2bitmap
     d['bitmap4_to_list'] = nfs4lib.bitmap2list
Пример #4
0
 def importops(self):
     d = self.locals
     for attr in dir(self.client):
         if attr.endswith("_op"):
             key = attr[:-3].upper()
             d[key] = getattr(self.client, attr)
     d["COMPOUND"] = self.client.compound
     d["NULL"] = self.client.null
     d['fattr4_from_dict'] = nfs4lib.dict2fattr
     d['fattr4_to_dict'] = nfs4lib.fattr2dict
     d['fattr4_names'] = nfs4lib.get_bitnumattr_dict()
     d['bitmap4_from_list'] = nfs4lib.list2bitmap
     d['bitmap4_to_list'] = nfs4lib.bitmap2list
Пример #5
0
def _try_mandatory(t, env, path):
    c = env.c1
    mandatory = [attr.bitnum for attr in env.attr_info if attr.mandatory]
    ops = c.use_obj(path)
    ops += [c.getattr(mandatory)]
    res = c.compound(ops)
    check(res)
    attrs = fattr2dict(res.resarray[-1].arm.arm.obj_attributes)
    unsupp = []
    for attr in mandatory:
        if attr not in attrs:
            attrname = get_bitnumattr_dict()[attr]
            unsupp += [attrname]
    if unsupp:
        t.fail("Mandatory attribute(s) %s not supported" % 'and'.join(unsupp))
Пример #6
0
def _try_mandatory(t, env, path):
    c = env.c1
    mandatory = [attr.bitnum for attr in env.attr_info if attr.mandatory]
    ops = c.use_obj(path)
    ops += [c.getattr(mandatory)]
    res = c.compound(ops)
    check(res)
    attrs = fattr2dict(res.resarray[-1].arm.arm.obj_attributes)
    unsupp = []
    for attr in mandatory:
        if attr not in attrs:
            attrname = get_bitnumattr_dict()[attr]
            unsupp += [attrname]
    if unsupp:
        t.fail("Mandatory attribute(s) %s not supported" % 'and'.join(unsupp))