コード例 #1
0
ファイル: mesh_api.py プロジェクト: biocyberman/TS
    def _fetch_versions(servers):
        _, local_meta_version = findVersions()
        job_arguments = []
        for mesh_node in servers:
            params = {
                "api_key": mesh_node.apikey_remote,
                "system_id": settings.SYSTEM_UUID
            }
            job_arguments.append({
                "address": mesh_node.hostname,
                "params": params
            })
        job_pool = multiprocessing.Pool(processes=len(job_arguments))
        job_output = job_pool.map(fetch_remote_version_process, job_arguments)
        objects_per_host = {}
        for address, object, exceptions in job_output:
            objects_per_host[address] = {
                "object": {},
                "warnings": []
            }
            if exceptions:
                if hasattr(exceptions[0], "response"):
                    response = exceptions[0].response
                    if response.status_code == 401:
                        objects_per_host[address]["warnings"].append("Invalid Permissions")
                else:
                    # Instead of showing this warning, just let the other (incompatible) warning show up on its own.
                    pass

            else:
                objects_per_host[address]["object"] = object.get("meta_version", "")

            if local_meta_version != object.get("meta_version", ""):
                objects_per_host[address]["warnings"].append("Incompatible Software Version")
        return objects_per_host
コード例 #2
0
    def _fetch_versions(servers):
        _, local_meta_version = findVersions()
        job_arguments = []
        for mesh_node in servers:
            params = {
                "api_key": mesh_node.apikey_remote,
                "system_id": settings.SYSTEM_UUID
            }
            job_arguments.append({
                "address": mesh_node.hostname,
                "params": params
            })
        job_pool = multiprocessing.Pool(processes=len(job_arguments))
        job_output = job_pool.map(fetch_remote_version_process, job_arguments)
        objects_per_host = {}
        for address, object, exceptions in job_output:
            objects_per_host[address] = {"object": {}, "warnings": []}
            if exceptions:
                if hasattr(exceptions[0], "response"):
                    response = exceptions[0].response
                    if response.status_code == 401:
                        objects_per_host[address]["warnings"].append(
                            "Invalid Permissions")
                else:
                    # Instead of showing this warning, just let the other (incompatible) warning show up on its own.
                    pass

            else:
                objects_per_host[address]["object"] = object.get(
                    "meta_version", "")

            if local_meta_version != object.get("meta_version", ""):
                objects_per_host[address]["warnings"].append(
                    "Incompatible Software Version")
        return objects_per_host
コード例 #3
0
def update(request):
    """provide a simple interface to allow Torrent Suite to be updated"""

    if request.method == "POST":
        updateLocked = run_update()
        data = json.dumps({"lockBlocked": updateLocked})
        return http.HttpResponse(data, content_type="application/json")
    elif request.method == "GET":
        about, meta_version = findVersions()
        config = GlobalConfig.get()
        from iondb.rundb.api import GlobalConfigResource
        resource = GlobalConfigResource()
        bundle = Bundle(config)
        serialized_config = resource.serialize(None,
                                               resource.full_dehydrate(bundle),
                                               "application/json")
        return render_to_response(
            "admin/update.html",
            {
                "about": about,
                "meta": meta_version,
                "global_config": serialized_config
            },
            RequestContext(request, {}),
        )
コード例 #4
0
ファイル: api.py プロジェクト: golharam/TS
    def get_update(self, request, **kwargs):

        updateStatus = {}
        versions, meta_version = findVersions()
        updateStatus["versions"] = versions
        updateStatus["meta_version"] = meta_version

        updateStatus["locked"] = iondb.rundb.admin.update_locked()
        updateStatus["logs"] = iondb.rundb.admin.install_log_text()

        return self.create_response(request, updateStatus)
