{"action":"created","comment":{"url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments/56820744","id":56820744,"diff_hunk":"@@ -114,8 +154,149 @@ def __updateSECache( self ):\n       return rawCache\n     return S_OK( getCacheDictFromRawData( rawCache[ 'Value' ] ) )\n \n+  def __updateCECache( self ):\n+    \"\"\" Method used to update the ComputingElementCache.\n+\n+        It will try 5 times to contact the RSS before giving up\n+    \"\"\"\n+\n+    meta = { 'columns' : [ 'Name', 'StatusType', 'Status' ] }\n+\n+    for ti in range( 5 ):\n+      rawCache = self.rssClient.selectStatusElement( 'Resource', 'Status',\n+                                                     elementType = 'ComputingElement',\n+                                                     meta = meta )\n+      if rawCache['OK']:\n+        break\n+      self.log.warn( \"Can't get CE status\", rawCache['Message'] + \"; trial %d\" % ti )\n+      sleep( math.pow( ti, 2 ) )\n+      self.rssClient = ResourceStatusClient()\n+\n+    if not rawCache[ 'OK' ]:\n+      return rawCache\n+    return S_OK( getCacheDictFromRawData( rawCache[ 'Value' ] ) )\n+\n+\n ################################################################################\n \n+  def __getRSSComputingElementStatus( self, elementName, statusType ):\n+    \"\"\"\n+    Gets from the cache or the RSS the ComputingElements status. The cache is a\n+    copy of the DB table. If it is not on the cache, most likely is not going\n+    to be on the DB.\n+\n+    There is one exception: item just added to the CS, e.g. new ComputingElement.\n+    The period between it is added to the DB and the changes are propagated\n+    to the cache will be inconsistent, but not dangerous. Just wait <cacheLifeTime>\n+    minutes.\n+    \"\"\"\n+\n+    cacheMatch = self.ceCache.match( elementName, statusType )\n+\n+    self.log.debug( '__getRSSComputingElementStatus' )\n+    self.log.debug( cacheMatch )\n+\n+    return cacheMatch\n+\n+  def __getCSComputingElementStatus( self, elementName, statusType, default ):\n+    \"\"\"\n+    Gets from the CS the ComputingElements status\n+    \"\"\"\n+\n+    cs_path = \"/Resources/ComputingElements\"\n+\n+    if not isinstance( elementName, list ):\n+      elementName = [ elementName ]\n+\n+    statuses = self.rssConfig.getConfigStatusType( 'ComputingElement' )\n+\n+    result = {}\n+    for element in elementName:\n+\n+      if statusType is not None:\n+        # Added Active by default\n+        res = gConfig.getValue( \"%s/%s/%s\" % ( cs_path, element, statusType ), 'Active' )\n+        result[element] = {statusType: res}\n+\n+      else:\n+        res = gConfig.getOptionsDict( \"%s/%s\" % ( cs_path, element ) )\n+        if res[ 'OK' ] and res[ 'Value' ]:\n+          elementStatuses = {}\n+          for elementStatusType, value in res[ 'Value' ].items():\n+            if elementStatusType in statuses:\n+              elementStatuses[ elementStatusType ] = value\n+\n+          # If there is no status defined in the CS, we add by default Read and\n+          # Write as Active.\n+          if elementStatuses == {}:\n+            elementStatuses = { 'ReadAccess' : 'Active', 'WriteAccess' : 'Active' }\n+\n+          result[ element ] = elementStatuses\n+\n+    if result:\n+      return S_OK( result )\n+\n+    if default is not None:\n+\n+      # sec check\n+      if statusType is None:\n+        statusType = 'none'\n+\n+      defList = [ [ el, statusType, default ] for el in elementName ]\n+      return S_OK( getDictFromList( defList ) )\n+\n+    _msg = \"ComputingElement '%s', with statusType '%s' is unknown for CS.\"\n+    return S_ERROR( _msg % ( elementName, statusType ) )\n+\n+\n+  def __setRSSComputingElementStatus( self, elementName, statusType, status, reason, tokenOwner ):\n+    \"\"\"\n+    Sets on the RSS the ComputingElements status\n+    \"\"\"\n+\n+    expiration = datetime.datetime.utcnow() + datetime.timedelta( days = 1 )\n+\n+    self.seCache.acquireLock()\n+    try:\n+      res = self.rssClient.modifyStatusElement( 'Resource', 'Status', name = elementName,\n+                                                statusType = statusType, status = status,\n+                                                reason = reason, tokenOwner = tokenOwner,\n+                                                tokenExpiration = expiration )\n+      if res[ 'OK' ]:\n+        self.seCache.refreshCache()\n+\n+      if not res[ 'OK' ]:","path":"ResourceStatusSystem/Client/ResourceStatus.py","position":162,"original_position":162,"commit_id":"cd45512f03f7daa35114ad8e3076cae4dc738a16","original_commit_id":"cd45512f03f7daa35114ad8e3076cae4dc738a16","user":{"login":"chaen","id":3728211,"avatar_url":"https://avatars.githubusercontent.com/u/3728211?v=3","gravatar_id":"","url":"https://api.github.com/users/chaen","html_url":"https://github.com/chaen","followers_url":"https://api.github.com/users/chaen/followers","following_url":"https://api.github.com/users/chaen/following{/other_user}","gists_url":"https://api.github.com/users/chaen/gists{/gist_id}","starred_url":"https://api.github.com/users/chaen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaen/subscriptions","organizations_url":"https://api.github.com/users/chaen/orgs","repos_url":"https://api.github.com/users/chaen/repos","events_url":"https://api.github.com/users/chaen/events{/privacy}","received_events_url":"https://api.github.com/users/chaen/received_events","type":"User","site_admin":false},"body":"use the else close ? ","created_at":"2016-03-21T13:27:54Z","updated_at":"2016-03-21T13:27:54Z","html_url":"https://github.com/DIRACGrid/DIRAC/pull/2863#discussion_r56820744","pull_request_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863","_links":{"self":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments/56820744"},"html":{"href":"https://github.com/DIRACGrid/DIRAC/pull/2863#discussion_r56820744"},"pull_request":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863"}}},"pull_request":{"url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863","id":63562101,"html_url":"https://github.com/DIRACGrid/DIRAC/pull/2863","diff_url":"https://github.com/DIRACGrid/DIRAC/pull/2863.diff","patch_url":"https://github.com/DIRACGrid/DIRAC/pull/2863.patch","issue_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/2863","number":2863,"state":"open","locked":false,"title":"[v6r15] Methods to use the RSS status for CEs, FTS and Catalogs","user":{"login":"vipersec","id":8127545,"avatar_url":"https://avatars.githubusercontent.com/u/8127545?v=3","gravatar_id":"","url":"https://api.github.com/users/vipersec","html_url":"https://github.com/vipersec","followers_url":"https://api.github.com/users/vipersec/followers","following_url":"https://api.github.com/users/vipersec/following{/other_user}","gists_url":"https://api.github.com/users/vipersec/gists{/gist_id}","starred_url":"https://api.github.com/users/vipersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vipersec/subscriptions","organizations_url":"https://api.github.com/users/vipersec/orgs","repos_url":"https://api.github.com/users/vipersec/repos","events_url":"https://api.github.com/users/vipersec/events{/privacy}","received_events_url":"https://api.github.com/users/vipersec/received_events","type":"User","site_admin":false},"body":"I added `getComputingElementStatus()` and `setComputingElementStatus()` for the time being.","created_at":"2016-03-21T13:18:38Z","updated_at":"2016-03-21T13:27:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc2352153b06edf47bf4a49b3bf0270d5b9cccae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863/commits","review_comments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863/comments","review_comment_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/2863/comments","statuses_url":"https://api.github.com/repos/DIRACGrid/DIRAC/statuses/cd45512f03f7daa35114ad8e3076cae4dc738a16","head":{"label":"vipersec:RSS_all_resources","ref":"RSS_all_resources","sha":"cd45512f03f7daa35114ad8e3076cae4dc738a16","user":{"login":"vipersec","id":8127545,"avatar_url":"https://avatars.githubusercontent.com/u/8127545?v=3","gravatar_id":"","url":"https://api.github.com/users/vipersec","html_url":"https://github.com/vipersec","followers_url":"https://api.github.com/users/vipersec/followers","following_url":"https://api.github.com/users/vipersec/following{/other_user}","gists_url":"https://api.github.com/users/vipersec/gists{/gist_id}","starred_url":"https://api.github.com/users/vipersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vipersec/subscriptions","organizations_url":"https://api.github.com/users/vipersec/orgs","repos_url":"https://api.github.com/users/vipersec/repos","events_url":"https://api.github.com/users/vipersec/events{/privacy}","received_events_url":"https://api.github.com/users/vipersec/received_events","type":"User","site_admin":false},"repo":{"id":51287138,"name":"DIRAC","full_name":"vipersec/DIRAC","owner":{"login":"vipersec","id":8127545,"avatar_url":"https://avatars.githubusercontent.com/u/8127545?v=3","gravatar_id":"","url":"https://api.github.com/users/vipersec","html_url":"https://github.com/vipersec","followers_url":"https://api.github.com/users/vipersec/followers","following_url":"https://api.github.com/users/vipersec/following{/other_user}","gists_url":"https://api.github.com/users/vipersec/gists{/gist_id}","starred_url":"https://api.github.com/users/vipersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vipersec/subscriptions","organizations_url":"https://api.github.com/users/vipersec/orgs","repos_url":"https://api.github.com/users/vipersec/repos","events_url":"https://api.github.com/users/vipersec/events{/privacy}","received_events_url":"https://api.github.com/users/vipersec/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vipersec/DIRAC","description":"DIRAC Grid","fork":true,"url":"https://api.github.com/repos/vipersec/DIRAC","forks_url":"https://api.github.com/repos/vipersec/DIRAC/forks","keys_url":"https://api.github.com/repos/vipersec/DIRAC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vipersec/DIRAC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vipersec/DIRAC/teams","hooks_url":"https://api.github.com/repos/vipersec/DIRAC/hooks","issue_events_url":"https://api.github.com/repos/vipersec/DIRAC/issues/events{/number}","events_url":"https://api.github.com/repos/vipersec/DIRAC/events","assignees_url":"https://api.github.com/repos/vipersec/DIRAC/assignees{/user}","branches_url":"https://api.github.com/repos/vipersec/DIRAC/branches{/branch}","tags_url":"https://api.github.com/repos/vipersec/DIRAC/tags","blobs_url":"https://api.github.com/repos/vipersec/DIRAC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vipersec/DIRAC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vipersec/DIRAC/git/refs{/sha}","trees_url":"https://api.github.com/repos/vipersec/DIRAC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vipersec/DIRAC/statuses/{sha}","languages_url":"https://api.github.com/repos/vipersec/DIRAC/languages","stargazers_url":"https://api.github.com/repos/vipersec/DIRAC/stargazers","contributors_url":"https://api.github.com/repos/vipersec/DIRAC/contributors","subscribers_url":"https://api.github.com/repos/vipersec/DIRAC/subscribers","subscription_url":"https://api.github.com/repos/vipersec/DIRAC/subscription","commits_url":"https://api.github.com/repos/vipersec/DIRAC/commits{/sha}","git_commits_url":"https://api.github.com/repos/vipersec/DIRAC/git/commits{/sha}","comments_url":"https://api.github.com/repos/vipersec/DIRAC/comments{/number}","issue_comment_url":"https://api.github.com/repos/vipersec/DIRAC/issues/comments{/number}","contents_url":"https://api.github.com/repos/vipersec/DIRAC/contents/{+path}","compare_url":"https://api.github.com/repos/vipersec/DIRAC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vipersec/DIRAC/merges","archive_url":"https://api.github.com/repos/vipersec/DIRAC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vipersec/DIRAC/downloads","issues_url":"https://api.github.com/repos/vipersec/DIRAC/issues{/number}","pulls_url":"https://api.github.com/repos/vipersec/DIRAC/pulls{/number}","milestones_url":"https://api.github.com/repos/vipersec/DIRAC/milestones{/number}","notifications_url":"https://api.github.com/repos/vipersec/DIRAC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vipersec/DIRAC/labels{/name}","releases_url":"https://api.github.com/repos/vipersec/DIRAC/releases{/id}","deployments_url":"https://api.github.com/repos/vipersec/DIRAC/deployments","created_at":"2016-02-08T08:49:32Z","updated_at":"2016-02-08T08:49:36Z","pushed_at":"2016-03-21T13:12:57Z","git_url":"git://github.com/vipersec/DIRAC.git","ssh_url":"git@github.com:vipersec/DIRAC.git","clone_url":"https://github.com/vipersec/DIRAC.git","svn_url":"https://github.com/vipersec/DIRAC","homepage":"http://diracgrid.org","size":30266,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"integration"}},"base":{"label":"DIRACGrid:rel-v6r15","ref":"rel-v6r15","sha":"44e6cefe088016053eeea7ee4d2fe8c009207adf","user":{"login":"DIRACGrid","id":694842,"avatar_url":"https://avatars.githubusercontent.com/u/694842?v=3","gravatar_id":"","url":"https://api.github.com/users/DIRACGrid","html_url":"https://github.com/DIRACGrid","followers_url":"https://api.github.com/users/DIRACGrid/followers","following_url":"https://api.github.com/users/DIRACGrid/following{/other_user}","gists_url":"https://api.github.com/users/DIRACGrid/gists{/gist_id}","starred_url":"https://api.github.com/users/DIRACGrid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DIRACGrid/subscriptions","organizations_url":"https://api.github.com/users/DIRACGrid/orgs","repos_url":"https://api.github.com/users/DIRACGrid/repos","events_url":"https://api.github.com/users/DIRACGrid/events{/privacy}","received_events_url":"https://api.github.com/users/DIRACGrid/received_events","type":"Organization","site_admin":false},"repo":{"id":1576831,"name":"DIRAC","full_name":"DIRACGrid/DIRAC","owner":{"login":"DIRACGrid","id":694842,"avatar_url":"https://avatars.githubusercontent.com/u/694842?v=3","gravatar_id":"","url":"https://api.github.com/users/DIRACGrid","html_url":"https://github.com/DIRACGrid","followers_url":"https://api.github.com/users/DIRACGrid/followers","following_url":"https://api.github.com/users/DIRACGrid/following{/other_user}","gists_url":"https://api.github.com/users/DIRACGrid/gists{/gist_id}","starred_url":"https://api.github.com/users/DIRACGrid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DIRACGrid/subscriptions","organizations_url":"https://api.github.com/users/DIRACGrid/orgs","repos_url":"https://api.github.com/users/DIRACGrid/repos","events_url":"https://api.github.com/users/DIRACGrid/events{/privacy}","received_events_url":"https://api.github.com/users/DIRACGrid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DIRACGrid/DIRAC","description":"DIRAC Grid","fork":false,"url":"https://api.github.com/repos/DIRACGrid/DIRAC","forks_url":"https://api.github.com/repos/DIRACGrid/DIRAC/forks","keys_url":"https://api.github.com/repos/DIRACGrid/DIRAC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DIRACGrid/DIRAC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DIRACGrid/DIRAC/teams","hooks_url":"https://api.github.com/repos/DIRACGrid/DIRAC/hooks","issue_events_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/events{/number}","events_url":"https://api.github.com/repos/DIRACGrid/DIRAC/events","assignees_url":"https://api.github.com/repos/DIRACGrid/DIRAC/assignees{/user}","branches_url":"https://api.github.com/repos/DIRACGrid/DIRAC/branches{/branch}","tags_url":"https://api.github.com/repos/DIRACGrid/DIRAC/tags","blobs_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/refs{/sha}","trees_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DIRACGrid/DIRAC/statuses/{sha}","languages_url":"https://api.github.com/repos/DIRACGrid/DIRAC/languages","stargazers_url":"https://api.github.com/repos/DIRACGrid/DIRAC/stargazers","contributors_url":"https://api.github.com/repos/DIRACGrid/DIRAC/contributors","subscribers_url":"https://api.github.com/repos/DIRACGrid/DIRAC/subscribers","subscription_url":"https://api.github.com/repos/DIRACGrid/DIRAC/subscription","commits_url":"https://api.github.com/repos/DIRACGrid/DIRAC/commits{/sha}","git_commits_url":"https://api.github.com/repos/DIRACGrid/DIRAC/git/commits{/sha}","comments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/comments{/number}","issue_comment_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/comments{/number}","contents_url":"https://api.github.com/repos/DIRACGrid/DIRAC/contents/{+path}","compare_url":"https://api.github.com/repos/DIRACGrid/DIRAC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DIRACGrid/DIRAC/merges","archive_url":"https://api.github.com/repos/DIRACGrid/DIRAC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DIRACGrid/DIRAC/downloads","issues_url":"https://api.github.com/repos/DIRACGrid/DIRAC/issues{/number}","pulls_url":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls{/number}","milestones_url":"https://api.github.com/repos/DIRACGrid/DIRAC/milestones{/number}","notifications_url":"https://api.github.com/repos/DIRACGrid/DIRAC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DIRACGrid/DIRAC/labels{/name}","releases_url":"https://api.github.com/repos/DIRACGrid/DIRAC/releases{/id}","deployments_url":"https://api.github.com/repos/DIRACGrid/DIRAC/deployments","created_at":"2011-04-06T11:47:53Z","updated_at":"2016-03-09T10:17:10Z","pushed_at":"2016-03-21T13:18:38Z","git_url":"git://github.com/DIRACGrid/DIRAC.git","ssh_url":"git@github.com:DIRACGrid/DIRAC.git","clone_url":"https://github.com/DIRACGrid/DIRAC.git","svn_url":"https://github.com/DIRACGrid/DIRAC","homepage":"http://diracgrid.org","size":31779,"stargazers_count":47,"watchers_count":47,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":110,"forks":90,"open_issues":110,"watchers":47,"default_branch":"integration"}},"_links":{"self":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863"},"html":{"href":"https://github.com/DIRACGrid/DIRAC/pull/2863"},"issue":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/2863"},"comments":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/issues/2863/comments"},"review_comments":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863/comments"},"review_comment":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/pulls/2863/commits"},"statuses":{"href":"https://api.github.com/repos/DIRACGrid/DIRAC/statuses/cd45512f03f7daa35114ad8e3076cae4dc738a16"}}}}