Beispiel #1
0
int status_node(

  struct pbsnode       *pnode,    /* ptr to node receiving status query */
  struct batch_request *preq,
  int                  *bad,      /* O */
  tlist_head           *pstathd)  /* head of list to append status to  */

  {
  int                rc = 0;

  struct brp_status *pstat;
  svrattrl          *pal;

  if ((preq->rq_perm & ATR_DFLAG_RDACC) == 0)
    {
    return(PBSE_PERM);
    }

  /* allocate status sub-structure and fill in header portion */

  pstat = (struct brp_status *)calloc(1, sizeof(struct brp_status));

  if (pstat == NULL)
    {
    return(PBSE_SYSTEM);
    }

  pstat->brp_objtype = MGR_OBJ_NODE;

  strncpy(pstat->brp_objname, pnode->nd_name, sizeof(pstat->brp_objname)-1);

  CLEAR_LINK(pstat->brp_stlink);
  CLEAR_HEAD(pstat->brp_attr);

  /*add this new brp_status structure to the list hanging off*/
  /*the request's reply substructure                         */

  append_link(pstathd, &pstat->brp_stlink, pstat);

  /*point to the list of node-attributes about which we want status*/
  /*hang that status information from the brp_attr field for this  */
  /*brp_status structure                                           */

  *bad = 0;                                    /*global variable*/

  if (preq->rq_ind.rq_status.rq_attr.ll_struct != NULL)
    pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr);
  else
    pal = NULL;

  rc = status_nodeattrib(
         pal,
         node_attr_def,
         pnode,
         ND_ATR_LAST,
         preq->rq_perm,
         &pstat->brp_attr,
         bad);

  return(rc);
  }  /* END status_node() */
Beispiel #2
0
END_TEST

START_TEST(status_nodeattrib_test)
{
    struct svrattrl attributes;
    struct attribute_def node_attributes;
    struct pbsnode node;
    struct list_link list;
    int result_mask = 0;
    int result = 0;

    memset(&attributes, 0, sizeof(attributes));
    memset(&node_attributes, 0, sizeof(node_attributes));
    initialize_pbsnode(&node, NULL, NULL, 0, FALSE);
    memset(&list, 0, sizeof(list));


    result = status_nodeattrib(&attributes,
                               NULL,
                               &node,
                               0,
                               0,
                               &list,
                               &result_mask);
    fail_unless(result != PBSE_NONE, "NULL input attribute_def pointer fail: %d" ,result);

    result = status_nodeattrib(&attributes,
                               &node_attributes,
                               NULL,
                               0,
                               0,
                               &list,
                               &result_mask);
    fail_unless(result != PBSE_NONE, "NULL input pbsnode pointer fail: %d" ,result);

    result = status_nodeattrib(&attributes,
                               &node_attributes,
                               &node,
                               0,
                               0,
                               NULL,
                               &result_mask);
    fail_unless(result != PBSE_NONE, "NULL input tlist_head pointer fail: %d" ,result);

    result = status_nodeattrib(&attributes,
                               &node_attributes,
                               &node,
                               0,
                               0,
                               &list,
                               NULL);
    fail_unless(result != PBSE_NONE, "NULL input result_mask pointer fail: %d" ,result);

    result = status_nodeattrib(NULL,
                               &node_attributes,
                               &node,
                               0,
                               0,
                               &list,
                               &result_mask);
    /*FIXME: NOTE: this is probably a correct set of input parameters, but still returns -1*/
    /*   fail_unless(result != PBSE_NONE, "NULL input svrattrl pointer fail: %d" ,result); */

    result = status_nodeattrib(&attributes,
                               &node_attributes,
                               &node,
                               0,
                               0,
                               &list,
                               &result_mask);
    /*FIXME: NOTE: this is probably a correct set of input parameters, but still returns -1*/
    fail_unless(result != PBSE_NONE, "status_nodeattrib fail: %d" ,result);
}
Beispiel #3
0
static int
status_node(struct pbsnode *pnode, struct batch_request *preq, pbs_list_head *pstathd)
{
	int		   rc = 0;
	struct brp_status *pstat;
	svrattrl	  *pal;
	unsigned long		   old_nd_state = VNODE_UNAVAILABLE;

	if (pnode->nd_state & INUSE_DELETED)  /*node no longer valid*/
		return  (0);

	if ((preq->rq_perm & ATR_DFLAG_RDACC) == 0)
		return (PBSE_PERM);

	/* sync state attribute with nd_state */

	if (pnode->nd_state != pnode->nd_attr[(int)ND_ATR_state].at_val.at_long) {
		pnode->nd_attr[(int)ND_ATR_state].at_val.at_long = pnode->nd_state;
		pnode->nd_attr[(int)ND_ATR_state].at_flags |= ATR_VFLAG_MODIFY |
			ATR_VFLAG_MODCACHE;
	}

	/*node is provisioning - mask out the DOWN/UNKNOWN flags while prov is on*/
	if (pnode->nd_attr[(int)ND_ATR_state].at_val.at_long &
		(INUSE_PROV | INUSE_WAIT_PROV)) {
		old_nd_state = pnode->nd_attr[(int)ND_ATR_state].at_val.at_long;

		/* don't want to show job-busy, job/resv-excl while provisioning */
		pnode->nd_attr[(int)ND_ATR_state].at_val.at_long &=
			~(INUSE_DOWN | INUSE_UNKNOWN | INUSE_JOB |
			INUSE_JOBEXCL | INUSE_RESVEXCL);
	}

	/*allocate status sub-structure and fill in header portion*/

	pstat = (struct brp_status *)malloc(sizeof(struct brp_status));
	if (pstat == NULL)
		return (PBSE_SYSTEM);

	pstat->brp_objtype = MGR_OBJ_NODE;
	(void)strcpy(pstat->brp_objname, pnode->nd_name);
	CLEAR_LINK(pstat->brp_stlink);
	CLEAR_HEAD(pstat->brp_attr);

	/*add this new brp_status structure to the list hanging off*/
	/*the request's reply substructure                         */

	append_link(pstathd, &pstat->brp_stlink, pstat);

	/*point to the list of node-attributes about which we want status*/
	/*hang that status information from the brp_attr field for this  */
	/*brp_status structure                                           */
	bad = 0;                                        /*global variable*/
	pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr);

	rc = status_nodeattrib(pal, node_attr_def, pnode, ND_ATR_LAST,
		preq->rq_perm, &pstat->brp_attr, &bad);

	/*reverting back the state*/

	if (pnode->nd_attr[(int)ND_ATR_state].at_val.at_long & INUSE_PROV)
		pnode->nd_attr[(int)ND_ATR_state].at_val.at_long = old_nd_state ;


	return (rc);
}