bug 10837: rename api related to netapp

status 10837: resolved fixed
This commit is contained in:
Edison Su 2011-10-26 17:37:04 -07:00
parent 3f7ce01f28
commit 4c1a2f50bd
17 changed files with 11 additions and 951 deletions

View File

@ -3,19 +3,17 @@ package com.cloud.api.commands;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.VolumeResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.storage.Volume;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
@Implementation(description="Migrate volume", responseObject=VolumeResponse.class)
public class MigrateVolumeCmd extends BaseAsyncCmd {
private static final String s_name = "migratevolumeresponse";

View File

@ -24,15 +24,15 @@ deleteTrafficMonitor=com.cloud.api.commands.DeleteTrafficMonitorCmd;1
listTrafficMonitors=com.cloud.api.commands.ListTrafficMonitorsCmd;1
####Netapp integration commands
createVolumeOnFiler=com.cloud.api.commands.netapp.CreateVolumeCmd;15
destroyVolumeOnFiler=com.cloud.api.commands.netapp.DestroyVolumeCmd;15
listVolumesOnFiler=com.cloud.api.commands.netapp.ListVolumesCmd;15
createVolumeOnFiler=com.cloud.api.commands.netapp.CreateVolumeOnFilerCmd;15
destroyVolumeOnFiler=com.cloud.api.commands.netapp.DestroyVolumeOnFilerCmd;15
listVolumesOnFiler=com.cloud.api.commands.netapp.ListVolumesOnFilerCmd;15
createLunOnFiler=com.cloud.api.commands.netapp.CreateLunCmd;15
destroyLunOnFiler=com.cloud.api.commands.netapp.DestroyLunCmd;15
listLunsOnFiler=com.cloud.api.commands.netapp.ListLunsCmd;15
associateLun=com.cloud.api.commands.netapp.AssociateLunCmd;15
dissociateLun=com.cloud.api.commands.netapp.DissociateLunCmd;15
createPool=com.cloud.api.commands.netapp.CreatePoolCmd;15
deletePool=com.cloud.api.commands.netapp.DeletePoolCmd;15
modifyPool=com.cloud.api.commands.netapp.ModifyPoolCmd;15
listPools=com.cloud.api.commands.netapp.ListPoolsCmd;15
createVolumePool=com.cloud.api.commands.netapp.CreateVolumePoolCmd;15
deleteVolumePool=com.cloud.api.commands.netapp.DeleteVolumePoolCmd;15
modifyVolumePool=com.cloud.api.commands.netapp.ModifyVolumePoolCmd;15
listVolumePools=com.cloud.api.commands.netapp.ListVolumePoolsCmd;15

View File

@ -198,6 +198,7 @@ createVolume=com.cloud.api.commands.CreateVolumeCmd;15
deleteVolume=com.cloud.api.commands.DeleteVolumeCmd;15
listVolumes=com.cloud.api.commands.ListVolumesCmd;15
extractVolume=com.cloud.api.commands.ExtractVolumeCmd;15
migrateVolume=com.cloud.api.commands.MigrateVolumeCmd;15
#### registration command: FIXME -- this really should be something in management server that
#### generates a new key for the user and they just have to

View File

@ -1,101 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*@author-aj
*/
package com.cloud.api.commands.netapp;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.CreatePoolCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="Create a pool", responseObject = CreatePoolCmdResponse.class)
public class CreatePoolCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreatePoolCmd.class.getName());
private static final String s_name = "createpoolresponse";
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required = true, description="pool name.")
private String poolName;
@Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required = true, description="algorithm.")
private String algorithm;
public String getPoolName() {
return poolName;
}
public String getAlgorithm() {
return algorithm;
}
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
try {
CreatePoolCmdResponse response = new CreatePoolCmdResponse();
netappMgr.createPool(getPoolName(), getAlgorithm());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException e) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.toString());
}
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,163 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author-aj
*/
package com.cloud.api.commands.netapp;
import java.net.UnknownHostException;
import java.rmi.ServerException;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.CreateVolumeCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="Create a volume", responseObject = CreateVolumeCmdResponse.class)
public class CreateVolumeCmd extends BaseCmd {
private static final String s_name = "createvolumeresponse";
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, required = true, description="ip address.")
private String ipAddress;
@Parameter(name=ApiConstants.AGGREGATE_NAME, type=CommandType.STRING, required = true, description="aggregate name.")
private String aggrName;
@Parameter(name=ApiConstants.POOL_NAME, type=CommandType.STRING, required = true, description="pool name.")
private String poolName;
@Parameter(name=ApiConstants.VOLUME_NAME, type=CommandType.STRING, required = true, description="volume name.")
private String volName;
@Parameter(name=ApiConstants.SIZE, type=CommandType.INTEGER, required = true, description="volume size.")
private Integer volSize;
@Parameter(name=ApiConstants.SNAPSHOT_POLICY, type=CommandType.STRING, required = false, description="snapshot policy.")
private String snapshotPolicy;
@Parameter(name=ApiConstants.SNAPSHOT_RESERVATION, type=CommandType.INTEGER, required = false, description="snapshot reservation.")
private Integer snapshotReservation;
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="user name.")
private String userName;
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required = true, description="password.")
private String password;
public String getIpAddress() {
return ipAddress;
}
public String getAggrName() {
return aggrName;
}
public String getPoolName() {
return poolName;
}
public String volName() {
return volName;
}
public Integer getVolSize() {
return volSize;
}
public String getSnapshotPolicy() {
return snapshotPolicy;
}
public Integer getSnapshotReservation() {
return snapshotReservation;
}
public String getUserName() {
return userName;
}
public String getPassword() {
return password;
}
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
//param checks
if(snapshotReservation != null && (snapshotReservation<0 || snapshotReservation>100))
throw new InvalidParameterValueException("Invalid snapshot reservation");
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
StringBuilder s = new StringBuilder(getVolSize().toString());
s.append("g");
try {
netappMgr.createVolumeOnFiler(ipAddress, aggrName, poolName, volName, s.toString(), snapshotPolicy, snapshotReservation, userName, password);
CreateVolumeCmdResponse response = new CreateVolumeCmdResponse();
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (ServerException e) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.toString());
} catch (InvalidParameterValueException e) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.toString());
} catch (UnknownHostException e) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.toString());
}
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,93 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*@author-aj
*/
package com.cloud.api.commands.netapp;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.DeletePoolCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="Delete a pool", responseObject = DeletePoolCmdResponse.class)
public class DeletePoolCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName());
private static final String s_name = "deletepoolresponse";
@Parameter(name=ApiConstants.POOL_NAME, type=CommandType.STRING, required = true, description="pool name.")
private String poolName;
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
try {
netappMgr.deletePool(poolName);
DeletePoolCmdResponse response = new DeletePoolCmdResponse();
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException e) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.toString());
} catch (ResourceInUseException e) {
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, e.toString());
}
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,104 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author-aj
*/
package com.cloud.api.commands.netapp;
import java.rmi.ServerException;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.DeleteVolumeCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="Destroy a Volume", responseObject = DeleteVolumeCmdResponse.class)
public class DestroyVolumeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DestroyVolumeCmd.class.getName());
private static final String s_name = "destroyvolumeresponse";
@Parameter(name=ApiConstants.AGGREGATE_NAME, type=CommandType.STRING, required = true, description="aggregate name.")
private String aggrName;
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, required = true, description="ip address.")
private String ipAddr;
@Parameter(name=ApiConstants.VOLUME_NAME, type=CommandType.STRING, required = true, description="volume name.")
private String volumeName;
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
try {
netappMgr.destroyVolumeOnFiler(ipAddr, aggrName, volumeName);
DeleteVolumeCmdResponse response = new DeleteVolumeCmdResponse();
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException e) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.toString());
} catch (ResourceInUseException e) {
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, e.toString());
} catch (ServerException e) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.toString());
}
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,101 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*@author-aj
*/
package com.cloud.api.commands.netapp;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ListResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.netapp.PoolVO;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.ListPoolsCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="List Pool", responseObject = ListPoolsCmdResponse.class)
public class ListPoolsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ListPoolsCmd.class.getName());
private static final String s_name = "listpoolresponse";
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
try {
List<PoolVO> poolList = netappMgr.listPools();
ListResponse<ListPoolsCmdResponse> listResponse = new ListResponse<ListPoolsCmdResponse>();
List<ListPoolsCmdResponse> responses = new ArrayList<ListPoolsCmdResponse>();
for (PoolVO pool : poolList) {
ListPoolsCmdResponse response = new ListPoolsCmdResponse();
response.setId(pool.getId());
response.setName(pool.getName());
response.setAlgorithm(pool.getAlgorithm());
response.setObjectName("pool");
responses.add(response);
}
listResponse.setResponses(responses);
listResponse.setResponseName(getCommandName());
this.setResponseObject(listResponse);
} catch (InvalidParameterValueException e) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, e.toString());
}
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,111 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*@author-aj
*/
package com.cloud.api.commands.netapp;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ListResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.netapp.NetappVolumeVO;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.ListVolumesCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="List Volumes", responseObject = ListVolumesCmdResponse.class)
public class ListVolumesCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ListVolumesCmd.class.getName());
private static final String s_name = "listvolumesresponse";
@Parameter(name=ApiConstants.POOL_NAME, type=CommandType.STRING, required = true, description="pool name.")
private String poolName;
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
try {
List<NetappVolumeVO> volumes = netappMgr.listVolumesOnFiler(poolName);
ListResponse<ListVolumesCmdResponse> listResponse = new ListResponse<ListVolumesCmdResponse>();
List<ListVolumesCmdResponse> responses = new ArrayList<ListVolumesCmdResponse>();
for (NetappVolumeVO volume : volumes) {
ListVolumesCmdResponse response = new ListVolumesCmdResponse();
response.setId(volume.getId());
response.setIpAddress(volume.getIpAddress());
response.setPoolName(volume.getPoolName());
response.setAggrName(volume.getAggregateName());
response.setVolumeName(volume.getVolumeName());
response.setSnapshotPolicy(volume.getSnapshotPolicy());
response.setSnapshotReservation(volume.getSnapshotReservation());
response.setVolumeSize(volume.getVolumeSize());
response.setObjectName("volume");
responses.add(response);
}
listResponse.setResponses(responses);
listResponse.setResponseName(getCommandName());
this.setResponseObject(listResponse);
} catch (InvalidParameterValueException e) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.toString());
}
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,90 +0,0 @@
/**
* * Copyright (C) 2011 Citrix Systems, Inc. All rights reserved
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*@author-aj
*/
package com.cloud.api.commands.netapp;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.netapp.NetappManager;
import com.cloud.server.ManagementService;
import com.cloud.server.api.response.netapp.ModifyPoolCmdResponse;
import com.cloud.utils.component.ComponentLocator;
@Implementation(description="Modify pool", responseObject = ModifyPoolCmdResponse.class)
public class ModifyPoolCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ModifyPoolCmd.class.getName());
private static final String s_name = "modifypoolresponse";
@Parameter(name=ApiConstants.POOL_NAME, type=CommandType.STRING, required = true, description="pool name.")
private String poolName;
@Parameter(name=ApiConstants.ALGORITHM, type=CommandType.STRING, required = true, description="algorithm.")
private String algorithm;
@Override
public void execute() throws ResourceUnavailableException,
InsufficientCapacityException, ServerApiException,
ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
NetappManager netappMgr = locator.getManager(NetappManager.class);
netappMgr.modifyPool(poolName, algorithm);
ModifyPoolCmdResponse response = new ModifyPoolCmdResponse();
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
@Override
public String getCommandName() {
// TODO Auto-generated method stub
return s_name;
}
@Override
public long getEntityOwnerId() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -1,6 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.response.BaseResponse;
public class CreatePoolCmdResponse extends BaseResponse{
}

