Ejemplo n.º 1
0
def backup(host, user, key, output_file=None):
    client = heketi.HeketiClient(host, user, key)
    req = client._make_request('GET', '/backup/db')

    if output_file is None:
        output = sys.stdout
    else:
        try:
            output = open(output_file, "w")
        except IOError as e:
            print "IOError: Could not open file for writing: {0}".format(
                e.strerror)
            sys.exit(1)
        except:
            print "Unexpected error:", sys.exc_info()[0]
            sys.exit(1)

    try:
        output.write(req.content)
    except IOError as e:
        print "IOError: Could not write to output: {0}".format(e.strerror)
        sys.exit(1)
    except:
        print "Unexpected error:", sys.exc_info()[0]
        sys.exit(1)
    finally:
        if output_file is not None:
            output.close()
Ejemplo n.º 2
0
 def test_create_cluster_tls_cert(self):
     import heketi
     c = heketi.HeketiClient('https://localhost:8080',
                             'abc',
                             'xyz',
                             verify="heketi.crt")
     resp = c.cluster_create()
     self.assertTrue(resp)
     self.assertTrue(resp['id'])
     cluster_id = resp['id']
     node = c.node_add({
         "cluster": cluster_id,
         "zone": 1,
         "hostnames": {
             "manage": ["node1.foo.example.com"],
             "storage": ["s1.foo.example.com"],
         },
     })
     self.assertTrue(node)
     self.assertTrue(node["id"])
     resp = c.cluster_list()
     self.assertTrue(resp)
     ci = c.cluster_info(resp['clusters'][0])
     self.assertTrue(ci)
     self.assertIn(node["id"], ci["nodes"])
Ejemplo n.º 3
0
 def heketi_client(self):
     """Return a fully configured heketi client object ready for use
     with the current test server.
     """
     return heketi.HeketiClient('http://localhost:8080', 'foo', 'bar')
Ejemplo n.º 4
0
def heketi_client():
    return heketi.HeketiClient('http://localhost:8080',
                               'x',
                               'x',
                               poll_delay=0.2)