示例#1
0
/**
 * Tests the cgroup_delete_cgroup() api under different scenarios
 * @param retcode error code in case any error is expected from api
 * @param cgrp the group to be deleted
 * @param name the name of the group
 * @param common to test if group was created under one or both mountpoints
 * @param mpnt to test if group under mountpoint or mountpoint2
 * @param ign parameter for api if to ignore the ownership
 * @param the test number
 */
void test_cgroup_delete_cgroup(int retcode, struct cgroup *cgrp,
			 const char *name, int common, int mpnt, int ign, int i)
{
	int retval;
	char path1_group[FILENAME_MAX], path2_group[FILENAME_MAX];
	/* Check, In case some error is expected due to a negative scenario */
	if (retcode) {
		retval = cgroup_delete_cgroup(cgrp, ign);
		if (retval == retcode)
			message(i, PASS, "delete_cgroup()", retval,
							 info[NOMESSAGE]);
		else
			message(i, FAIL, "delete_cgroup()", retval,
							 info[NOMESSAGE]);

		return;
	}

	/* Now there is no error and it is a genuine call */
	retval = cgroup_delete_cgroup(cgrp, ign);
	if (retval) {
		message(i, FAIL, "delete_cgroup()", retval,  info[NOMESSAGE]);
		return;
	}

	/* Let us now check if the group has been deleted from file system */
	if (!common) {
		/* check only under one mountpoint */
		if (mpnt == 1)
			/* check group under mountpoint */
			build_path(path1_group, mountpoint, name, NULL);
		else
			/* check group under mountpoint2 */
			build_path(path1_group, mountpoint2, name, NULL);

		if (group_exist(path1_group) == ENOENT)
			message(i, PASS, "delete_cgroup()", retval,
						 info[GRPDELETEDINFS]);
		else
			message(i, FAIL, "delete_cgroup()", retval,
						 info[GRPNOTDELETEDINFS]);

	} else {
		/* check group under both mountpoints */
		/* Check if the group deleted under both mountpoints */
		build_path(path1_group, mountpoint, name, NULL);
		if (group_exist(path1_group) == ENOENT) {
			build_path(path2_group, mountpoint2, name, NULL);

			if (group_exist(path2_group) == ENOENT)
				message(i, PASS, "delete_cgroup()",
						 retval, info[GRPDELETEDINFS]);
			else
				message(i, FAIL, "delete_cgroup()",
					 retval, info[GRPNOTDELETEDGLOBALY]);
		} else {
			message(i, FAIL, "delete_cgroup()", retval,
						 info[GRPNOTDELETEDINFS]);
		}
	}

}
示例#2
0
int
NS_group_svc::group_create (
  const ACE_TCHAR* group_name,
  const ACE_TCHAR* policy )
{

  if (group_name == 0 || policy == 0 )
  {
    ORBSVCS_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("group_create args not provided\n")),
                      -2);
  }

  /// Validate load balancing strategy policy string
  FT_Naming::LoadBalancingStrategyValue strategy;
  if (false == determine_policy_string (policy, strategy))
  {
    ORBSVCS_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%s is not a valid policy.\n"),
                       policy),
                      -2);
  }

  try
  {
    /// Verify that the group does not already exist
    /// Group names must be unique
    if ( true == group_exist (group_name))
    {
      ORBSVCS_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("Group %s already exists\n"),
                         group_name),
                        -1);
    }

    PortableGroup::Criteria criteria (1);
    criteria.length (1);

    PortableGroup::Property &property = criteria[0];
    property.nam.length (1);

    property.nam[0].id = CORBA::string_dup (
      "org.omg.PortableGroup.MembershipStyle");

    PortableGroup::MembershipStyleValue msv = PortableGroup::MEMB_APP_CTRL;
    property.val <<= msv;

    CORBA::Object_var obj =
      this->naming_manager_->create_object_group (
        ACE_TEXT_ALWAYS_CHAR (group_name),
        strategy,
        criteria);

    if (CORBA::is_nil (obj.in ()))
    {
      ORBSVCS_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("\nUnable to create group %s.\n"),
                         group_name),
                        -1);
    }

  }
  catch (const CORBA::Exception&)
  {
    ORBSVCS_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("\nUnable to create group %s\n"),
                       group_name),
                      -1);
  }

  return 0;
}
示例#3
0
/**
 * Tests the cgroup_create_cgroup() api under different scenarios
 * @param retcode error code in case any error is expected from api
 * @param cgrp the group to be created
 * @param name the name of the group
 * @param common to test if group will be created under one or both mountpoints
 * @param mpnt to test if group under mountpoint or mountpoint2
 * @param ign parameter for api if to ignore the ownership
 * @param the test number
 */
void test_cgroup_create_cgroup(int retcode, struct cgroup *cgrp,
			 const char *name, int common, int mpnt, int ign, int i)
{
	int retval;
	char path1_group[FILENAME_MAX], path2_group[FILENAME_MAX];
	/* Check, In case some error is expected due to a negative scenario */
	if (retcode) {
		retval = cgroup_create_cgroup(cgrp, ign);
		if (retval == retcode)
			message(i, PASS, "create_cgroup()", retval,
							 info[NOMESSAGE]);
		else
			message(i, FAIL, "create_cgroup()", retval,
							 info[NOMESSAGE]);

		return;
	}

	/* Now there is no error and it is a genuine call */
	retval = cgroup_create_cgroup(cgrp, ign);
	if (retval) {
		message(i, FAIL, "create_cgroup()", retval,  info[NOMESSAGE]);
		return;
	}

	/* Let us now check if the group exist in file system */
	if (!common) {
		/* group only under one mountpoint */
		if (mpnt == 1)
			/* group under mountpoint */
			build_path(path1_group, mountpoint, name, NULL);
		else
			/* group under mountpoint2 */
			build_path(path1_group, mountpoint2, name, NULL);

		if (group_exist(path1_group) == 0)
			message(i, PASS, "create_cgroup()", retval,
							 info[GRPINFS]);
		else
			message(i, FAIL, "create_cgroup()", retval,
							 info[GRPNOTINFS]);

	 /* group under both mountpoints */
	} else {
		/* check if the group exists under both controllers */
		build_path(path1_group, mountpoint, name, NULL);
		if (group_exist(path1_group) == 0) {
			build_path(path2_group, mountpoint2, name, NULL);

			if (group_exist(path2_group) == 0)
				message(i, PASS, "create_cgroup()",
						 retval, info[GRPINBOTHCTLS]);
			else
				message(i, FAIL, "create_cgroup()",
						 retval, info[GRPNOTIN2NDCTL]);
		} else {
			message(i, FAIL, "create_cgroup()", retval,
							 info[GRPNOTIN1STCTL]);
		}
	}

	return;
}