Example #1
0
    def testMultiSomeOffline(self):
        nodes = dict(("node%s-uuid" % i,
                      objects.Node(name="node%s.example.com" % i,
                                   offline=((i % 3) == 0),
                                   primary_ip="192.0.2.%s" % i,
                                   uuid="node%s-uuid" % i))
                     for i in range(1, 255))

        # Resolve no names
        self.assertEqual(
            rpc._NodeConfigResolver(NotImplemented, lambda: nodes, [], None),
            [])

        # Offline, online and unknown hosts
        self.assertEqual(
            rpc._NodeConfigResolver(NotImplemented, lambda: nodes, [
                "node3-uuid",
                "node92-uuid",
                "node54-uuid",
                "unknown.example.com",
            ], None), [
                ("node3.example.com", rpc._OFFLINE, "node3-uuid"),
                ("node92.example.com", "192.0.2.92", "node92-uuid"),
                ("node54.example.com", rpc._OFFLINE, "node54-uuid"),
                ("unknown.example.com", "unknown.example.com",
                 "unknown.example.com"),
            ])
  def testMultiSomeOffline(self):
    nodes = dict(("node%s-uuid" % i,
                  objects.Node(name="node%s.example.com" % i,
                               offline=((i % 3) == 0),
                               primary_ip="192.0.2.%s" % i,
                               uuid="node%s-uuid" % i))
                  for i in range(1, 255))

    # Resolve no names
    self.assertEqual(rpc._NodeConfigResolver(NotImplemented,
                                             lambda: nodes,
                                             [], None),
                     [])

    # Offline, online and unknown hosts
    self.assertEqual(rpc._NodeConfigResolver(NotImplemented,
                                             lambda: nodes,
                                             ["node3-uuid",
                                              "node92-uuid",
                                              "node54-uuid",
                                              "unknown.example.com",],
                                             None), [
      ("node3.example.com", rpc._OFFLINE, "node3-uuid"),
      ("node92.example.com", "192.0.2.92", "node92-uuid"),
      ("node54.example.com", rpc._OFFLINE, "node54-uuid"),
      ("unknown.example.com", "unknown.example.com", "unknown.example.com"),
      ])
Example #3
0
 def testSingleOfflineWithAcceptOffline(self):
     fn = self._GetSingleOfflineNode
     assert fn("node100-uuid").offline
     self.assertEqual(
         rpc._NodeConfigResolver(fn, NotImplemented, ["node100-uuid"],
                                 rpc_defs.ACCEPT_OFFLINE_NODE),
         [("node100.example.com", "192.0.2.100", "node100-uuid")])
     for i in [False, True, "", "Hello", 0, 1]:
         self.assertRaises(AssertionError, rpc._NodeConfigResolver, fn,
                           NotImplemented, ["node100.example.com"], i)
 def testSingleOfflineWithAcceptOffline(self):
   fn = self._GetSingleOfflineNode
   assert fn("node100-uuid").offline
   self.assertEqual(rpc._NodeConfigResolver(fn, NotImplemented,
                                            ["node100-uuid"],
                                            rpc_defs.ACCEPT_OFFLINE_NODE),
                    [("node100.example.com", "192.0.2.100", "node100-uuid")])
   for i in [False, True, "", "Hello", 0, 1]:
     self.assertRaises(AssertionError, rpc._NodeConfigResolver,
                       fn, NotImplemented, ["node100.example.com"], i)
Example #5
0
 def testMultiEmpty(self):
     self.assertEqual(
         rpc._NodeConfigResolver(NotImplemented, lambda: {}, [], None), [])
Example #6
0
 def testUnknownSingleNode(self):
     self.assertEqual(
         rpc._NodeConfigResolver(lambda _: None, NotImplemented,
                                 ["node110.example.com"], None),
         [("node110.example.com", "node110.example.com",
           "node110.example.com")])
Example #7
0
 def testSingleOffline(self):
     self.assertEqual(
         rpc._NodeConfigResolver(self._GetSingleOfflineNode, NotImplemented,
                                 ["node100-uuid"], None),
         [("node100.example.com", rpc._OFFLINE, "node100-uuid")])
Example #8
0
 def testSingleOnline(self):
     self.assertEqual(
         rpc._NodeConfigResolver(self._GetSingleOnlineNode, NotImplemented,
                                 ["node90-uuid"], None),
         [("node90.example.com", "192.0.2.90", "node90-uuid")])
 def testMultiEmpty(self):
   self.assertEqual(rpc._NodeConfigResolver(NotImplemented,
                                            lambda: {},
                                            [], None),
                    [])
Example #10
0
 def testUnknownSingleNode(self):
   self.assertEqual(rpc._NodeConfigResolver(lambda _: None, NotImplemented,
                                            ["node110.example.com"], None),
                    [("node110.example.com", "node110.example.com",
                      "node110.example.com")])
Example #11
0
 def testSingleOffline(self):
   self.assertEqual(rpc._NodeConfigResolver(self._GetSingleOfflineNode,
                                            NotImplemented,
                                            ["node100-uuid"], None),
                    [("node100.example.com", rpc._OFFLINE, "node100-uuid")])
Example #12
0
 def testSingleOnline(self):
   self.assertEqual(rpc._NodeConfigResolver(self._GetSingleOnlineNode,
                                            NotImplemented,
                                            ["node90-uuid"], None),
                    [("node90.example.com", "192.0.2.90", "node90-uuid")])