protected void btnMakeReservation_Click(object sender, System.EventArgs e) { // ToDo: Add error checking DateTime startReserveTime = DateUtil.ParseUserToUtc(ddlSelectTime.SelectedItem.Text, culture, userTZ); DateTime endReserveTime = startReserveTime.AddSeconds(Double.Parse(ddlDuration.SelectedValue)); if ((endReserveTime.Minute % quantum) != 0) { DateTime dt = endReserveTime.AddMinutes(quantum - (endReserveTime.Minute % quantum)); if (dt <= endTimePeriod) { endReserveTime = dt; } else { endReserveTime = endTimePeriod; } } lblErrorMessage.Text = ddlSelectTime.SelectedItem.Text + " " + DateUtil.ToUserTime(endReserveTime, culture, -userTZ); lblErrorMessage.Visible = true; string notification = null; LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.Url = lssURL; try { // create "REQUEST RESERVATION" ticket in SB and get the coupon for the ticket. //iLabs.DataTypes.TicketingTypes.Coupon authCoupon = ticketIssuer.CreateTicket(lssGuid, "REQUEST RESERVATION", 300, ""); //assign the coupon from ticket to the soap header; OperationAuthHeader opHeader = new OperationAuthHeader(); opHeader.coupon = coupon; lssProxy.OperationAuthHeaderValue = opHeader; notification = lssProxy.ConfirmReservation(serviceBrokerGuid, groupName, ProcessAgentDB.ServiceGuid, labServerGuid, clientGuid, startReserveTime, endReserveTime); if (notification != "The reservation is confirmed successfully") { lblErrorMessage.Text = Utilities.FormatErrorMessage(notification); } else { try { int status = USSSchedulingAPI.AddReservation(userName, serviceBrokerGuid, groupName, labServerGuid, clientGuid, startReserveTime, endReserveTime); string confirm = "The reservation from<br />" + DateUtil.ToUserTime(startReserveTime,culture,userTZ) + " to " + DateUtil.ToUserTime(endReserveTime, culture, userTZ) + "<br />is confirmed."; lblErrorMessage.Text = Utilities.FormatConfirmationMessage(confirm); } catch(Exception insertEx){ lblErrorMessage.Text = Utilities.FormatErrorMessage(notification); lblErrorMessage.Visible = true; } getTimePeriods(); } lblErrorMessage.Visible = true; return; } catch (Exception ex) { string msg = "Exception: reservation can not be confirmed. " + ex.GetBaseException() + "."; lblErrorMessage.Text = Utilities.FormatErrorMessage(msg); lblErrorMessage.Visible = true; } try { if (notification == "The reservation is confirmed successfully") { int experimentInfoId = USSSchedulingAPI.ListExperimentInfoIDByExperiment(labServerGuid, clientGuid); DateTime startTimeUTC = startReserveTime.ToUniversalTime(); DateTime endTimeUTC = endReserveTime.ToUniversalTime(); } return; } catch (Exception ex) { string msg = "Exception: reservation can not be added successfully. " + ex.GetBaseException() + "."; lblErrorMessage.Text = Utilities.FormatErrorMessage(msg); lblErrorMessage.Visible = true; lssProxy.RemoveReservation(serviceBrokerGuid, groupName, ProcessAgentDB.ServiceGuid, labServerGuid, clientGuid, startReserveTime, endReserveTime); } }
protected int removeSchedulingInfo(int clientId, int serverId, int ussId, int lssId, ref StringBuilder message) { int status = 1; int result = 1; DateTime start = DateTime.UtcNow; DateTime end = DateTime.MaxValue; ProcessAgent ls = ticketing.GetProcessAgent(serverId); ProcessAgentInfo lss = ticketing.GetProcessAgentInfo(lssId); ProcessAgentInfo uss = ticketing.GetProcessAgentInfo(ussId); if (ls == null) { message.AppendLine("LabServer is not specified!<br/>"); status = 0; } if (lss == null) { message.AppendLine("LSS is not specified!<br/>"); status = 0; } if (uss == null) { message.AppendLine("USS is not specified!<br/>"); status = 0; } if (status < 1) { return status; } TicketLoadFactory tlf = TicketLoadFactory.Instance(); string payload = tlf.createRevokeReservationPayload("ISB"); Coupon coupon = ticketing.CreateTicket(TicketTypes.REVOKE_RESERVATION, lss.agentGuid, ProcessAgentDB.ServiceGuid, 300L, payload); ticketing.AddTicket(coupon, TicketTypes.REVOKE_RESERVATION, uss.agentGuid, ProcessAgentDB.ServiceGuid, 300L, payload); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); AgentAuthHeader agentHeader = new AgentAuthHeader(); agentHeader.agentGuid = ProcessAgentDB.ServiceGuid; agentHeader.coupon = lss.identOut; lssProxy.AgentAuthHeaderValue = agentHeader; OperationAuthHeader opHeader = new OperationAuthHeader(); opHeader.coupon = coupon; lssProxy.OperationAuthHeaderValue = opHeader; lssProxy.Url = lss.webServiceUrl; int count = lssProxy.RemoveReservation(ProcessAgentDB.ServiceGuid, "", uss.agentGuid, ls.agentGuid, labClient.clientGuid, start, end); result = lssProxy.RemoveExperimentInfo(ls.agentGuid, labClient.clientGuid); if (result > 0) { status = Math.Min(status, result); } UserSchedulingProxy ussProxy = new UserSchedulingProxy(); AgentAuthHeader header = new AgentAuthHeader(); header.agentGuid = ProcessAgentDB.ServiceGuid; header.coupon = uss.identOut; ussProxy.AgentAuthHeaderValue = header; OperationAuthHeader op2Header = new OperationAuthHeader(); op2Header.coupon = coupon; ussProxy.OperationAuthHeaderValue = op2Header; ussProxy.Url = uss.webServiceUrl; int num = ussProxy.RevokeReservation(ProcessAgentDB.ServiceGuid, "", ls.agentGuid, labClient.clientGuid, start, end, "The USS is being removed from this lab client!"); result = ussProxy.RemoveExperimentInfo(ls.agentGuid, labClient.clientGuid, lss.agentGuid); if (result > 0) { status = Math.Min(status, result); } return status; }
void getTimePeriods() { OperationAuthHeader opHeader = new OperationAuthHeader(); opHeader.coupon = coupon; LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.Url = lssURL; lssProxy.OperationAuthHeaderValue = opHeader; TimePeriod[] availablePeriods = lssProxy.RetrieveAvailableTimePeriods(serviceBrokerGuid, groupName, "", labServerGuid, clientGuid, startTime, endTime); if (availablePeriods == null) { string msg = "There are no available time slots for this experiment."; lblErrorMessage.Text = Utilities.FormatWarningMessage(msg); lblErrorMessage.Visible = true; btnMakeReservation.Visible = false; // btnMakeReservation1.Visible = false; cntrScheduling.Visible=false; } else{ if (availablePeriods.Length > 0) { minTime = availablePeriods[0].quantum > minRequiredTime.TotalMinutes ? TimeSpan.FromMinutes(availablePeriods[0].quantum) : minRequiredTime; } cntrScheduling.Visible = true; cntrScheduling.StartTime = startTime; cntrScheduling.EndTime = endTime; cntrScheduling.UserTZ = userTZ; cntrScheduling.Culture = culture; cntrScheduling.DataSource = availablePeriods; cntrScheduling.DataBind(); } }
protected void btnRemoveReservation_Click(object sender, System.EventArgs e) { DateTime startTime = DateTime.MinValue; DateTime endTime = DateTime.MinValue; DateTime startTimeUTC = startTime.ToUniversalTime(); DateTime endTimeUTC = endTime.ToUniversalTime(); int experimentInfoId = -1; if (lbxReservation.SelectedIndex < 0) { string msg = "Please select the reservation to be removed. "; lblErrorMessage.Text = Utilities.FormatWarningMessage(msg); lblErrorMessage.Visible = true; return; } try { int[] resIDs = new int[] { Int32.Parse(lbxReservation.SelectedValue) }; if (resIDs != null && resIDs.Length > 0) { ReservationInfo[] remove = dbManager.GetReservations(resIDs); if (remove != null && remove.Length > 0) { startTimeUTC = remove[0].startTime; endTimeUTC = remove[0].endTime; experimentInfoId = remove[0].experimentInfoId; UssExperimentInfo[] exp = dbManager.GetExperimentInfos(new int[] { remove[0].experimentInfoId }); UssCredentialSet[] cSet = dbManager.GetCredentialSets(new int[] { remove[0].credentialSetId }); LSSInfo lss = dbManager.GetLSSInfo(exp[0].lssGuid); if (exp != null && exp.Length > 0 && cSet != null && cSet.Length > 0 && lss.lssUrl != null) { Coupon coupon = dbManager.GetCoupon(lss.revokeCouponID, lss.domainGuid); if (coupon != null) { OperationAuthHeader opHeader = new OperationAuthHeader(); opHeader.coupon = coupon; LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.OperationAuthHeaderValue = opHeader; lssProxy.Url = lss.lssUrl; int count = lssProxy.RemoveReservation(cSet[0].serviceBrokerGuid, cSet[0].groupName, ProcessAgentDB.ServiceGuid, exp[0].labServerGuid, exp[0].labClientGuid, startTimeUTC, endTimeUTC); if (count > 0) { dbManager.RemoveReservation(resIDs); string msg = "The reservation has been removed successfully! "; lblErrorMessage.Text = Utilities.FormatConfirmationMessage(msg); lblErrorMessage.Visible = true; } else { string msg = "The reservation has not been removed successfully."; lblErrorMessage.Text = Utilities.FormatErrorMessage(msg); lblErrorMessage.Visible = true; } } else { string msg = "Access denied: The reservation has not been removed successfully."; lblErrorMessage.Text = Utilities.FormatErrorMessage(msg); lblErrorMessage.Visible = true; } } buildReservationListBox(); } } } catch (Exception ex) { string msg = "Exception: reservation can not be removed. " + ex.GetBaseException() + "."; lblErrorMessage.Text = Utilities.FormatErrorMessage(msg); lblErrorMessage.Visible = true; } }
protected int registerUSS(int ussID, ref StringBuilder message) { int status = 1; ProcessAgentInfo uss = null; try { if (labClientID <= 0) { message.AppendLine("Please save the Lab Client information before attempting to associate it with a resource."); status = 0; } if (ddlAssociatedUSS.SelectedIndex == 0) { message.AppendLine("Please select a desired USS to be associated with the client."); status = 0; } if (status < 1) return status; if (ussID > 0) { uss = ticketing.GetProcessAgentInfo(ussID); if (uss != null) { if (uss.retired) { message.AppendLine("The specified USS is retired.<br/>"); return 0; } TicketLoadFactory factory = TicketLoadFactory.Instance(); //this should be in a loop int[] labServerIDs = AdministrativeAPI.GetLabServerIDsForClient(labClientID); if (labServerIDs != null && labServerIDs.Length > 0) { for (int i = 0; i < labServerIDs.Length; i++) { if (labServerIDs[i] > 0) { ProcessAgentInfo labServer = ticketing.GetProcessAgentInfo(labServerIDs[i]); if (labServer.retired) { message.AppendLine("The lab server: " + labServer.agentName + " is retired!<br/>"); } int lssId = ticketing.FindProcessAgentIdForAgent(labServerIDs[i], ProcessAgentType.LAB_SCHEDULING_SERVER); if (lssId > 0) { ProcessAgentInfo lss = ticketing.GetProcessAgentInfo(lssId); if (lss != null) { if (lss.retired) { message.AppendLine("The LSS: " + lss.agentName + " is retired!<br/>"); return 0; } LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.Url = lss.webServiceUrl; lssProxy.AgentAuthHeaderValue = new AgentAuthHeader(); lssProxy.AgentAuthHeaderValue.coupon = lss.identOut; lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; // Is this in the domain or cross-domain //if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid)) // { lssProxy.AddExperimentInfo(labServer.agentGuid, labServer.agentName, labClient.clientGuid, labClient.clientName, labClient.version, labClient.contactEmail); //} // check for existing REVOKE_RESERVATION tickets bool needUssRevoke = true; bool needLssRevoke = true; Coupon ussRevokeCoupon = null; Coupon lssRevokeCoupon = null; Ticket ussRevoke = null; Ticket lssRevoke = null; Ticket[] ussRevokeTickets = ticketing.RetrieveIssuedTickets(-1L, TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid); if (ussRevokeTickets != null && ussRevokeTickets.Length > 0) { ussRevoke = ussRevokeTickets[0]; needUssRevoke = false; } Ticket[] lssRevokeTickets = ticketing.RetrieveIssuedTickets(-1L, TicketTypes.REVOKE_RESERVATION, lss.agentGuid, uss.agentGuid); if (lssRevokeTickets != null && lssRevokeTickets.Length > 0) { lssRevoke = lssRevokeTickets[0]; needLssRevoke = false; } if (ussRevoke == null && lssRevoke == null) { ussRevokeCoupon = ticketing.CreateCoupon(); lssRevokeCoupon = ussRevokeCoupon; } if (needUssRevoke) { string ussRevokePayload = factory.createRevokeReservationPayload("LSS"); if (ussRevokeCoupon == null) { ussRevokeCoupon = ticketing.CreateTicket(TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid, -1L, ussRevokePayload); } else { ticketing.AddTicket(ussRevokeCoupon, TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid, -1L, ussRevokePayload); } // Is this in the domain or cross-domain if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid)) { // this domain //Add USS on LSS int ussAdded = lssProxy.AddUSSInfo(uss.agentGuid, uss.agentName, uss.webServiceUrl, ussRevokeCoupon); status = 1; } else { // cross-domain // send consumerInfo to remote SB int remoteSbId = ticketing.GetProcessAgentID(lss.domainGuid); message.AppendLine(RegistrationSupport.RegisterClientUSS(remoteSbId, null, lss.agentId, null, labServer.agentId, ussRevokeCoupon, uss.agentId, null, labClient.clientID)); } } UserSchedulingProxy ussProxy = new UserSchedulingProxy(); ussProxy.Url = uss.webServiceUrl; ussProxy.AgentAuthHeaderValue = new AgentAuthHeader(); ussProxy.AgentAuthHeaderValue.coupon = uss.identOut; ussProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; if (needLssRevoke) { //ADD LSS on USS string ussPayload = factory.createAdministerUSSPayload(Convert.ToInt32(Session["UserTZ"])); string lssRevokePayload = factory.createRevokeReservationPayload("USS"); if (lssRevokeCoupon == null) { lssRevokeCoupon = ticketing.CreateTicket(TicketTypes.REVOKE_RESERVATION, lss.agentGuid, uss.agentGuid, -1L, lssRevokePayload); } else { ticketing.AddTicket(lssRevokeCoupon, TicketTypes.REVOKE_RESERVATION, lss.agentGuid, uss.agentGuid, -1L, lssRevokePayload); } int lssAdded = ussProxy.AddLSSInfo(lss.agentGuid, lss.agentName, lss.webServiceUrl, lssRevokeCoupon); } //Add Experiment Information on USS int expInfoAdded = ussProxy.AddExperimentInfo(labServer.agentGuid, labServer.agentName, labClient.clientGuid, labClient.clientName, labClient.version, labClient.contactEmail, lss.agentGuid); //Ceate resource Map ResourceMappingKey key = new ResourceMappingKey(ResourceMappingTypes.CLIENT, labClientID); List<ResourceMappingValue> valuesList = new List<ResourceMappingValue>(); valuesList.Add(new ResourceMappingValue(ResourceMappingTypes.RESOURCE_TYPE, ProcessAgentType.SCHEDULING_SERVER)); valuesList.Add(new ResourceMappingValue(ResourceMappingTypes.PROCESS_AGENT, ussID)); valuesList.Add(new ResourceMappingValue(ResourceMappingTypes.TICKET_TYPE, TicketTypes.GetTicketType(TicketTypes.SCHEDULE_SESSION))); // Add the mapping to the database & cache ResourceMapping newMapping = ticketing.AddResourceMapping(key, valuesList.ToArray()); // add mapping to qualifier list int qualifierType = Qualifier.resourceMappingQualifierTypeID; string name = ticketing.ResourceMappingToString(newMapping); int qualifierID = AuthorizationAPI.AddQualifier(newMapping.MappingID, qualifierType, name, Qualifier.ROOT); // Group Credentials MOVED TO THE MANAGE LAB GROUPS PAGE } else { message.AppendLine("The specified LSS was not found!<br/>"); return 0; } } else { message.AppendLine("You must assign a LSS to the lab server before you may assign a USS!<br/>"); return 0; } } } } else { message.AppendLine("You must assign a Lab Server before assigning a USS!<br/>"); return 0; } btnRegisterUSS.Visible = true; btnRegisterUSS.Text = "Dissociate"; ddlAssociatedUSS.Visible = false; txtAssociatedUSS.Visible = true; txtAssociatedUSS.Text = ddlAssociatedUSS.SelectedItem.Text; hdnUssID.Value = ussID.ToString(); message.AppendLine("User-side Scheduling Server \"" + ddlAssociatedUSS.SelectedItem.Text + "\" succesfully " + "associated with client \"" + ddlLabClient.SelectedItem.Text + "\"."); } } else { message.AppendLine("USS was not found!<br/>"); return 0; } } catch (Exception e) { message.AppendLine("Exception: " + e.Message); return -1; } return status; }
// Error recovery must be added to this method protected void btnSaveChange_Click(object sender, EventArgs e) { int id = int.Parse(ddlLabClient.SelectedValue); if (id > 0) { LabClient[] clients = wrapper.GetLabClientsWrapper(new int[] { id }); if (clients.Length > 0 && clients[0].clientID > 0) { theClient = clients[0]; } } // objects used in try block may be required for recovery if errors bool noError = true; ProcessAgentInfo labServer = null; ProcessAgentInfo uss = null; ProcessAgentInfo lss = null; long rmUss = 0; lblResponse.Visible = false; lblResponse.Text = ""; try { if (ddlUserGroup.SelectedIndex <= 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("Please select a user group from the corresponding drop-down list."); return; } int groupID = Convert.ToInt32(ddlUserGroup.SelectedValue); if (groupID <= 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("The user group is invalid."); return; } //Get the user Group Name to be displayed in the repeater Group[] userGroup = wrapper.GetGroupsWrapper(new int[] { groupID }); string userGroupName = userGroup[0].GroupName; if (theClient.labServerIDs != null && theClient.labServerIDs.Length > 0) { labServer = issuer.GetProcessAgentInfo(theClient.labServerIDs[0]); } if (labServer == null) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("Lab Client should first be associated with a Lab Server"); return; } if (theClient.needsScheduling) { if (ddlAdminGroup.SelectedIndex <= 0 || ddlUserGroup.SelectedIndex <= 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("Please select a user and management group from the corresponding drop-down lists."); return; } int manageID = Convert.ToInt32(ddlAdminGroup.SelectedValue); if (manageID <= 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("The management group is invalid."); return; } int ussId = issuer.FindProcessAgentIdForClient(theClient.clientID, ProcessAgentType.SCHEDULING_SERVER); if (ussId <= 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("Lab Client should first be associated with a USS"); return; } int lssId = issuer.FindProcessAgentIdForAgent(theClient.labServerIDs[0], ProcessAgentType.LAB_SCHEDULING_SERVER); if (lssId <= 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatWarningMessage("Lab Server should first be associated with an LSS"); return; } else { uss = issuer.GetProcessAgentInfo(ussId); if (uss.retired) { throw new Exception("The USS is retired"); } lss = issuer.GetProcessAgentInfo(lssId); if (lss.retired) { throw new Exception("The LSS is retired"); } //Object keyObj = groupID; //string keyType = ResourceMappingTypes.GROUP; ResourceMappingKey key = new ResourceMappingKey(ResourceMappingTypes.GROUP, groupID); ResourceMappingValue[] values = new ResourceMappingValue[3]; values[0] = new ResourceMappingValue(ResourceMappingTypes.CLIENT, theClient.clientID); values[1] = new ResourceMappingValue(ResourceMappingTypes.TICKET_TYPE, TicketTypes.GetTicketType(TicketTypes.MANAGE_USS_GROUP)); values[2] = new ResourceMappingValue(ResourceMappingTypes.GROUP,manageID); //values[0] = new ResourceMappingValue(ResourceMappingTypes.RESOURCE_TYPE, ProcessAgentType.SCHEDULING_SERVER); //values[1] = new ResourceMappingValue(ResourceMappingTypes.PROCESS_AGENT, ussId); ResourceMapping newMapping = issuer.AddResourceMapping(key, values); rmUss = newMapping.MappingID; // add mapping to qualifier list int qualifierType = Qualifier.resourceMappingQualifierTypeID; string name = issuer.ResourceMappingToString(newMapping); int qualifierID = AuthorizationAPI.AddQualifier(newMapping.MappingID, qualifierType, name, Qualifier.ROOT); //Give the Manager Group a Grant "MANAGE_USS_GROUP" on the created resource mapping string function = Function.manageUSSGroup; int grantID = wrapper.AddGrantWrapper(manageID, function, qualifierID); //Get the management Group Name to be displayed in the repeater Group[] adminGroup = wrapper.GetGroupsWrapper(new int[] { manageID }); string adminGroupName = adminGroup[0].GroupName; //Create the Map between user and management group GroupManagerUserMap groupMap = new GroupManagerUserMap(adminGroupName, userGroupName, grantID, newMapping.MappingID); TicketLoadFactory factory = TicketLoadFactory.Instance(); //long duration = 60; // Get this SB's domain Guid string domainGuid = ProcessAgentDB.ServiceGuid; string sbName = ProcessAgentDB.ServiceAgent.agentName; //Add Credential set on the USS //string ussPayload = factory.createAdministerUSSPayload(Convert.ToInt32(Session["userTZ"])); //Coupon ussCoupon = issuer.CreateTicket(TicketTypes.ADMINISTER_USS, uss.agentGuid, // issuer.GetIssuerGuid(), duration, ussPayload); UserSchedulingProxy ussProxy = new UserSchedulingProxy(); ussProxy.Url = uss.webServiceUrl; ussProxy.AgentAuthHeaderValue = new AgentAuthHeader(); ussProxy.AgentAuthHeaderValue.coupon = uss.identOut; ussProxy.AgentAuthHeaderValue.agentGuid = domainGuid; ussProxy.AddCredentialSet(domainGuid, sbName, userGroupName); // Check for existing RevokeReservation ticket redeemer = USS, sponsor = LSS Coupon[] revokeCoupons = issuer.RetrieveIssuedTicketCoupon( TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid); Coupon revokeCoupon = null; if (revokeCoupons != null && revokeCoupons.Length > 0) { revokeCoupon = revokeCoupons[0]; } else { // Create RevokeReservation ticket revokeCoupon = issuer.CreateTicket(TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid, -1L, factory.createRevokeReservationPayload()); } //Add Credential set on the LSS // check if this domain if (ProcessAgentDB.ServiceGuid.Equals(lss.domainGuid)) { LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.Url = lss.webServiceUrl; lssProxy.AgentAuthHeaderValue = new AgentAuthHeader(); lssProxy.AgentAuthHeaderValue.coupon = lss.identOut; lssProxy.AgentAuthHeaderValue.agentGuid = domainGuid; // Add the USS to the LSS, this may be called multiple times with duplicate data lssProxy.AddUSSInfo(uss.AgentGuid, uss.agentName, uss.webServiceUrl, revokeCoupon); int credentialSetAdded = lssProxy.AddCredentialSet(domainGuid, sbName, userGroupName, uss.agentGuid); } else { // Cross-Domain Registration needed ProcessAgentInfo remoteSB = issuer.GetProcessAgentInfo(lss.domainGuid); if(remoteSB.retired){ throw new Exception("The remote service broker is retired"); } ResourceDescriptorFactory resourceFactory = ResourceDescriptorFactory.Instance(); string ussDescriptor = resourceFactory.CreateProcessAgentDescriptor(ussId); string lssDescriptor = resourceFactory.CreateProcessAgentDescriptor(lssId); string groupDescriptor = resourceFactory.CreateGroupCredentialDescriptor(domainGuid, sbName, userGroupName, uss.agentGuid, lss.agentGuid); ServiceDescription[] info = new ServiceDescription[3]; info[0] = new ServiceDescription(null, revokeCoupon, ussDescriptor); info[1] = new ServiceDescription(null, null, lssDescriptor); info[2] = new ServiceDescription(null, null, groupDescriptor); ProcessAgentProxy sbProxy = new ProcessAgentProxy(); sbProxy.AgentAuthHeaderValue = new AgentAuthHeader(); sbProxy.AgentAuthHeaderValue.agentGuid = domainGuid; sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut; sbProxy.Url = remoteSB.webServiceUrl; sbProxy.Register(Utilities.MakeGuid(), info); } } } /*Update Lab Client grants*/ //Get qualifier for labclient int lcQualifierID = AuthorizationAPI.GetQualifierID(theClient.clientID, Qualifier.labClientQualifierTypeID); //Get all "uselabclient" grants for this labclient int[] lcGrantIDs = wrapper.FindGrantsWrapper(-1, Function.useLabClientFunctionType, lcQualifierID); Grant[] lcGrants = wrapper.GetGrantsWrapper(lcGrantIDs); //Get list of agents that can use labclient ArrayList lcAgents = new ArrayList(); foreach (Grant g in lcGrants) lcAgents.Add(g.agentID); //if that agent doesn't already have the uselabclient permission if (!lcAgents.Contains(groupID)) //add lab client grant wrapper.AddGrantWrapper(groupID, Function.useLabClientFunctionType, lcQualifierID); /*Update Lab Servers grant*/ //Update grants for each of the associated lab servers foreach (int lsID in theClient.labServerIDs) { //Get qualifier for labserver int lsQualifierID = AuthorizationAPI.GetQualifierID(lsID, Qualifier.labServerQualifierTypeID); //Get all "uselabserver" grants for this labserver int[] lsGrantIDs = wrapper.FindGrantsWrapper(-1, Function.useLabServerFunctionType, lsQualifierID); Grant[] lsGrants = wrapper.GetGrantsWrapper(lsGrantIDs); //Get list of agents that can use labserver ArrayList lsAgents = new ArrayList(); foreach (Grant g in lsGrants) lsAgents.Add(g.agentID); //int groupID = Convert.ToInt32(ddlUserGroup.SelectedValue); //if that agent doesn't already have the uselabclient permission if (!lsAgents.Contains(groupID)) //add lab server grant wrapper.AddGrantWrapper(groupID, Function.useLabServerFunctionType, lsQualifierID); } //Refresh the repeater RefreshAdminUserGroupsRepeater(); LoadListBoxes(); lblResponse.Visible = true; lblResponse.Text = Utilities.FormatConfirmationMessage("Lab client (& corresponding lab servers) successfully updated. "); } catch (Exception ex) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatErrorMessage("Cannot update Lab Client. " + ex.GetBaseException()); } }
protected override void register(string registerGuid, ServiceDescription[] info) { StringBuilder message = new StringBuilder(); message.AppendLine("Service " + ProcessAgentDB.ServiceAgent.codeBaseUrl + " recieved a 'Register' webService call."); if (info == null) { //message.AppendLine("Register called without any ServiceDescriptions"); throw new ArgumentNullException("Register called without any ServiceDescriptions"); } try { base.register(registerGuid, info); } catch (Exception e) { message.AppendLine("Error in base.register" + Utilities.DumpException(e)); throw new Exception(message.ToString(), e); } bool hasProvider = false; bool hasConsumer = false; string ns = ""; int lssID = 0; int lsID = 0; ProcessAgentInfo ls = null; ProcessAgentInfo lss = null; ProcessAgentInfo uss = null; LabClient labClient = null; GroupCredential credential = null; try { ResourceDescriptorFactory rFactory = ResourceDescriptorFactory.Instance(); string jobGuid = registerGuid; message.AppendLine(" Register called at " + DateTime.UtcNow + " UTC \t registerGUID: " + registerGuid); ProcessAgent sourceAgent = brokerDB.GetProcessAgent(agentAuthHeader.agentGuid); message.AppendLine("Source Agent: " + sourceAgent.agentName); for (int i = 0; i < info.Length; i++) { Coupon coupon = null; if (info[i].coupon != null) { coupon = info[i].coupon; } if (info[i].serviceProviderInfo != null && info[i].serviceProviderInfo.Length > 0) { // ProviderInfo is simple add to database and create qualifier if (!hasProvider) { message.AppendLine("Provider Info:"); hasProvider = true; } XmlQueryDoc xdoc = new XmlQueryDoc(info[i].serviceProviderInfo); string descriptorType = xdoc.GetTopName(); if (descriptorType.Equals("processAgentDescriptor")) { string paGuid = xdoc.Query("/processAgentDescriptor/agentGuid"); string paType = xdoc.Query("/processAgentDescriptor/type"); if (paType.Equals(ProcessAgentType.LAB_SCHEDULING_SERVER)) { lssID = brokerDB.GetProcessAgentID(paGuid); if (lssID > 0) { // Already in database //message.AppendLine("Reference to existing LSS: " + lssID + " GUID: " + paGuid); } else { lss = rFactory.LoadProcessAgent(xdoc, ref message); lssID = lss.agentId; } } else if (paType.Equals(ProcessAgentType.LAB_SERVER)) { lsID = brokerDB.GetProcessAgentID(paGuid); if (lsID > 0) { // Already in database //message.AppendLine("Reference to existing LS: " + lsID + " GUID: " + paGuid); } else { ls = rFactory.LoadProcessAgent(xdoc, ref message); lsID = ls.agentId; } int myLssID = brokerDB.FindProcessAgentIdForAgent(lsID, ProcessAgentType.LAB_SCHEDULING_SERVER); if ((lssID > 0) && (myLssID <= 0) && (lssID != myLssID)) { brokerDB.AssociateLSS(lsID, lssID); } } } else if (descriptorType.Equals("clientDescriptor")) { int clientId = -1; string clientGuid = xdoc.Query("/clientDescriptor/clientGuid"); clientId = AdministrativeAPI.GetLabClientID(clientGuid); if (clientId > 0) { // Already in database message.Append(" Attempt to Register a LabClient that is already in the database. "); message.AppendLine(" GUID: " + clientGuid); } else { // LabServer should already be in the Database, once multiple LS supported may need work // LS is specified in clientDescriptor int clientID = rFactory.LoadLabClient(xdoc, ref message); message.AppendLine("Adding LabClient: GUID " + clientGuid); } } else if (descriptorType.Equals("systemSupport")) { // Already handled in base.register } // Add Relationships: LSS, LS Client } // end of ServiceProvider if (info[i].consumerInfo != null && info[i].consumerInfo.Length > 0) { // requestSystemSupport Handled by base register & there is no xml dcument if (info[i].consumerInfo.CompareTo("requestSystemSupport") != 0) { message.AppendLine("Consumer Info: " + info[i].consumerInfo); //if (!hasConsumer) // message.AppendLine("Consumer Info: " + info[i].consumerInfo); hasConsumer = true; XmlQueryDoc xdoc = new XmlQueryDoc(info[i].consumerInfo); string descriptorType = xdoc.GetTopName(); if (descriptorType.Equals("processAgentDescriptor")) { string paGuid = xdoc.Query("/processAgentDescriptor/agentGuid"); ProcessAgentInfo paInfo = brokerDB.GetProcessAgentInfo(paGuid); if (paInfo == null) { // Not in database paInfo = rFactory.LoadProcessAgent(xdoc, ref message); message.Append("Loaded new "); } else { message.Append("Reference to existing "); if (paInfo.retired) { throw new Exception("The ProcessAgent is retired"); } } if (paInfo.agentType == ProcessAgentType.AgentType.LAB_SCHEDULING_SERVER) { lss = paInfo; message.AppendLine("LSS: " + paGuid); } else if (paInfo.agentType == ProcessAgentType.AgentType.LAB_SERVER) { ls = paInfo; message.AppendLine("LS: " + paGuid); } else if (paInfo.agentType == ProcessAgentType.AgentType.SCHEDULING_SERVER) { uss = paInfo; message.AppendLine("USS: " + paGuid); if (lss != null) { if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid)) { message.AppendLine("Registering USSinfo on LSS: " + lss.agentName); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.AgentAuthHeaderValue = new AgentAuthHeader(); lssProxy.AgentAuthHeaderValue.coupon = lss.identOut; lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; lssProxy.Url = lss.webServiceUrl; lssProxy.AddUSSInfo(uss.agentGuid, uss.agentName, uss.webServiceUrl, coupon); } else { message.AppendLine("LSS is not from this domain"); } } } } else if (descriptorType.Equals("clientDescriptor")) { int newClientId = -1; string clientGuid = xdoc.Query("/clientDescriptor/clientGuid"); int clientId = AdministrativeAPI.GetLabClientID(clientGuid); if (clientId > 0) { // Already in database message.Append(" Attempt to Register a LabClient that is already in the database. "); message.AppendLine(" GUID: " + clientGuid); } else { clientId = rFactory.LoadLabClient(xdoc, ref message); message.AppendLine("Adding Lab Client GUID: " + clientGuid); } } else if (descriptorType.Equals("credentialDescriptor")) { credential = rFactory.ParseCredential(xdoc, ref message); if (lss != null) { if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid)) { message.AppendLine("Registering Group Credentials on LSS: " + lss.agentName); message.AppendLine("Group: " + credential.groupName + " DomainServer: " + credential.domainServerName); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.AgentAuthHeaderValue = new AgentAuthHeader(); lssProxy.AgentAuthHeaderValue.coupon = lss.identOut; lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; lssProxy.Url = lss.webServiceUrl; lssProxy.AddCredentialSet(credential.domainGuid, credential.domainServerName, credential.groupName, credential.ussGuid); } else { message.AppendLine("LSS is not from this domain"); } } } } } } // End of info loop } // End of Try catch (Exception ex) { message.Append("Exception in Register: " + Utilities.DumpException(ex)); throw new Exception(message.ToString(),ex); } finally { // Send a mail Message StringBuilder sb = new StringBuilder(); MailMessage mail = new MailMessage(); mail.To = ConfigurationManager.AppSettings["supportMailAddress"]; //mail.To = "*****@*****.**"; mail.From = ConfigurationManager.AppSettings["genericFromMailAddress"]; mail.Subject = "Register called on " + ProcessAgentDB.ServiceAgent.agentName; mail.Body = message.ToString(); SmtpMail.SmtpServer = "127.0.0.1"; try { SmtpMail.Send(mail); } catch (Exception ex) { // Report detailed SMTP Errors StringBuilder smtpErrorMsg = new StringBuilder(); smtpErrorMsg.Append("Exception: " + ex.Message); //check the InnerException if (ex.InnerException != null) smtpErrorMsg.Append("<br>Inner Exceptions:"); while (ex.InnerException != null) { smtpErrorMsg.Append("<br>" + ex.InnerException.Message); ex = ex.InnerException; } Logger.WriteLine(smtpErrorMsg.ToString()); } } }
public int RevokeReservation(string serviceBrokerGuid, string groupName, string labServerGuid, string labClientGuid, DateTime startTime, DateTime endTime, string message) { bool status = false; bool fromISB = false; int count = 0; Coupon opCoupon = new Coupon(); opCoupon.couponId = opHeader.coupon.couponId; opCoupon.passkey = opHeader.coupon.passkey; opCoupon.issuerGuid = opHeader.coupon.issuerGuid; UserSchedulingDB dbManager = new UserSchedulingDB(); try { Ticket retrievedTicket = dbManager.RetrieveAndVerify(opCoupon, TicketTypes.REVOKE_RESERVATION); if (retrievedTicket.payload != null && retrievedTicket.payload.Length > 0) { XmlQueryDoc revokeDoc = new XmlQueryDoc(retrievedTicket.payload); string sourceStr = revokeDoc.Query("RevokeReservationPayload/source"); if (sourceStr != null && sourceStr.CompareTo("ISB") == 0) { fromISB = true; } } DateTime targetStart = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0, startTime.Kind); if (targetStart.Kind != DateTimeKind.Utc) targetStart = targetStart.ToUniversalTime(); DateTime targetEnd = new DateTime(endTime.Year, endTime.Month, endTime.Day, endTime.Hour, endTime.Minute, 0, endTime.Kind); if (targetEnd.Kind != DateTimeKind.Utc) targetEnd = targetEnd.ToUniversalTime(); if (fromISB) { // Need to forward to LSS string lssUrl = dbManager.ListLssUrlByExperiment(labClientGuid, labServerGuid); if (lssUrl != null && lssUrl.Length > 0) { LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.OperationAuthHeaderValue = new OperationAuthHeader(); lssProxy.OperationAuthHeaderValue.coupon = opCoupon; lssProxy.Url = lssUrl; int rCount = lssProxy.RemoveReservation(serviceBrokerGuid, groupName, ProcessAgentDB.ServiceGuid, labServerGuid, labClientGuid, targetStart, targetEnd); } } ReservationData[] ris = dbManager.GetReservations(serviceBrokerGuid, null, groupName, labServerGuid, labClientGuid, targetStart, targetEnd); if (ris != null && ris.Length > 0) { InteractiveSBProxy sbProxy = new InteractiveSBProxy(); ProcessAgentInfo sbInfo = dbManager.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid); AgentAuthHeader header = new AgentAuthHeader(); header.coupon = sbInfo.identOut; header.agentGuid = ProcessAgentDB.ServiceGuid; sbProxy.AgentAuthHeaderValue = header; sbProxy.Url = sbInfo.webServiceUrl; foreach (ReservationData rd in ris) { status = dbManager.RevokeReservation(rd.sbGuid, rd.groupName, rd.lsGuid, rd.clientGuid, rd.startTime, rd.endTime, message); if (status) { count++; status = sbProxy.RevokeReservation(rd.sbGuid, rd.userName, rd.groupName, rd.lsGuid, rd.clientGuid, rd.startTime, rd.endTime, message); } } } } catch (Exception e) { throw new Exception("USS: RevokeReservation -> ",e); } return count; }
public TimePeriod[] RetrieveAvailableTimePeriods(string serviceBrokerGuid, string groupName, string labServerGuid, string clientGuid, DateTime startTime, DateTime endTime) { Coupon opCoupon = new Coupon(); opCoupon.couponId = opHeader.coupon.couponId; opCoupon.passkey = opHeader.coupon.passkey; opCoupon.issuerGuid = opHeader.coupon.issuerGuid; try { UserSchedulingDB dbManager = new UserSchedulingDB(); Ticket ssTicket = dbManager.RetrieveAndVerify(opCoupon, TicketTypes.SCHEDULE_SESSION); string lssGuid = dbManager.ListLssIdByExperiment(clientGuid, labServerGuid); LSSInfo lssInfo = dbManager.GetLSSInfo(lssGuid); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.OperationAuthHeaderValue = new OperationAuthHeader(); lssProxy.OperationAuthHeaderValue.coupon = opCoupon; lssProxy.Url = lssInfo.lssUrl; TimePeriod[] array = lssProxy.RetrieveAvailableTimePeriods( serviceBrokerGuid, groupName, ProcessAgentDB.ServiceGuid, labServerGuid, clientGuid, startTime, endTime); return array; } catch { throw; } }
public string AddReservation(string serviceBrokerGuid, string userName, string groupName, string labServerGuid, string labClientGuid, DateTime startTime, DateTime endTime) { string message = null; Coupon opCoupon = new Coupon(); UserSchedulingDB dbManager = new UserSchedulingDB(); opCoupon.couponId = opHeader.coupon.couponId; opCoupon.passkey = opHeader.coupon.passkey; opCoupon.issuerGuid = opHeader.coupon.issuerGuid; string type = TicketTypes.SCHEDULE_SESSION; try { Ticket retrievedTicket = dbManager.RetrieveAndVerify(opCoupon, type); if (retrievedTicket.IsExpired()) { throw new AccessDeniedException("The reservation ticket has expired, Please re-login."); } //used to check ticketPayload string user = null; string group = null; string labGuid = null; string clientGuid = null; string sbGuid = null; //Resolved target arguments string userTarget = null; string groupTarget = null; string labGuidTarget = null; string clientGuidTarget = null; XmlDocument payload = new XmlDocument(); payload.LoadXml(retrievedTicket.payload); sbGuid = payload.GetElementsByTagName("sbGuid")[0].InnerText; user = payload.GetElementsByTagName("userName")[0].InnerText; group = payload.GetElementsByTagName("groupName")[0].InnerText; clientGuid = payload.GetElementsByTagName("clientGuid")[0].InnerText; labGuid = payload.GetElementsByTagName("labServerGuid")[0].InnerText; userTarget = Utilities.ResolveArguments(userName, user, true); groupTarget = Utilities.ResolveArguments(groupName, group, true); clientGuidTarget = Utilities.ResolveArguments(labClientGuid, clientGuid, false); labGuidTarget = Utilities.ResolveArguments(labServerGuid, labGuid, false); string lssGuid = dbManager.ListLssIdByExperiment(labClientGuid, labServerGuid); LSSInfo lssInfo = dbManager.GetLSSInfo(lssGuid); DateTime targetStart = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, 0, startTime.Kind); if (targetStart.Kind != DateTimeKind.Utc) targetStart = targetStart.ToUniversalTime(); DateTime targetEnd = new DateTime(endTime.Year, endTime.Month, endTime.Day, endTime.Hour, endTime.Minute, 0, endTime.Kind); if (targetEnd.Kind != DateTimeKind.Utc) targetEnd = targetEnd.ToUniversalTime(); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.OperationAuthHeaderValue = new OperationAuthHeader(); lssProxy.OperationAuthHeaderValue.coupon = opCoupon; lssProxy.Url = lssInfo.lssUrl; message = lssProxy.ConfirmReservation( serviceBrokerGuid, groupName, ProcessAgentDB.ServiceGuid, labServerGuid, labClientGuid, targetStart, targetEnd); if(message.ToLower().Contains("success")){ int infoID = dbManager.ListExperimentInfoIDByExperiment(labServerGuid, labClientGuid); dbManager.AddReservation(userName, serviceBrokerGuid,groupName,infoID,targetStart,targetEnd); } return message; } catch (Exception e) { throw new Exception("USS: AddReservation -> ", e); } return message; }
protected void btnRegisterUSS_Click(object sender, EventArgs e) { lblResponse.Visible = false; lblResponse.Text = ""; StringBuilder message = new StringBuilder(); try { if (ddlLabClient.SelectedIndex == 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatErrorMessage("Please save the Lab Client information before attempting to dissociate it from a resource"); return; } if (ddlAssociatedUSS.SelectedIndex == 0) { lblResponse.Visible = true; lblResponse.Text = Utilities.FormatErrorMessage("Please select a desired USS to be associated with the client."); return; } LabClient lc = new LabClient(); lc = labClients[ddlLabClient.SelectedIndex - 1]; Object keyObj = int.Parse(ddlLabClient.SelectedValue); string keyType = ResourceMappingTypes.CLIENT; ArrayList valuesList = new ArrayList(); Object valueObj = null; ResourceMappingValue value = new ResourceMappingValue(ResourceMappingTypes.RESOURCE_TYPE, ProcessAgentType.SCHEDULING_SERVER); valuesList.Add(value); int ussId = int.Parse(ddlAssociatedUSS.SelectedValue); if (ussId > 0) { value = new ResourceMappingValue(ResourceMappingTypes.PROCESS_AGENT, ussId); valuesList.Add(value); value = new ResourceMappingValue(ResourceMappingTypes.TICKET_TYPE, TicketTypes.GetTicketType(TicketTypes.SCHEDULE_SESSION)); valuesList.Add(value); ResourceMappingKey key = new ResourceMappingKey(keyType, keyObj); ResourceMappingValue[] values = (ResourceMappingValue[])valuesList.ToArray((new ResourceMappingValue()).GetType()); // Add the mapping to the database & cache ResourceMapping newMapping = ticketing.AddResourceMapping(key, values); // add mapping to qualifier list int qualifierType = Qualifier.resourceMappingQualifierTypeID; string name = ticketing.ResourceMappingToString(newMapping); int qualifierID = AuthorizationAPI.AddQualifier(newMapping.MappingID, qualifierType, name, Qualifier.ROOT); // Moved to ManageLabGroups //Give the Manager Group a Grant "MANAGE_USS_GROUP" on the created resource mapping //int agentID = Convert.ToInt32(ddlAdminGroup.SelectedValue); //string function = Function.manageUSSGroup; //int grantID = wrapper.AddGrantWrapper(agentID, function, qualifierID); Session["ClientUssMappingID"] = newMapping.MappingID; btnRegisterUSS.Visible = false; btnDissociateUSS.Visible = true; ddlAssociatedUSS.Enabled = false; message.AppendLine("User-side Scheduling Server \"" + ddlAssociatedUSS.SelectedItem.Text + "\" succesfully " + "associated with client \"" + ddlLabClient.SelectedItem.Text + "\"."); //wrapper.ModifyLabClientWrapper(lc.clientID, lc.clientName, lc.version, lc.clientShortDescription, // lc.clientLongDescription, lc.notes, lc.loaderScript, lc.clientType, // lc.labServerIDs, lc.contactEmail, lc.contactFirstName, lc.contactLastName, // lc.needsScheduling, lc.needsESS, lc.IsReentrant, lc.clientInfos); TicketLoadFactory factory = TicketLoadFactory.Instance(); ProcessAgentInfo uss = ticketing.GetProcessAgentInfo(ussId); if (uss.retired) { throw new Exception("The specified USS is retired"); } //this should be in a loop for(int i = 0;i<lc.labServerIDs.Length;i++){ if (lc.labServerIDs[i] > 0) { ProcessAgentInfo labServer = ticketing.GetProcessAgentInfo(lc.labServerIDs[i]); if (labServer.retired) { throw new Exception("The lab server is retired"); } int lssId = ticketing.FindProcessAgentIdForAgent(lc.labServerIDs[i], ProcessAgentType.LAB_SCHEDULING_SERVER); if (lssId > 0) { ProcessAgentInfo lss = ticketing.GetProcessAgentInfo(lssId); if (lss.retired) { throw new Exception("The LSS is retired"); } // The REVOKE_RESERVATION ticket string revokePayload = factory.createRevokeReservationPayload(); Coupon ussCoupon = ticketing.CreateTicket(TicketTypes.REVOKE_RESERVATION, uss.agentGuid, lss.agentGuid, -1L, revokePayload); // Is this in the domain or cross-domain if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid)) { // this domain //Add USS on LSS //string lssPayload = factory.createAdministerLSSPayload(Convert.ToInt32(Session["UserTZ"])); //long duration = 60; //seconds for the LSS to redeem the ticket of this coupon and Add LSS Info //ticketing.AddTicket(lssCoupon, TicketTypes.ADMINISTER_LSS, lss.agentGuid, // ticketing.ServiceGuid(), duration, lssPayload); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.Url = lss.webServiceUrl; lssProxy.AgentAuthHeaderValue = new AgentAuthHeader(); lssProxy.AgentAuthHeaderValue.coupon = lss.identOut; lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; int ussAdded = lssProxy.AddUSSInfo(uss.agentGuid, uss.agentName, uss.webServiceUrl, ussCoupon); lssProxy.AddExperimentInfo(labServer.agentGuid, labServer.agentName, lc.clientGuid, lc.clientName, lc.version, lc.contactEmail); } else { // cross-domain // send consumerInfo to remote SB int remoteSbId = ticketing.GetProcessAgentID(lss.domainGuid); message.AppendLine(RegistrationSupport.RegisterClientUSS(remoteSbId, null, lss.agentId, null, labServer.agentId, ussCoupon, uss.agentId, null, lc.clientID)); } //ADD LSS on USS string ussPayload = factory.createAdministerUSSPayload(Convert.ToInt32(Session["UserTZ"])); UserSchedulingProxy ussProxy = new UserSchedulingProxy(); ussProxy.Url = uss.webServiceUrl; ussProxy.AgentAuthHeaderValue = new AgentAuthHeader(); ussProxy.AgentAuthHeaderValue.coupon = uss.identOut; ussProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; int lssAdded = ussProxy.AddLSSInfo(lss.agentGuid, lss.agentName, lss.webServiceUrl); //Add Experiment Information on USS int expInfoAdded = ussProxy.AddExperimentInfo(labServer.agentGuid, labServer.agentName, lc.clientGuid, lc.clientName, lc.version, lc.contactEmail, lss.agentGuid); // Group Credentials MOVED TO THE MANAGE LAB GROUPS PAGE } } } } } catch { throw; } lblResponse.Visible = true; lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString()); }
protected void btnAssociateLSS_Click(object sender, EventArgs e) { int lsID = 0; int lssID = 0; if (btnAssociateLSS.CommandName.CompareTo("associate") == 0) { try { if (ddlLSS.SelectedIndex == 0) { lblErrorMessage.Visible = true; lblErrorMessage.Text = Utilities.FormatErrorMessage("Please select a desired LSS to be associated with the lab server."); return; } if (ddlManageLSS.SelectedIndex == 0) { lblErrorMessage.Visible = true; lblErrorMessage.Text = Utilities.FormatErrorMessage("Please select a group to manage the Lab Server on the lab scheduling server."); return; } lsID = Int32.Parse(ddlService.SelectedValue); lssID = Int32.Parse(ddlLSS.SelectedValue); int manageGroupID = Int32.Parse(ddlManageLSS.SelectedValue); try { int qualifierID = brokerDB.AssociateLSS(lsID, lssID); int labGrantID = wrapper.AddGrantWrapper(manageGroupID, Function.manageLAB, qualifierID); string manageGroup = AdministrativeAPI.GetGroupName(manageGroupID); ProcessAgentInfo lss = brokerDB.GetProcessAgentInfo(lssID); LabSchedulingProxy lssProxy = new LabSchedulingProxy(); lssProxy.AgentAuthHeaderValue = new AgentAuthHeader(); lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; lssProxy.AgentAuthHeaderValue.coupon = lss.identOut; lssProxy.Url = lss.webServiceUrl; lssProxy.AddCredentialSet(ProcessAgentDB.ServiceGuid, ProcessAgentDB.ServiceAgent.agentName, manageGroup, null); } catch (Exception ex) { Logger.WriteLine(ex.Message); } btnAssociateLSS.Text = "Disassociate"; btnAssociateLSS.CommandName = "disassociate"; ddlLSS.Enabled = false; ddlLSS.BackColor = disabled; ddlManageLSS.Enabled = false; ddlManageLSS.BackColor = disabled; lblErrorMessage.Visible = true; lblErrorMessage.Text = Utilities.FormatConfirmationMessage("Lab-side Scheduling Server \"" + ddlLSS.SelectedItem.Text + "\" succesfully " + "associated with lab server \"" + ddlService.SelectedItem.Text + "\"."); } catch { throw; } } else if (btnAssociateLSS.CommandName.CompareTo("disassociate") == 0) { try { int mapId = ResourceMapManager.FindMapID(ResourceMappingTypes.PROCESS_AGENT, lsID, ResourceMappingTypes.RESOURCE_TYPE, ProcessAgentType.LAB_SCHEDULING_SERVER); if (mapId > 0) { brokerDB.DeleteResourceMapping(mapId); } lblErrorMessage.Visible = true; lblErrorMessage.Text = Utilities.FormatConfirmationMessage("Lab-side Scheduling Server \"" + ddlLSS.SelectedItem.Text + "\" succesfully " + "dissociated from lab server \"" + ddlService.SelectedItem.Text + "\"."); ddlLSS.Enabled = true; ddlLSS.BackColor = enabled; ddlLSS.SelectedIndex = 0; ddlManageLSS.SelectedIndex = 0; ddlManageLSS.Enabled = true; ddlManageLSS.BackColor = enabled; btnAssociateLSS.CommandName = "associate"; btnAssociateLSS.Text = "Associate"; } catch { throw; } } displayService(lsID); }