@@ -0,0 +1,2020 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*%0Aimport subprocess%0Aimport yaml%0Aimport pycurl%0Aimport sys%0A%0Adef curlRequest(url):%0A    class ContentCallback:%0A         def __init__(self):%0A            self.contents = ''%0A         def content_callback(self, buf):%0A            self.contents = self.contents + buf%0A%0A    t = ContentCallback()%0A    try:%0A        info = pycurl.Curl()%0A        info.setopt(info.URL, url)%0A        info.setopt(info.WRITEFUNCTION, t.content_callback)%0A        info.perform()%0A        info.close()%0A    except ValueError:%0A        print %22Error: %25s - not found%22 %25url%0A    return yaml.load(t.contents)%0A%0A%0Adef chooseCluster():%0A    clusters = curlRequest('http://127.0.0.1:8000/api/v1/clusters/')%0A    print %22You have get %25d clusters:%22 %25 len(clusters)%0A    print %22ID%5Ct%7C name %5Ct%7C mode %5Ct%7C network type %5Ct%22%0A    for i in clusters:%0A        print i%5B'id'%5D, %22%5Ct%22,  i%5B'name'%5D, %22%5Ct%22, i%5B'mode'%5D, %22%5Ct%22, i%5B'net_provider'%5D%0A%0A    try:%0A        env_id = int(raw_input(%22Enter environment ID: %22))%0A        return env_id%0A    except ValueError:%0A        print %22ID is not number%22%0A        sys.exit(1)%0A%0Adef getClusterInfo(id = 4):%0A%0A    clusters = curlRequest('http://127.0.0.1:8000/api/v1/clusters/')%0A    attributes = curlRequest('http://127.0.0.1:8000/api/v1/clusters/%25d/attributes/' %25 id)%0A    #print yaml.safe_dump(attributes)%0A    try:%0A        cluster_attributes = attributes%5B'editable'%5D%0A    except:%0A        print %22Incorect cluster date%22%0A        sys.exit(1)%0A%0A    return (id, cluster_attributes)%0A%0Adef main():    %0A    id = chooseCluster()%0A    id, cluster = getClusterInfo(id)%0A    try:%0A        passwd = raw_input(%22Enter admin password %22)%0A    except:%0A        print %22Error%22%0A        sys.exit(1)%0A    cluster%5B'access'%5D%5B'password'%5D%5B'value'%5D = passwd%0A    set_cluster_data = 'sudo -u postgres -H -- psql -d nailgun -c %5C%22update attributes set editable = %25s where id = %25d;%5C%22' %25 (str(cluster), id)%0A    cluster_data = subprocess.Popen(set_cluster_data, shell=True, stdout=subprocess.PIPE)%0A#    print yaml.safe_dump(cluster)%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Create hack.py