Ejemplo n.º 1
0
    def start_instance(self, build):
        yield self.stop_instance(reportFailure=False)

        image, marathon_extra_config = \
            yield self.renderWorkerPropsOnStart(build)

        marathon_config = {
            "container": {
                "docker": {
                    "image": image,
                    "network": "BRIDGE",
                },
                "type": "DOCKER"
            },
            "id": self.getApplicationId(),
            "instances": 1,
            "env": self.createEnvironment()
        }
        util.dictionary_merge(marathon_config, marathon_extra_config)
        res = yield self._http.post("/v2/apps", json=marathon_config)
        res_json = yield res.json()
        if res.code != 201:
            raise LatentWorkerFailedToSubstantiate(
                "Unable to create Marathon app: {} {}: {} {}".format(
                    self.getApplicationId(), res.code, res_json['message'],
                    res_json))
        self.instance = res_json
        defer.returnValue(True)
Ejemplo n.º 2
0
 def start_instance(self, build):
     yield self.stop_instance(reportFailure=False)
     image = yield build.render(self.image)
     marathon_extra_config = yield build.render(self.marathon_extra_config)
     marathon_config = {
         "container": {
             "docker": {
                 "image": image,
                 "network": "BRIDGE",
             },
             "type": "DOCKER"
         },
         "id": self.getApplicationId(),
         "instances": 1,
         "env": self.createEnvironment()
     }
     util.dictionary_merge(marathon_config, marathon_extra_config)
     res = yield self._http.post("/v2/apps", json=marathon_config)
     res_json = yield res.json()
     if res.code != 201:
         raise LatentWorkerFailedToSubstantiate(
             "Unable to create Marathon app: {} {}: {}".format(
                 self.getApplicationId(), res.code, res_json['message']))
     self.instance = res_json
     defer.returnValue(True)
Ejemplo n.º 3
0
 def test_merge(self):
     self.assertEqual(
         util.dictionary_merge({'a': {
             'b': 1
         }}, {'a': {
             'c': 2
         }}), {'a': {
             'b': 1,
             'c': 2
         }})
Ejemplo n.º 4
0
 def test_overwrite2(self):
     self.assertEqual(
         util.dictionary_merge({'a': {
             'b': 1,
             'c': 2
         }}, {'a': {
             'b': [1, 2, 3]
         }}), {'a': {
             'b': [1, 2, 3],
             'c': 2
         }})
Ejemplo n.º 5
0
 def test_overwrite2(self):
     self.assertEqual(
         util.dictionary_merge(
             {
                 'a': {'b': 1, 'c': 2}
             },
             {
                 'a': {'b': [1, 2, 3]}
             }),
         {
             'a': {'b': [1, 2, 3], 'c': 2}
         })
Ejemplo n.º 6
0
 def test_overwrite(self):
     self.assertEqual(
         util.dictionary_merge(
             {
                 'a': {'b': 1}
             },
             {
                 'a': 1
             }),
         {
             'a': 1
         })
Ejemplo n.º 7
0
 def test_merge(self):
     self.assertEqual(
         util.dictionary_merge(
             {
                 'a': {'b': 1}
             },
             {
                 'a': {'c': 2}
             }),
         {
             'a': {'b': 1, 'c': 2}
         })
Ejemplo n.º 8
0
 def test_overwrite(self):
     self.assertEqual(
         util.dictionary_merge(
             {
                 'a': {'b': 1}
             },
             {
                 'a': 1
             }),
         {
             'a': 1
         })