def test_ds(self):
     self.assertNotEqual(vsan_info.get_vsan_datastore(), None,
                         "Failed to find VSAN datastore")
     self.assertTrue(vsan_info.is_on_vsan(self.VMDK_PATH),
                     "is_on_vsan can't find file %s" % self.VMDK_PATH)
     self.assertFalse(
         vsan_info.is_on_vsan(self.NON_VSAN_VMDK),
         "is_on_vsan is mistaken about the file %s" % self.NON_VSAN_VMDK)
 def test_ds(self):
     self.assertNotEqual(vsan_info.get_vsan_datastore(), None,
                         "Failed to find VSAN datastore")
     self.assertTrue(
         vsan_info.is_on_vsan(self.VMDK_PATH),
         "is_on_vsan can't find file %s" % self.VMDK_PATH)
     self.assertFalse(
         vsan_info.is_on_vsan(self.NON_VSAN_VMDK),
         "is_on_vsan is mistaken about the file %s" % self.NON_VSAN_VMDK)
 def test_policy(self):
     # check it's on VSAN
     self.assertTrue(
         vsan_info.is_on_vsan(self.VMDK_PATH),
         "is_on_vsan can't find file %s" % self.VMDK_PATH)
     # set policy
     policy_string = \
         '(("hostFailuresToTolerate" i0) ("forceProvisioning" i1))'
     # same policy content with different space/tabs:
     same_policy = \
         ' ((  "hostFailuresToTolerate"    \ti0) ("forceProvisioning" i1))'
     # different content:
     notsame_policy = \
         '(("hostFailuresToTolerate" i0) ("forceProvisioning" i0))'
     err = vsan_info.set_policy(self.VMDK_PATH, policy_string)
     self.assertEqual(err, None, "failed to set")
     # get policy and check it
     p = vsan_info.get_policy(self.VMDK_PATH)
     self.assertTrue(
         vsan_info.same_policy(self.VMDK_PATH, p),
         "failed to compare with get_policy")
     self.assertTrue(
         vsan_info.same_policy(self.VMDK_PATH, policy_string),
         "failed to compare with original policy")
     self.assertTrue(
         vsan_info.same_policy(self.VMDK_PATH, same_policy),
         "failed to compare with same policy, different tabs")
     self.assertFalse(
         vsan_info.same_policy(self.VMDK_PATH, notsame_policy),
         "failed to compare with different policy")
 def test_policy(self):
     # check it's on VSAN
     self.assertTrue(vsan_info.is_on_vsan(self.VMDK_PATH),
                     "is_on_vsan can't find file %s" % self.VMDK_PATH)
     # set policy
     policy_string = \
         '(("hostFailuresToTolerate" i0) ("forceProvisioning" i1))'
     # same policy content with different space/tabs:
     same_policy = \
         ' ((  "hostFailuresToTolerate"    \ti0) ("forceProvisioning" i1))'
     # different content:
     notsame_policy = \
         '(("hostFailuresToTolerate" i0) ("forceProvisioning" i0))'
     self.assertTrue(vsan_info.set_policy(self.VMDK_PATH, policy_string),
                     "failed to set")
     # get policy and check it
     p = vsan_info.get_policy(self.VMDK_PATH)
     self.assertTrue(vsan_info.same_policy(self.VMDK_PATH, p),
                     "failed to compare with get_policy")
     self.assertTrue(vsan_info.same_policy(self.VMDK_PATH, policy_string),
                     "failed to compare with original policy")
     self.assertTrue(vsan_info.same_policy(self.VMDK_PATH, same_policy),
                     "failed to compare with same policy, different tabs")
     self.assertFalse(vsan_info.same_policy(self.VMDK_PATH, notsame_policy),
                      "failed to compare with different policy")
Exemplo n.º 5
0
def validate_vsan_policy_name(policy_name, vmdk_path):
    """
    Ensure that the policy file exists
    """
    if not vsan_info.is_on_vsan(vmdk_path):
        raise ValidationError('Cannot use a VSAN policy on a non-VSAN datastore')

    if not vsan_policy.policy_exists(policy_name):
        raise ValidationError('Policy {0} does not exist'.format(policy_name))
Exemplo n.º 6
0
def validate_vsan_policy_name(policy_name, vmdk_path):
    """
    Ensure that the policy file exists
    """
    if not vsan_info.is_on_vsan(vmdk_path):
        raise ValidationError('Cannot use a VSAN policy on a non-VSAN datastore')

    if not vsan_policy.policy_exists(policy_name):
        raise ValidationError('Policy {0} does not exist'.format(policy_name))
def get_policy(metadata, path):
    """ Return the policy for a volume given its volume options """
    try:
        return metadata[kv.VOL_OPTS][kv.VSAN_POLICY_NAME]
    except:
        pass

    if vsan_info.is_on_vsan(path):
        return kv.DEFAULT_VSAN_POLICY
    else:
        return NOT_AVAILABLE
Exemplo n.º 8
0
def get_policy(metadata, path):
    """ Return the policy for a volume given its volume options """
    try:
        return metadata[kv.VOL_OPTS][kv.VSAN_POLICY_NAME]
    except:
        pass

    if vsan_info.is_on_vsan(path):
        return kv.DEFAULT_VSAN_POLICY
    else:
        return NOT_AVAILABLE