Computing > 6 - Schedules Management > Adding a Scheduled Occurrence

6.3 Adding a Scheduled Occurrence

By using the Aruba WsEndUser method SetAddServerScheduledOperation รจ possibile aggiungere un'operazione schedulata riccorente.

Parameters
serverId
Type: int
Value of type int with the server identifier

operationType
Type: ScheduledOperationTypes
Value of type ScheduledOperationTypes which contains the operation type :
  • StartVirtualMachine
  • StopVirtualMachine
  • ShutdownVirtualMachine
  • UpdateVirtualMachine
  • CreateSnapshot
  • RestoreSnapShot
  • DeleteSnapshot

operationLabel
Type: string
Value of type string with a label to assign to the operation

dateStart
Type: DateTime
Value of type DateTime which contains the start date of time interval

dateEnd
Type: DateTime
Value of type DateTime which contains the end date of time interval

operationParameters
Type: OperationParameters[]
Array of OperationParameters with the parameters to send to the operation.

frequencyType
Type: ScheduleFrequencyType
Value of type ScheduleFrequencyType with one of following values:
  • Hourly.
  • Daily.
  • Weekly.
  • Monthly.
  • MonthlyRelative

montlyRecurrence
Type: ScheduledMontlyRecurrence
VAlue of type ScheduledMontlyRecurrence with the recurrence information about MonthlyRelative operation:
  • FirstDay
  • LastDay


daysOfMonth
Type: int[]
Array of int with the days of month in which to execute the operation (in case of Monthly frequency type).

daysOfWeek
Type: ScheduleWeekDays[]
Array of ScheduleWeekDays the days of week in which to execute the operation (in case of Weekly frequency type).

frequency
Type: int[]
Array of int with execution frequency of other cases of frequency type.


/// IWsEndUser.SetAddServerScheduledOperation Method (c# .NET)
public static string SetAddServerScheduledOperation(WsEndUserClient client,
        int serverId, ScheduledOperationTypes operationType, string operationLabel,
        DateTime dateStart, DateTime dateEnd, OperationParameters[] operationParameters,
    ScheduleFrequencyType frequencyType, int frequency,
    ScheduledMontlyRecurrence montlyRecurrence,
    int[] daysOfMonth, ScheduleWeekDays[] daysOfWeek)
{
    //specify the account login details 
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
        // create the object SetAddScheduledOperationRequest  for the request 
        // with data to process
        SetAddScheduledOperationRequest scheduledOperationRequest = 
            new SetAddScheduledOperationRequest();
        scheduledOperationRequest.ServerID = serverId;
        scheduledOperationRequest.OperationType = operationType;
        scheduledOperationRequest.OperationsParameters = operationParameters;

        SchedulePlan plan = new SchedulePlan();
        plan.ScheduleStartDateTime = dateStart;
        plan.ScheduleEndDateTime = dateEnd;
        plan.ScheduleOperationLabel = operationLabel;
        plan.ScheduleFrequencyType = frequencyType;
        plan.ScheduledMontlyRecurrence = montlyRecurrence;
        plan.ScheduledPlanStatus = ScheduledPlanStatus.Enabled;
        plan.ScheduleFrequency = frequency;
        plan.ScheduleDaysOfMonth = daysOfMonth;                
        plan.ScheduleWeekDays = daysOfWeek;

        scheduledOperationRequest.NewSchedulePlan = plan;
                
        // call method SetAddServerScheduledOperation 
        // obtaining a WsResult item
        WsResult result = 
            client.SetAddServerScheduledOperation(scheduledOperationRequest);

        //if the call is Success print history values
        if (result.Success)
        {
            // get Value returned from server
            stringBuilder.Append(" Operation successfully. Result Code : ");
            stringBuilder.Append(result.ResultCode);
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        // re-run the error
        throw new ApplicationException(ex.Message);
    }

    return stringBuilder.ToString();
}
// IWsEndUser.SetAddServerScheduledOperation Method (JAVA)
public static String SetAddServerScheduledOperation(IWsEndUser client,
        int serverId, ScheduledOperationTypes operationType, String operationLabel,
        XMLGregorianCalendar dateStart, XMLGregorianCalendar dateEnd, 
        OperationParameters[] operationParameters,
    ScheduleFrequencyType frequencyType, int frequency,
    ScheduledMontlyRecurrence montlyRecurrence,
    ArrayOfint daysOfMonth, ArrayOfScheduleWeekDays daysOfWeek)
{
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
        // create the object SetAddScheduledOperationRequest  for the request 
        // with data to process
        SetAddScheduledOperationRequest scheduledOperationRequest = 
            new SetAddScheduledOperationRequest();
        scheduledOperationRequest.setServerID(serverId);
        scheduledOperationRequest.setOperationType(operationType);
        scheduledOperationRequest.setOperationsParameters(operationParameters);

        SchedulePlan plan = new SchedulePlan();
        plan.setScheduleStartDateTime(dateStart);
        plan.setScheduleEndDateTime(dateEnd);
        plan.setScheduleOperationLabel(operationLabel);
        plan.setScheduleFrequencyType(frequencyType);
        plan.setScheduledMontlyRecurrence(montlyRecurrence);
        plan.setScheduledPlanStatus(ScheduledPlanStatus.ENABLED);
        plan.setScheduleFrequency(frequency);
        plan.setScheduleDaysOfMonth(daysOfMonth);                
        plan.setScheduleWeekDays(daysOfWeek);

        scheduledOperationRequest.setNewSchedulePlan(plan);
                
        // call method SetAddServerScheduledOperation 
        // obtaining a WsResult item
        WsResult result = 
            client.setAddServerScheduledOperation(scheduledOperationRequest);

        //if the call is Success print history values
        if (result.isSuccess())
        {
            // get Value returned from server
            stringBuilder.append(" Operation successfully. Result Code : ");
            stringBuilder.append(result.ResultCode);
        }
        else
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        //show result
        System.out.println(ex);
    }

    return stringBuilder.toString();
}
Version
API: v2.8 URL:https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
See also