示例#1
0
    def test_991_dump(self):
        _id = "etcd-test-%s" % self.test_991_dump.__name__
        new = generator.GenerateGroup(api_uri=self.api_uri,
                                      _id=_id,
                                      name="etcd-test",
                                      profile="etcd-test.yaml",
                                      matchbox_path=self.test_matchbox_path)
        self.assertTrue(new.dump())
        self.assertTrue(
            os.path.isfile("%s/groups/%s.json" %
                           (self.test_matchbox_path, _id)))

        self.assertFalse(new.dump())
        self.assertTrue(
            os.path.isfile("%s/groups/%s.json" %
                           (self.test_matchbox_path, _id)))

        new = generator.GenerateGroup(api_uri=self.api_uri,
                                      _id=_id,
                                      name="etcd-test",
                                      profile="etcd-test.yaml",
                                      matchbox_path=self.test_matchbox_path,
                                      selector={"one": "selector"})
        self.assertTrue(new.dump())
        self.assertTrue(
            os.path.isfile("%s/groups/%s.json" %
                           (self.test_matchbox_path, _id)))
        os.remove("%s/groups/%s.json" % (self.test_matchbox_path, _id))
示例#2
0
 def test_990_generate(self):
     expect = {
         'profile': 'etcd-proxy.yaml',
         'metadata': {
             'api_uri': "%s" % self.gen.api_uri,
             'selector': {
                 'mac': '08:00:27:37:28:2e'
             },
             'ssh_authorized_keys': []
         },
         'id': 'etcd-proxy',
         'name': 'etcd-proxy',
         'selector': {
             'mac': '08:00:27:37:28:2e'
         }
     }
     new = generator.GenerateGroup(api_uri=self.api_uri,
                                   _id="etcd-proxy",
                                   name="etcd-proxy",
                                   profile="etcd-proxy.yaml",
                                   selector={"mac": "08:00:27:37:28:2e"},
                                   matchbox_path=self.test_matchbox_path)
     result = new.generate()
     result["metadata"]["ssh_authorized_keys"] = []
     self.assertEqual(expect, result)
示例#3
0
 def setUpClass(cls):
     cls.gen = generator.GenerateGroup(api_uri=cls.api_uri,
                                       _id="etcd-proxy",
                                       name="etcd-proxy",
                                       profile="TestGenerateProfiles",
                                       matchbox_path=cls.test_matchbox_path)
     cls.gen.profiles_path = "%s/test_resources" % cls.tests_path
示例#4
0
 def setUpClass(cls):
     os.environ["MATCHBOX_URI"] = "http://127.0.0.1:8080"
     os.environ["API_URI"] = "http://127.0.0.1:5000"
     cls.gen = generator.GenerateGroup(
         api_uri=cls.api_uri,
         _id="etcd-proxy",
         name="etcd-proxy",
         profile="TestGenerateProfiles",
         selector={"mac": "08:00:27:37:28:2e"},
         matchbox_path=cls.test_matchbox_path)
示例#5
0
 def test_991_dump(self):
     _id = "etcd-test-%s" % self.test_991_dump.__name__
     new = generator.GenerateGroup(api_uri=self.api_uri,
                                   _id="%s" % _id,
                                   name="etcd-test",
                                   profile="etcd-test.yaml",
                                   matchbox_path=self.test_matchbox_path,
                                   selector={"mac": "08:00:27:37:28:2e"})
     new.dump()
     self.assertTrue(
         os.path.isfile("%s/groups/%s.json" %
                        (self.test_matchbox_path, _id)))
     os.remove("%s/groups/%s.json" % (self.test_matchbox_path, _id))
示例#6
0
 def setUpClass(cls):
     os.environ["MATCHBOX_URI"] = "http://127.0.0.1:8080"
     os.environ["API_URI"] = "http://127.0.0.1:5000"
     cls.gen = generator.GenerateGroup(
         api_uri=cls.api_uri,
         _id="etcd-proxy",
         name="etcd-proxy",
         profile="TestGenerateProfiles",
         selector={"mac": "08:00:27:37:28:2E"},
         metadata={
             "etcd_initial_cluster": "static0=http://192.168.1.1:2379",
             "api_seed": "http://192.168.1.2:5000"
         },
         matchbox_path=cls.test_matchbox_path)
示例#7
0
 def test_990_generate(self):
     expect = {
         'profile': 'etcd-proxy.yaml',
         'metadata': {
             'api_uri': '%s' % self.gen.api_uri,
             'ssh_authorized_keys': []
         },
         'id': 'etcd-proxy',
         'name': 'etcd-proxy'
     }
     new = generator.GenerateGroup(api_uri=self.api_uri,
                                   _id="etcd-proxy",
                                   name="etcd-proxy",
                                   profile="etcd-proxy.yaml",
                                   matchbox_path=self.test_matchbox_path)
     result = new.generate()
     self.assertEqual(expect["profile"], result["profile"])
     self.assertEqual(expect["id"], result["id"])
     self.assertEqual(expect["name"], result["name"])
     self.assertEqual(expect["metadata"]["api_uri"],
                      result["metadata"]["api_uri"])