View File

@ -1,6 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.response.BaseResponse;
public class CreateVolumeCmdResponse extends BaseResponse {
}

View File

@ -1,6 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.response.BaseResponse;
public class DeletePoolCmdResponse extends BaseResponse {
}

View File

@ -1,9 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.ApiConstants;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class DeleteVolumeCmdResponse extends BaseResponse {
}

View File

@ -1,42 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.ApiConstants;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class ListPoolsCmdResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="pool id")
private Long id;
@SerializedName(ApiConstants.NAME) @Param(description="pool name")
private String name;
@SerializedName(ApiConstants.ALGORITHM) @Param(description="pool algorithm")
private String algorithm;
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getAlgorithm() {
return algorithm;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
}

View File

@ -1,98 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.ApiConstants;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class ListVolumesCmdResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="volume id")
private Long id;
@SerializedName(ApiConstants.POOL_NAME) @Param(description="pool name")
private String poolName;
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="ip address")
private String ipAddress;
@SerializedName(ApiConstants.AGGREGATE_NAME) @Param(description="Aggregate name")
private String aggrName;
@SerializedName(ApiConstants.VOLUME_NAME) @Param(description="Volume name")
private String volumeName;
@SerializedName(ApiConstants.SNAPSHOT_POLICY) @Param(description="snapshot policy")
private String snapshotPolicy;
@SerializedName(ApiConstants.SNAPSHOT_RESERVATION) @Param(description="snapshot reservation")
private Integer snapshotReservation;
@SerializedName(ApiConstants.SIZE) @Param(description="volume size")
private String volumeSize;
public Long getId() {
return id;
}
public String getPoolName() {
return poolName;
}
public String getIpAddress() {
return ipAddress;
}
public String getAggrName() {
return aggrName;
}
public String getVolumeName() {
return volumeName;
}
public String getSnapshotPolicy() {
return snapshotPolicy;
}
public Integer getSnapshotReservation() {
return snapshotReservation;
}
public String getVolumeSize() {
return volumeSize;
}
public void setId(Long id) {
this.id = id;
}
public void setPoolName(String poolName) {
this.poolName = poolName;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public void setAggrName(String aggrName) {
this.aggrName = aggrName;
}
public void setVolumeName(String volumeName) {
this.volumeName = volumeName;
}
public void setSnapshotPolicy(String snapshotPolicy) {
this.snapshotPolicy = snapshotPolicy;
}
public void setSnapshotReservation(Integer snapshotReservation) {
this.snapshotReservation = snapshotReservation;
}
public void setVolumeSize(String size) {
this.volumeSize = size;
}
}

View File

@ -1,9 +0,0 @@
package com.cloud.server.api.response.netapp;
import com.cloud.api.ApiConstants;
import com.cloud.api.response.BaseResponse;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class ModifyPoolCmdResponse extends BaseResponse {
}