Phone sales support +39 0575 05077
  Phone technical support +39 0575 0508
 
Computing > 4 - Advanced manipulation of the items > Set a Virtual Switch to a Cloud Server

4.1.16 Set a Virtual Switch to a Cloud Server

By using the Aruba WsEndUser method SetEnqueueAssociateVLan it is possible to assign a VLAN to a specified network adapter.

Parameters
vLanResourceId
Type: int
Value of type int which is the unique identifier of the VLAN
networkAdapterId
Type: int
Value of type int which is the unique identifier of the network adapter

setOnVirtualMachine
Type: bool
Value of type bool that, if "true", it applies the new configuration directly on the Virtual Machine as well as save it on database if the parameter ExtraControl is active on the server.


private static void AssociateVLan(WsEndUserClient client,
    int vLanResourceId, int networkAdapterId, bool setOnVirtualMachine)
{
    //specify the account login details 
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";

    try
    {
        // create the object SetVlanRequest for the request 
        //with data to process
        SetVlanRequest request = new SetVlanRequest();
        request.NetworkAdapterId = networkAdapterId;
        request.VLanResourceId = vLanResourceId;
        request.SetOnVirtualMachine = setOnVirtualMachine;

        //call method SetEnqueueAssociateVLan, 
        //obtaining a WsResult item
        WsResult result = client.SetEnqueueAssociateVLan(request);

        //if the call is not successful, re-run the error indicating the message
        if (!result.Success)
            throw new ApplicationException(result.ResultMessage);
    }
    catch (Exception ex)
    {
        // re-run the error
        throw new ApplicationException(ex.Message);
    }
}
// IWsEndUser.associateVLan Method (JAVA)
private static void associateVLan(IWsEndUser client, 
    int vLanResourceId, int networkAdapterId, boolean setOnVirtualMachine)
{
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
    .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
    .put(BindingProvider.PASSWORD_PROPERTY, "1234567890");

    try
    {
        //create the object SetVlanRequest for the request 
        //with data to process
        SetVlanRequest request = new SetVlanRequest();
        request.setNetworkAdapterId(networkAdapterId );
        request.setVLanResourceId(vLanResourceId);
        request.setSetOnVirtualMachine(setOnVirtualMachine);

        //call method setEnqueueAssociateVLan, 
        //obtaining a WsResult item
        WsResult result = client.setEnqueueAssociateVLan(request);

        //if the call is not successful, re-run the error indicating the message
        if (!result.isSuccess())
            throw new Exception(result.getResultMessage());
    }
    catch (Exception ex)
    {
        //show error
        System.out.println(ex);
    }
}
Version
API: v2.8 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
See also