From 3aa9a312b45604c8b9003e3306ab449014ad4d40 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Thu, 12 Jan 2012 15:17:27 -0800 Subject: [PATCH] seems netapp part of code is missing due to merge Revert "bug 10837: rename api related to netapp" This reverts commit 5db6b500dd1bbb96bfddbd7eda6cf1f616e2e0f9. Conflicts: api/src/com/cloud/api/commands/MigrateVolumeCmd.java client/tomcatconf/commands-ext.properties.in --- client/tomcatconf/commands-ext.properties.in | 13 ++ .../netapp/CreateVolumeOnFilerCmd.java | 163 ++++++++++++++++++ .../commands/netapp/CreateVolumePoolCmd.java | 101 +++++++++++ .../commands/netapp/DeleteVolumePoolCmd.java | 93 ++++++++++ .../netapp/DestroyVolumeOnFilerCmd.java | 104 +++++++++++ .../commands/netapp/ListVolumePoolsCmd.java | 101 +++++++++++ .../netapp/ListVolumesOnFilerCmd.java | 111 ++++++++++++ .../commands/netapp/ModifyVolumePoolCmd.java | 90 ++++++++++ .../CreateVolumeOnFilerCmdResponse.java | 6 + .../netapp/CreateVolumePoolCmdResponse.java | 6 + .../DeleteVolumeOnFilerCmdResponse.java | 9 + .../netapp/DeleteVolumePoolCmdResponse.java | 6 + .../netapp/ListVolumePoolsCmdResponse.java | 42 +++++ .../netapp/ListVolumesOnFilerCmdResponse.java | 98 +++++++++++ .../netapp/ModifyVolumePoolCmdResponse.java | 9 + 15 files changed, 952 insertions(+) create mode 100644 server/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java create mode 100644 server/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java create mode 100644 server/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java create mode 100644 server/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java create mode 100644 server/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java create mode 100644 server/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java create mode 100644 server/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java create mode 100644 server/src/com/cloud/server/api/response/netapp/CreateVolumeOnFilerCmdResponse.java create mode 100644 server/src/com/cloud/server/api/response/netapp/CreateVolumePoolCmdResponse.java create mode 100644 server/src/com/cloud/server/api/response/netapp/DeleteVolumeOnFilerCmdResponse.java create mode 100644 server/src/com/cloud/server/api/response/netapp/DeleteVolumePoolCmdResponse.java create mode 100644 server/src/com/cloud/server/api/response/netapp/ListVolumePoolsCmdResponse.java create mode 100644 server/src/com/cloud/server/api/response/netapp/ListVolumesOnFilerCmdResponse.java create mode 100644 server/src/com/cloud/server/api/response/netapp/ModifyVolumePoolCmdResponse.java diff --git a/client/tomcatconf/commands-ext.properties.in b/client/tomcatconf/commands-ext.properties.in index 1b1f91d892c..565a61d786f 100644 --- a/client/tomcatconf/commands-ext.properties.in +++ b/client/tomcatconf/commands-ext.properties.in @@ -23,3 +23,16 @@ addTrafficMonitor=com.cloud.api.commands.AddTrafficMonitorCmd;1 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 +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 diff --git a/server/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java b/server/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java new file mode 100644 index 00000000000..d4e02707c37 --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java @@ -0,0 +1,163 @@ +/** + * * 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 . + * + * + * 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 . + * + * @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.CreateVolumeOnFilerCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="Create a volume", responseObject = CreateVolumeOnFilerCmdResponse.class) +public class CreateVolumeOnFilerCmd 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); + CreateVolumeOnFilerCmdResponse response = new CreateVolumeOnFilerCmdResponse(); + 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; + } + +} diff --git a/server/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java b/server/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java new file mode 100644 index 00000000000..0b9a92cb45b --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java @@ -0,0 +1,101 @@ +/** + * * 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 . + * + * + * 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 . + * + *@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.CreateVolumePoolCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="Create a pool", responseObject = CreateVolumePoolCmdResponse.class) +public class CreateVolumePoolCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(CreateVolumePoolCmd.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 { + CreateVolumePoolCmdResponse response = new CreateVolumePoolCmdResponse(); + 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; + } + +} diff --git a/server/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java b/server/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java new file mode 100644 index 00000000000..29a6a473dc7 --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java @@ -0,0 +1,93 @@ +/** + * * 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 . + * + * + * 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 . + * + *@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.DeleteVolumePoolCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="Delete a pool", responseObject = DeleteVolumePoolCmdResponse.class) +public class DeleteVolumePoolCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(DeleteVolumePoolCmd.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); + DeleteVolumePoolCmdResponse response = new DeleteVolumePoolCmdResponse(); + 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; + } + +} diff --git a/server/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java b/server/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java new file mode 100644 index 00000000000..bef8bedeea3 --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java @@ -0,0 +1,104 @@ +/** + * * 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 . + * + * + * 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 . + * + * @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.DeleteVolumeOnFilerCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="Destroy a Volume", responseObject = DeleteVolumeOnFilerCmdResponse.class) +public class DestroyVolumeOnFilerCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(DestroyVolumeOnFilerCmd.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); + DeleteVolumeOnFilerCmdResponse response = new DeleteVolumeOnFilerCmdResponse(); + 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; + } + +} \ No newline at end of file diff --git a/server/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java b/server/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java new file mode 100644 index 00000000000..6f389a2d10e --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java @@ -0,0 +1,101 @@ +/** + * * 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 . + * + * + * 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 . + * + *@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.ListVolumePoolsCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="List Pool", responseObject = ListVolumePoolsCmdResponse.class) +public class ListVolumePoolsCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(ListVolumePoolsCmd.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 poolList = netappMgr.listPools(); + ListResponse listResponse = new ListResponse(); + List responses = new ArrayList(); + for (PoolVO pool : poolList) { + ListVolumePoolsCmdResponse response = new ListVolumePoolsCmdResponse(); + 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; + } + +} diff --git a/server/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java b/server/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java new file mode 100644 index 00000000000..495d8e13d74 --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java @@ -0,0 +1,111 @@ +/** + * * 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 . + * + * + * 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 . + * + *@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.ListVolumesOnFilerCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="List Volumes", responseObject = ListVolumesOnFilerCmdResponse.class) +public class ListVolumesOnFilerCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(ListVolumesOnFilerCmd.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 volumes = netappMgr.listVolumesOnFiler(poolName); + ListResponse listResponse = new ListResponse(); + List responses = new ArrayList(); + for (NetappVolumeVO volume : volumes) { + ListVolumesOnFilerCmdResponse response = new ListVolumesOnFilerCmdResponse(); + 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; + } + +} \ No newline at end of file diff --git a/server/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java b/server/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java new file mode 100644 index 00000000000..50033166f65 --- /dev/null +++ b/server/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java @@ -0,0 +1,90 @@ +/** + * * 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 . + * + * + * 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 . + * + *@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.ModifyVolumePoolCmdResponse; +import com.cloud.utils.component.ComponentLocator; + +@Implementation(description="Modify pool", responseObject = ModifyVolumePoolCmdResponse.class) +public class ModifyVolumePoolCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(ModifyVolumePoolCmd.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); + + ModifyVolumePoolCmdResponse response = new ModifyVolumePoolCmdResponse(); + 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; + } + +} diff --git a/server/src/com/cloud/server/api/response/netapp/CreateVolumeOnFilerCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/CreateVolumeOnFilerCmdResponse.java new file mode 100644 index 00000000000..730717e5048 --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/CreateVolumeOnFilerCmdResponse.java @@ -0,0 +1,6 @@ +package com.cloud.server.api.response.netapp; + +import com.cloud.api.response.BaseResponse; + +public class CreateVolumeOnFilerCmdResponse extends BaseResponse { +} diff --git a/server/src/com/cloud/server/api/response/netapp/CreateVolumePoolCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/CreateVolumePoolCmdResponse.java new file mode 100644 index 00000000000..29ce7f9b3a4 --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/CreateVolumePoolCmdResponse.java @@ -0,0 +1,6 @@ +package com.cloud.server.api.response.netapp; + +import com.cloud.api.response.BaseResponse; + +public class CreateVolumePoolCmdResponse extends BaseResponse{ +} diff --git a/server/src/com/cloud/server/api/response/netapp/DeleteVolumeOnFilerCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/DeleteVolumeOnFilerCmdResponse.java new file mode 100644 index 00000000000..ab4465c8c64 --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/DeleteVolumeOnFilerCmdResponse.java @@ -0,0 +1,9 @@ +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 DeleteVolumeOnFilerCmdResponse extends BaseResponse { +} diff --git a/server/src/com/cloud/server/api/response/netapp/DeleteVolumePoolCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/DeleteVolumePoolCmdResponse.java new file mode 100644 index 00000000000..13268602018 --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/DeleteVolumePoolCmdResponse.java @@ -0,0 +1,6 @@ +package com.cloud.server.api.response.netapp; + +import com.cloud.api.response.BaseResponse; + +public class DeleteVolumePoolCmdResponse extends BaseResponse { +} diff --git a/server/src/com/cloud/server/api/response/netapp/ListVolumePoolsCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/ListVolumePoolsCmdResponse.java new file mode 100644 index 00000000000..2abd6b3da70 --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/ListVolumePoolsCmdResponse.java @@ -0,0 +1,42 @@ +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 ListVolumePoolsCmdResponse 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; + } +} diff --git a/server/src/com/cloud/server/api/response/netapp/ListVolumesOnFilerCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/ListVolumesOnFilerCmdResponse.java new file mode 100644 index 00000000000..155e75406f6 --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/ListVolumesOnFilerCmdResponse.java @@ -0,0 +1,98 @@ +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 ListVolumesOnFilerCmdResponse 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; + } + +} + diff --git a/server/src/com/cloud/server/api/response/netapp/ModifyVolumePoolCmdResponse.java b/server/src/com/cloud/server/api/response/netapp/ModifyVolumePoolCmdResponse.java new file mode 100644 index 00000000000..99f954075bd --- /dev/null +++ b/server/src/com/cloud/server/api/response/netapp/ModifyVolumePoolCmdResponse.java @@ -0,0 +1,9 @@ +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 ModifyVolumePoolCmdResponse extends BaseResponse { +}