Exemple #1
0
 def test_secret_create(self):
     data = h1.copy()
     data['api_key'] = '123'
     hosts.create('host_1', data)
     h = hosts.get('host_1')
     self.assertNotEqual('123', h.api_key)
     self.assertTrue(SecretField.verify('123', h.api_key))
Exemple #2
0
    def test_container_create(self):
        h = h1.copy()
        h['containers'] = [{'name': 'c1', 'template': 'foo'}]

        hosts.create('host_1', h)
        h = hosts.get('host_1')
        self.assertEqual(1, h.containers.count())
        self.assertEqual('foo', h.containers.get('c1').template)
        self.assertEqual('c1', h.to_dict()['containers'][0]['name'])
Exemple #3
0
def host_create():
    if "api_key" not in request.json:
        raise ModelError("Missing required field: api_key")
    request.json["enlisted"] = settings.AUTO_ENLIST_HOSTS
    name = request.json["name"]
    del request.json["name"]
    hosts.create(name, request.json)
    resp = jsonify({})
    resp.status_code = 201
    resp.headers["Location"] = "/api/v1/host/%s/" % name
    return resp
Exemple #4
0
def host_create():
    if 'api_key' not in request.json:
        raise ModelError('Missing required field: api_key')
    request.json['enlisted'] = settings.AUTO_ENLIST_HOSTS
    name = request.json['name']
    del request.json['name']
    hosts.create(name, request.json)
    resp = jsonify({})
    resp.status_code = 201
    resp.headers['Location'] = '/api/v1/host/%s/' % name
    return resp
Exemple #5
0
    def setUp(self):
        self.modelsdir = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, self.modelsdir)
        hosts._model_dir = os.path.join(self.modelsdir, 'hosts')
        container_requests._model_dir = os.path.join(self.modelsdir, 'reqs')
        os.mkdir(hosts._model_dir)
        os.mkdir(container_requests._model_dir)

        hosts.create('host1', h1)
        hosts.create('host2', h1)
        self.host1 = hosts.get('host1')
        self.host2 = hosts.get('host2')

        self.container_data = {
            'template': 'ubuntu',
            'release': 'xenial',
        }
Exemple #6
0
    def test_empty_update(self):
        hosts.create('host_1', h1)

        self.assertEqual(1, hosts.count())
        self.assertEqual('ubuntu', hosts.get('host_1').distro_id)