Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #48 from vmendez/multi-endpoint
Browse files Browse the repository at this point in the history
Multi endpoint
  • Loading branch information
Adrià Casajús committed Jul 2, 2013
2 parents 995725c + 2e9c077 commit c2c8e9b
Show file tree
Hide file tree
Showing 17 changed files with 551 additions and 348 deletions.
11 changes: 5 additions & 6 deletions Resources/Cloud/CloudDirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def configureFromSection( self, mySection ):
"""
VMDirector.configureFromSection( self, mySection )

def _submitInstance( self, imageName, workDir, endpoint, instanceID ):
def _submitInstance( self, imageName, endpoint, CPUTime, instanceID ):
"""
Real backend method to submit a new Instance of a given Image
It has the decision logic of sumbission to the multi-endpoint, from the available from a given imageName, first approach: FirstFit
Expand Down Expand Up @@ -66,11 +66,11 @@ def _submitInstance( self, imageName, workDir, endpoint, instanceID ):


if ( driver == 'occi-0.9' or driver == 'occi-0.8'):
instanceType = gConfig.getValue( "%s/%s/%s" % ( endpointsPath, endpoint, 'instanceType' ), "" )
imageDriver = gConfig.getValue( "%s/%s/%s" % ( endpointsPath, endpoint, 'imageDriver' ), "" )

oima = OcciImage( imageName, endpoint )
result = oima.startNewInstance( instanceType, imageDriver )
connOcci = oima.connectOcci()
if not connOcci[ 'OK' ]:
return connOcci
result = oima.startNewInstance( CPUTime )
if not result[ 'OK' ]:
return result
idInstance = result['Value']
Expand All @@ -82,7 +82,6 @@ def _submitInstance( self, imageName, workDir, endpoint, instanceID ):
if not connNova[ 'OK' ]:
return connNova
result = nima.startNewInstance( instanceID )

if not result[ 'OK' ]:
return result
return S_OK( result['Value'] )
Expand Down
9 changes: 7 additions & 2 deletions Resources/Cloud/VMDirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def configureFromSection( self, mySection ):
self.runningPods[runningPodName]['Priority'] = int( runningPodDict['Priority'] )
self.runningPods[runningPodName]['CloudEndpoints'] = runningPodDict['CloudEndpoints']

def submitInstance( self, imageName, workDir, endpoint, numVMsToSubmit, runningPodName ):
def submitInstance( self, imageName, endpoint, numVMsToSubmit, runningPodName ):
"""
"""
# warning: instanceID is the DIRAC instance id, while uniqueID is unique for a particular endpoint
Expand All @@ -111,7 +111,12 @@ def submitInstance( self, imageName, workDir, endpoint, numVMsToSubmit, runningP
return newInstance
instanceID = newInstance[ 'Value' ]

dictVMSubmitted = self._submitInstance( imageName, workDir, endpoint, instanceID )
runningRequirementsDict = self.runningPods[runningPodName]['RequirementsDict']
cpuTime = runningRequirementsDict['CPUTime']
if not cpuTime:
return S_ERROR( 'Unknown CPUTime in Requirements of the RunningPod %s' % runningPodName )

dictVMSubmitted = self._submitInstance( imageName, endpoint, cpuTime, instanceID )
if not dictVMSubmitted[ 'OK' ]:
return dictVMSubmitted

Expand Down
10 changes: 10 additions & 0 deletions Security/VmProperties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# $HeadURL$
__RCSID__ = "$Id$"
#
#
VM_WEB_OPERATION = "VmWebOperation"
#
VM_RPC_OPERATION = "VmRpcOperation"

#...............................................................................
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
17 changes: 17 additions & 0 deletions Security/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# $HeadURL$
__RCSID__ = "$Id$"

import GSI

requiredGSIVersion = "0.3.9"
if GSI.version.__version__ < requiredGSIVersion:
raise Exception( "pyGSI is not the latest version (installed %s required %s)" % ( GSI.version.__version__, requiredGSIVersion ) )

GSI.SSL.set_thread_safe()

nid = GSI.crypto.create_oid( "1.2.42.42", "diracGroup", "DIRAC group" )
GSI.crypto.add_x509_extension_alias( nid, 78 ) #Alias to netscape comment, text based extension
nid = GSI.crypto.create_oid( "1.3.6.1.4.1.8005.100.100.5", "vomsExtensions", "VOMS extension" )
GSI.crypto.add_x509_extension_alias( nid, 78 ) #Alias to netscape comment, text based extension

import VMDIRAC.Security.VmProperties
13 changes: 13 additions & 0 deletions Web/controllers/systems/virtualmachines.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ def getRunningInstancesBEPHistory( self ):
data.append( rL )
return S_OK( data )

@jsonify
def checkVmWebOperation( self ):
try:
operation = str( request.params[ 'operation' ] )
except Exception, e:
print e
return S_ERROR( "Oops! Couldn't understand the request" )
rpcClient = getRPCClient( "WorkloadManagement/VirtualMachineManager" )
result = rpcClient.checkVmWebOperation( operation )
if not result[ 'OK' ]:
return S_ERROR( result[ 'Message' ] )
data = result[ 'Value' ]
return S_OK( data )

@jsonify
def declareInstancesStopping( self ):
Expand Down
102 changes: 71 additions & 31 deletions Web/public/javascripts/systems/virtualmachines/vmBrowser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var gMainGrid = false;
var gVMMenu = false;
var auth_response = false;

function initVMBrowser(){
auth_response = '';
checkVmWebOperation();
Ext.onReady(function(){
renderPage();
});
Expand Down Expand Up @@ -40,6 +43,19 @@ function generateBrowseGrid( config )
vmCond : config.vmFilter
});

