Revision f87ec53f lib/rapi/rlib2.py

b/lib/rapi/rlib2.py
1380 1380
    Example: ["tag1", "tag2", "tag3"]
1381 1381

  
1382 1382
    """
1383
    # pylint: disable-msg=W0212
1384
    return baserlib._Tags_GET(self.TAG_LEVEL, name=self.name)
1383
    kind = self.TAG_LEVEL
1384

  
1385
    if kind in (constants.TAG_INSTANCE,
1386
                constants.TAG_NODEGROUP,
1387
                constants.TAG_NODE):
1388
      if not self.name:
1389
        raise http.HttpBadRequest("Missing name on tag request")
1390

  
1391
      cl = baserlib.GetClient()
1392
      if kind == constants.TAG_INSTANCE:
1393
        fn = cl.QueryInstances
1394
      elif kind == constants.TAG_NODEGROUP:
1395
        fn = cl.QueryGroups
1396
      else:
1397
        fn = cl.QueryNodes
1398
      result = fn(names=[self.name], fields=["tags"], use_locking=False)
1399
      if not result or not result[0]:
1400
        raise http.HttpBadGateway("Invalid response from tag query")
1401
      tags = result[0][0]
1402

  
1403
    elif kind == constants.TAG_CLUSTER:
1404
      assert not self.name
1405
      # TODO: Use query API?
1406
      ssc = ssconf.SimpleStore()
1407
      tags = ssc.GetClusterTags()
1408

  
1409
    return list(tags)
1385 1410

  
1386 1411
  def PUT(self):
1387 1412
    """Add a set of tags.
......
1394 1419
    if "tag" not in self.queryargs:
1395 1420
      raise http.HttpBadRequest("Please specify tag(s) to add using the"
1396 1421
                                " the 'tag' parameter")
1397
    return baserlib._Tags_PUT(self.TAG_LEVEL,
1398
                              self.queryargs["tag"], name=self.name,
1399
                              dry_run=bool(self.dryRun()))
1422
    op = opcodes.OpTagsSet(kind=self.TAG_LEVEL, name=self.name,
1423
                           tags=self.queryargs["tag"], dry_run=self.dryRun())
1424
    return baserlib.SubmitJob([op])
1400 1425

  
1401 1426
  def DELETE(self):
1402 1427
    """Delete a tag.
......
1411 1436
      # no we not gonna delete all tags
1412 1437
      raise http.HttpBadRequest("Cannot delete all tags - please specify"
1413 1438
                                " tag(s) using the 'tag' parameter")
1414
    return baserlib._Tags_DELETE(self.TAG_LEVEL,
1415
                                 self.queryargs["tag"],
1416
                                 name=self.name,
1417
                                 dry_run=bool(self.dryRun()))
1439
    op = opcodes.OpTagsDel(kind=self.TAG_LEVEL, name=self.name,
1440
                           tags=self.queryargs["tag"], dry_run=self.dryRun())
1441
    return baserlib.SubmitJob([op])
1418 1442

  
1419 1443

  
1420 1444
class R_2_instances_name_tags(_R_Tags):

Also available in: Unified diff