Skip to content

Commit

Permalink
Merge branch 'RM-compute_engine_analysis' of https://github.com/JackM…
Browse files Browse the repository at this point in the history
…cCrea/Keesaco into beta_merge

Conflicts:
	app/API/APIAnalysis.py
	app/Analysis/ComputeEngine/ComputeEngineConfig.py
	app/Analysis/ComputeEngine/GCEManager.py
	app/Analysis/Manager/AnalysisManager.py
  • Loading branch information
McCrea committed Feb 10, 2014
2 parents a83f056 + 509f152 commit fedf6b9
Show file tree
Hide file tree
Showing 43 changed files with 12,115 additions and 11 deletions.
5 changes: 3 additions & 2 deletions app/API/APIAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
###########################################################################

# from app.Analysis.Manager import AnalysisManager
from Analysis.ComputeEngine.GCEManager import GCEManager
from app.Analysis.ComputeEngine.GCEManager import GCEManager

## !!TEMP!! The manager instance for Compute Engine.
gce_manager = GCEManager()
Expand All @@ -23,7 +23,8 @@
###########################################################################
def add_analysis_task( file_location ):
# !!TEMP!! Uses the file location to start an instance on Compute Engine.
return gce_manager.start_instance_pd("", file_location)

return gce_manager.start_instance_pd("default", file_location)


###########################################################################
Expand Down
8 changes: 4 additions & 4 deletions app/Analysis/ComputeEngine/ComputeEngineConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## \brief Provides constants to modify instantiations on compute engine.
###########################################################################

from Analysis import AdminConfig
from app.Analysis import AdminConfig

## The id of the project as it appears on Google Cloud Developers Console.
PROJECT_ID = 'keesaco-spe'
Expand Down Expand Up @@ -57,11 +57,11 @@
## The URL of the network to use.
NETWORK_URL = '%s/global/networks/%s' % (PROJECT_URL, DEFAULT_NETWORK)
## The file path of the storage container for authentication
STORAGE_URL = 'Analysis/ComputeEngine/Assets/%s' % OAUTH2_STORAGE
STORAGE_URL = 'app/Analysis/ComputeEngine/%s' % OAUTH2_STORAGE
## The file path of the client_secrets.json file
SECRETS_URL = 'Analysis/ComputeEngine/Assets/%s' % CLIENT_SECRETS
SECRETS_URL = 'app/Analysis/ComputeEngine/%s' % CLIENT_SECRETS
## The file path of the startup script
STARTUP_URL = 'Analysis/ComputeEngine/Assets/%s' % STARTUP_SCRIPT
STARTUP_URL = 'app/Analysis/ComputeEngine/%s' % STARTUP_SCRIPT



23 changes: 23 additions & 0 deletions app/Analysis/ComputeEngine/GCEManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
import logging
import sys
import argparse
<<<<<<< HEAD
import httplib2
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client import tools
from oauth2client.tools import run_flow
from apiclient.discovery import build
from Analysis.ComputeEngine.ComputeEngineConfig import *
=======
from app.Dependencies.GAEPythonClientAPI import httplib2
from app.Dependencies.GAEPythonClientAPI.oauth2client.client import flow_from_clientsecrets
from app.Dependencies.GAEPythonClientAPI.oauth2client.file import Storage
from app.Dependencies.GAEPythonClientAPI.oauth2client import tools
from app.Dependencies.GAEPythonClientAPI.oauth2client.tools import run_flow
from app.Dependencies.GAEPythonClientAPI.apiclient.discovery import build
from app.Analysis.ComputeEngine.ComputeEngineConfig import *
>>>>>>> 509f152f86aa8a1b21112f2baaa2a680a3532817

## \brief Manager which tracks all instances within the scope of the project on Compute Engine.
class GCEManager:
Expand Down Expand Up @@ -64,9 +74,12 @@ def __init__(self):
for i in range(0, MAX_INSTANCES):
self.persistent_disks.append(PersistentDisk(i, self.gce_service, self.auth_http))
self.pds_present = True
<<<<<<< HEAD

self.counter = 0
self.instance_names = []
=======
>>>>>>> 509f152f86aa8a1b21112f2baaa2a680a3532817

###########################################################################
## \brief Creates persistent disk up to the max number of instances.
Expand All @@ -93,11 +106,17 @@ def start_pds(self):
## \author swhitehouse@keesaco.com of Keesaco
###########################################################################
def start_instance_pd(self, instance_name, file_location):
<<<<<<< HEAD
self.instance_names = {file_location : 'keesaflo-analysis-' + str(self.counter)}
self.counter += 1
for persistent_disk in self.persistent_disks:
if persistent_disk.instance_name == "":
persistent_disk.start_instance(self.instance_names[file_location], file_location)
=======
for persistent_disk in self.persistent_disks:
if persistent_disk.instance_name == "":
persistent_disk.start_instance(instance_name, file_location)
>>>>>>> 509f152f86aa8a1b21112f2baaa2a680a3532817
return True
return False

Expand All @@ -111,7 +130,11 @@ def start_instance_pd(self, instance_name, file_location):
###########################################################################
def terminate_instance_pd(self, instance_name):
for persistent_disk in self.persistent_disks:
<<<<<<< HEAD
if persistent_disk.instance_name == self.instance_names[instance_name]:
=======
if persistent_disk.instance_name == instance_name:
>>>>>>> 509f152f86aa8a1b21112f2baaa2a680a3532817
persistent_disk.terminate_instance()
return True
return False
Expand Down
1 change: 1 addition & 0 deletions app/Analysis/ComputeEngine/client_secrets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"installed":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret":"XpJTeFjh_9MioCT5j0-qf_8r","token_uri":"https://accounts.google.com/o/oauth2/token","client_email":"","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","oob"],"client_x509_cert_url":"","client_id":"41520595559-dgubv27ebaj0ra08dkd706ke84m9hoh0.apps.googleusercontent.com","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}
11 changes: 11 additions & 0 deletions app/Analysis/ComputeEngine/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
###########################################################################
## \file app/Analysis/Manager/startup.sh
## \brief Runs the FCS analysis on new instances.
## \author swhitehouse@keesaco.com of Keesaco
###########################################################################

#!/bin/bash
## Obtains the file location from the metadata of the instance request.
FILE_LOCATION=$(curl http://metadata/computeMetadata/v1/instance/attributes/file_location -H "X-Google-Metadata-Request: True")
## Runs the analysis on the file location.
python visualise.py $FILE_LOCATION
10 changes: 5 additions & 5 deletions app/Analysis/Manager/AnalysisManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
## \brief Provides an Analysis Manager class which is responsible for managing analysis tasks.
###########################################################################

from Analysis.Manager import PALAnalysisManager
from Analysis.Scheduler import AnalysisScheduler
from Analysis import AdminConfig
from Analysis.Types import RequestList
from Analysis.Manager.GCEManager import GCEManager
from app.Analysis.Manager import PALAnalysisManager
from app.Analysis.Scheduler import AnalysisScheduler
from app.Analysis import AdminConfig
from app.Analysis.Types import RequestList
from app.Analysis.Manager.GCEManager import GCEManager

## The RequestList object which will hold information on analysis requests.
request_list = RequestList()
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions app/Dependencies/GAEPythonClientAPI/apiclient/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "1.2"
Loading

0 comments on commit fedf6b9

Please # to comment.