Informazioni commerciali +39 0575 05077
  Assistenza telefonica +39 0575 0508
 
Computing > 6 - Manipolazione Schedulazioni > Aggiungere una operazione singola

6.2 Aggiungere una operazione singola

Tramite il metodo SetAddServerScheduledOperation è possibile aggiungere un'operazione schedulata.

Parametri
serverId
Type: int
Oggetto di int che indica il server a cui la richiesta si riferisce

operationType
Type: ScheduledOperationTypes
Oggetto di ScheduledOperationTypes che indica il tipo di operazione. Operazioni possibili sono:
  • StartVirtualMachine
  • StopVirtualMachine
  • ShutdownVirtualMachine
  • UpdateVirtualMachine
  • CreateSnapshot
  • RestoreSnapShot
  • DeleteSnapshot

operationLabel
Type: string
Oggetto di tipo string che indica una etichetta da assegnare all'operazione

dateStart
Type: DateTime
Oggetto di tipo DateTime che contiene la data di inzio dell'intervallo temporale

dateEnd
Type: DateTime
Oggetto di tipo DateTime che contiene la data finale dell'intervallo temporale

operationParameters
Type: OperationParameters[]
Array di OperationParameters contententi i parametri da inviare all'operazione da avviare.


/// IWsEndUser.SetAddServerScheduledOperation Method (c# .NET)
public static string SetAddServerScheduledOperation(WsEndUserClient client,
        int serverId, ScheduledOperationTypes operationType, string operationLabel,
        DateTime dateStart, DateTime dateEnd, OperationParameters[] operationParameters)
{
    //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 = ScheduleFrequencyType.RunOnce;
        plan.ScheduledPlanStatus = ScheduledPlanStatus.Enabled;
        plan.ScheduledMontlyRecurrence = ScheduledMontlyRecurrence.FirstDay;

        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, 
        ArrayOfOperationParameters operationParameters)
{
    //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(ScheduleFrequencyType.RUN_ONCE);
        plan.setScheduledPlanStatus(ScheduledPlanStatus.ENABLED);
        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();
}
Versione
API: v2.8 URL:https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
Vedi anche




Bookmark and Share