コード例 #5
0
    def _fetch_versions(servers):
        _, local_meta_version = findVersions()
        job_arguments = []
        for mesh_node in servers:
            params = {
                "api_key": mesh_node.apikey_remote,
                "system_id": settings.SYSTEM_UUID,
            }
            job_arguments.append({
                "address": mesh_node.hostname,
                "params": params
            })
        with ManagedPool(processes=len(job_arguments)) as job_pool:
            job_output = job_pool.map(fetch_remote_version_process,
                                      job_arguments)
        objects_per_host = {}
        for address, object, exceptions in job_output:
            objects_per_host[address] = {"object": {}, "warnings": []}
            if exceptions:
                if type(exceptions[0]) == requests.exceptions.ConnectionError:
                    objects_per_host[address]["warnings"].append(
                        IonMeshNodeStatus.connection_error)
                elif type(exceptions[0]) == requests.exceptions.Timeout:
                    objects_per_host[address]["warnings"].append(
                        IonMeshNodeStatus.timeout)
                elif hasattr(exceptions[0], "response"):
                    response = exceptions[0].response
                    if response.status_code == 401:
                        objects_per_host[address]["warnings"].append(
                            IonMeshNodeStatus.unauthorized)
                else:
                    objects_per_host[address]["warnings"].append(
                        IonMeshNodeStatus.error)

            else:
                objects_per_host[address]["object"] = object.get(
                    "meta_version", "")
                if local_meta_version != object.get("meta_version", ""):
                    objects_per_host[address]["warnings"].append(
                        IonMeshNodeStatus.incompatible)

        return objects_per_host
コード例 #6
0
ファイル: admin.py プロジェクト: GerritvanNiekerk/TS
def update(request):
    """provide a simple interface to allow Torrent Suite to be updated"""

    if request.method == "POST":
        updateLocked = run_update()
        data = json.dumps({"lockBlocked": updateLocked})
        return http.HttpResponse(data, content_type="application/json")
    elif request.method == "GET":
        about, meta_version = findVersions()
        config = GlobalConfig.get()
        from iondb.rundb.api import GlobalConfigResource

        resource = GlobalConfigResource()
        bundle = Bundle(config)
        serialized_config = resource.serialize(None, resource.full_dehydrate(bundle), "application/json")
        return render_to_response(
            "admin/update.html",
            {"about": about, "meta": meta_version, "global_config": serialized_config},
            RequestContext(request, {}),
        )
コード例 #7
0
ファイル: cluster_info.py プロジェクト: Brainiarc7/TS
def run_nodetests():
    # Loops over Crunchers and runs node tests on each
    # updates cruncher state and test results in database 
    
    nodes = Cruncher.objects.all().order_by('pk')
    if not nodes:
        return False
    
    head_versions, meta = findVersions()
    # launch parallel celery tasks to test all nodes
    tasks = group(test_node_and_update_db.s(node, head_versions) for node in nodes)()
    node_states = tasks.get()
    
    if 'error' in  node_states:
        cluster_status = 'error'
    elif 'warning' in node_states:
        cluster_status = 'warning'
    else:
        cluster_status = 'good'
        
    return cluster_status
コード例 #8
0
def run_nodetests():
    # Loops over Crunchers and runs node tests on each
    # updates cruncher state and test results in database

    nodes = Cruncher.objects.all().order_by('pk')
    if not nodes:
        return False

    head_versions, meta = findVersions()
    # launch parallel celery tasks to test all nodes
    tasks = group(
        test_node_and_update_db.s(node, head_versions) for node in nodes)()
    node_states = tasks.get()

    if 'error' in node_states:
        cluster_status = 'error'
    elif 'warning' in node_states:
        cluster_status = 'warning'
    else:
        cluster_status = 'good'

    return cluster_status
コード例 #9
0
ファイル: test_pipeline.py プロジェクト: golharam/TS
 def test_get_versions(self):
     from ion.utils.TSversion import findVersions
     self.failIf(findVersions() is None)
コード例 #10
0
 def test_get_versions(self):
     from ion.utils.TSversion import findVersions
     self.failIf(findVersions() is None)
コード例 #11
0
from ion import version
import sys
import os

#provide a way to remove ion from the front of a package string name
from optparse import OptionParser

parser = OptionParser()

parser.add_option("-i", "--ion", dest="ion",
                  action="store_true", default=False,
                  help="Remove ion- from the start of a string", metavar="ion")

(options, args) = parser.parse_args()

sys.path.append('/opt/ion/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'iondb.settings'

from ion.utils.TSversion import findVersions

ret, meta = findVersions()

print "Torrent_Suite=" + version
print "host=" + socket.gethostname()

for package, version in ret.iteritems():
    if not options.ion:
        package = package.replace("ion-","")
    print "%s=%s" % (package,version)