if( auth_response == "Auth" )
aux_tbar= [
{ handler:function(){ toggleAll(true) }, text:'Select all', width:150, tooltip:'Click to select all rows' },
{ handler:function(){ toggleAll(false) }, text:'Select none', width:150, tooltip:'Click to select all rows' },
'->',
{ handler:function(){ cbStopSelected() }, text:'Stop', width:150, tooltip:'Click to stop all selected VMs' },
];
else
aux_tbar= [
{ handler:function(){ toggleAll(true) }, text:'Select all', width:150, tooltip:'Click to select all rows' },
{ handler:function(){ toggleAll(false) }, text:'Select none', width:150, tooltip:'Click to select all rows' },
];

gMainGrid = new Ext.grid.GridPanel( {
store : store,
/*view: new Ext.grid.GroupingView({
Expand All @@ -49,36 +65,31 @@ function generateBrowseGrid( config )
}),*/
columns: [
{ id : 'check', header : '', width : 30, dataIndex: 'inst_InstanceID', renderer : renderSelect },
{ header: "Image", width: 150, sortable: true, dataIndex: 'img_Name'},
{ header: "EndPoint", width: 100, sortable: true, dataIndex: 'img_CloudEndpoints'},
{ header: "Status", width: 100, sortable: true, dataIndex: 'inst_Status'},
{ header: "Endpoint VM ID", width: 220, sortable: true, dataIndex: 'inst_UniqueID'},
{ header: "IP", width: 100, sortable: true, dataIndex: 'inst_PublicIP'},
{ header: "Load", width: 50, sortable: true, dataIndex: 'inst_Load', renderer : renderLoad },
{ header: "Uptime", width: 75, sortable: true, dataIndex: 'inst_Uptime', renderer : renderUptime },
{ header: "Jobs", width: 50, sortable: true, dataIndex: 'inst_Jobs' },
{ header: "Last Update (UTC)", width: 125, sortable: true, dataIndex: 'inst_LastUpdate' },
{ header: "Error", width: 350, sortable: true, dataIndex: 'inst_ErrorMessage'},
],
region : 'center',
tbar : [
{ handler:function(){ toggleAll(true) }, text:'Select all', width:150, tooltip:'Click to select all rows' },
{ handler:function(){ toggleAll(false) }, text:'Select none', width:150, tooltip:'Click to select all rows' },
'->',
{ handler:function(){ cbStopSelected() }, text:'Stop', width:150, tooltip:'Click to stop all selected VMs' },
],
bbar: new Ext.PagingToolbar({
pageSize: 50,
store: store,
displayInfo: true,
displayMsg: 'Displaying entries {0} - {1} of {2}',
emptyMsg: "No entries to display",
items:[ '-',
'Items displaying per page: ', createNumItemsSelector(),
'-',
'Show VMs in status: ', createStatusSelector() ],
}),
listeners : { sortchange : cbMainGridSortChange },
{ header: "Image", width: 150, sortable: true, dataIndex: 'img_Name'},
{ header: "EndPoint", width: 100, sortable: true, dataIndex: 'img_CloudEndpoints'},
{ header: "Status", width: 100, sortable: true, dataIndex: 'inst_Status'},
{ header: "Endpoint VM ID", width: 220, sortable: true, dataIndex: 'inst_UniqueID'},
{ header: "IP", width: 100, sortable: true, dataIndex: 'inst_PublicIP'},
{ header: "Load", width: 50, sortable: true, dataIndex: 'inst_Load', renderer : renderLoad },
{ header: "Uptime", width: 75, sortable: true, dataIndex: 'inst_Uptime', renderer : renderUptime },
{ header: "Jobs", width: 50, sortable: true, dataIndex: 'inst_Jobs' },
{ header: "Last Update (UTC)", width: 125, sortable: true, dataIndex: 'inst_LastUpdate' },
{ header: "Error", width: 350, sortable: true, dataIndex: 'inst_ErrorMessage'},
],
region : 'center',
tbar : aux_tbar,
bbar: new Ext.PagingToolbar({
pageSize: 50,
store: store,
displayInfo: true,
displayMsg: 'Displaying entries {0} - {1} of {2}',
emptyMsg: "No entries to display",
items:[ '-',
'Items displaying per page: ', createNumItemsSelector(),
'-',
'Show VMs in status: ', createStatusSelector() ],
}),
listeners : { sortchange : cbMainGridSortChange },
} );
if( config.title )
gMainGrid.setTile( config.title );
Expand Down Expand Up @@ -252,9 +263,38 @@ function cbShowVMHistory( a,b,c )
}

/*
* Stopping VMs (stopping mandative management when vmStopPolicy=never, optional if vmStopPolocy=elastic):
* Callback with Auth or Unauth string, for current RPC access to Web Operation
*/

/*
*/
function checkVmWebOperation()
{
Ext.Ajax.request({
url : "checkVmWebOperation",
cache: false,
async: false,
success : ajaxReturn,
failure : ajaxFailure,
params : { operation : 'Web' }
});
}


function ajaxReturn( ajaxResponse, reqArguments )
{
var retVal = Ext.util.JSON.decode( ajaxResponse.responseText );
if( ! retVal.OK )
{
alert( "Failed to checkVmWebOperation: " + retVal.Message );
return
}
auth_response = retVal.Value
}

/*
* Stopping VMs (stopping mandative management when vmStopPolicy=never, optional if vmStopPolocy=elastic):
*/

function cbStopSelected()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__( self, *args, **kwargs ):
self.stopAgentPath = ''
self.cfgToUpdate = ''


def initialize( self ):
""" initialize
Expand Down Expand Up @@ -144,4 +143,4 @@ def touchStopAgents( self ):
return S_OK()

#...............................................................................
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
2 changes: 1 addition & 1 deletion WorkloadManagementSystem/Agent/VirtualMachineScheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def execute( self ):
numVMs = jobsToSubmitDict['NumVMsToSubmit']

ret = pool.generateJobAndQueueIt( director.submitInstance,
args = ( imageName, self.workDir, endpoint, numVMs, runningPodName ),
args = ( imageName, endpoint, numVMs, runningPodName ),
oCallback = self.callBack,
oExceptionCallback = director.exceptionCallBack,
blocking = False )
Expand Down
14 changes: 7 additions & 7 deletions WorkloadManagementSystem/Client/Nova11.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ def contextualise( self, imageConfig, endpointConfig, **kwargs ):
vmContextualizeScriptPath = contextConfig[ 'vmContextualizeScriptPath' ]
vmRunJobAgentURL = contextConfig[ 'vmRunJobAgentURL' ]
vmRunVmMonitorAgentURL = contextConfig[ 'vmRunVmMonitorAgentURL' ]
vmRunLogJobAgentURL = contextConfig[ 'vmRunLogJobAgentURL' ]
vmRunLogVmMonitorAgentURL = contextConfig[ 'vmRunLogVmMonitorAgentURL' ]
vmRunVmUpdaterAgentURL = contextConfig[ 'vmRunVmUpdaterAgentURL' ]
vmRunLogAgentURL = contextConfig[ 'vmRunLogAgentURL' ]
vmCvmfsContextURL = contextConfig[ 'vmCvmfsContextURL' ]
vmDiracContextURL = contextConfig[ 'vmDiracContextURL' ]
cpuTime = contextConfig[ 'cpuTime' ]
Expand All @@ -493,8 +493,8 @@ def contextualise( self, imageConfig, endpointConfig, **kwargs ):
vmContextualizeScriptPath = vmContextualizeScriptPath,
vmRunJobAgentURL = vmRunJobAgentURL,
vmRunVmMonitorAgentURL = vmRunVmMonitorAgentURL,
vmRunLogJobAgentURL = vmRunLogJobAgentURL,
vmRunLogVmMonitorAgentURL = vmRunLogVmMonitorAgentURL,
vmRunVmUpdaterAgentURL = vmRunVmUpdaterAgentURL,
vmRunLogAgentURL = vmRunLogAgentURL,
vmCvmfsContextURL = vmCvmfsContextURL,
vmDiracContextURL = vmDiracContextURL,
siteName = siteName,
Expand Down Expand Up @@ -524,8 +524,8 @@ def __sshContextualise( self,
vmContextualizeScriptPath,
vmRunJobAgentURL,
vmRunVmMonitorAgentURL,
vmRunLogJobAgentURL,
vmRunLogVmMonitorAgentURL,
vmRunVmUpdaterAgentURL,
vmRunLogAgentURL,
vmCvmfsContextURL,
vmDiracContextURL,
siteName,
Expand Down Expand Up @@ -578,7 +578,7 @@ def __sshContextualise( self,
try:
remotecmd = "/bin/bash /root/contextualize-script.bash \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\'"
remotecmd = remotecmd % ( uniqueId, putCertPath, putKeyPath, vmRunJobAgentURL,
vmRunVmMonitorAgentURL, vmRunLogJobAgentURL, vmRunLogVmMonitorAgentURL,
vmRunVmMonitorAgentURL, vmRunVmUpdaterAgentURL, vmRunLogAgentURL,
vmCvmfsContextURL, vmDiracContextURL, cvmfs_http_proxy, siteName, cloudDriver, cpuTime, vmStopPolicy )
print "remotecmd"
print remotecmd
Expand Down
Loading

0 comments on commit c2c8e9b

Please sign in to comment.