Override getRootDir in LocalNfsSecondaryStorageResource to make mount

successfully on MS side. Now S3 is working.
This commit is contained in:
Min Chen 2013-05-12 17:38:33 -07:00
parent e8259e38c2
commit 0b9e0c0f3a
6 changed files with 36 additions and 2 deletions

View File

@ -56,6 +56,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-secondary-storage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${cs.mysql.version}</version>

View File

@ -11,7 +11,7 @@
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.storage;

View File

@ -82,6 +82,7 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
@Inject
StoragePoolHostDao poolHostDao;
@Inject
private VolumeDao volumeDao;
public PrimaryDataStoreImpl() {

View File

@ -43,6 +43,7 @@ import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupStorageCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.UploadAnswer;
import com.cloud.agent.api.storage.UploadCommand;
import com.cloud.agent.api.storage.UploadProgressCommand;
@ -56,6 +57,7 @@ import com.cloud.storage.Upload.Status;
import com.cloud.storage.Upload.Type;
import com.cloud.storage.UploadVO;
import com.cloud.storage.dao.UploadDao;
import com.cloud.storage.download.DownloadListener;
import com.cloud.storage.upload.UploadState.UploadEvent;
import com.cloud.utils.exception.CloudRuntimeException;
@ -475,6 +477,10 @@ public class UploadListener implements Listener {
@Override
public void complete(Answer answer) {
listener.processAnswers(id, -1, new Answer[] {answer});
if (listener instanceof DownloadListener) {
DownloadListener dwldListener = (DownloadListener)listener;
dwldListener.getCallback().complete((DownloadAnswer)answer);
}
}
}
}

View File

@ -6,12 +6,14 @@ import static java.util.Arrays.asList;
import java.io.File;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
import org.apache.cloudstack.storage.command.DownloadSystemTemplateCommand;
@ -112,6 +114,26 @@ public class LocalNfsSecondaryStorageResource extends NfsSecondaryStorageResourc
}
}
@Override
synchronized public String getRootDir(String secUrl) {
try {
URI uri = new URI(secUrl);
String nfsHost = uri.getHost();
InetAddress nfsHostAddr = InetAddress.getByName(nfsHost);
String nfsHostIp = nfsHostAddr.getHostAddress();
String nfsPath = nfsHostIp + ":" + uri.getPath();
String dir = UUID.nameUUIDFromBytes(nfsPath.getBytes()).toString();
String root = _parent + "/" + dir;
mount(root, nfsPath);
return root;
} catch (Exception e) {
String msg = "GetRootDir for " + secUrl + " failed due to " + e.toString();
s_logger.error(msg, e);
throw new CloudRuntimeException(msg);
}
}
@Override
protected String mount(String root, String nfsPath) {
File file = new File(root);

View File

@ -158,7 +158,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
private String _storageNetmask;
private String _storageGateway;
private final List<String> nfsIps = new ArrayList<String>();
private String _parent = "/mnt/SecStorage";
protected String _parent = "/mnt/SecStorage";
final private String _tmpltDir = "/var/cloudstack/template";
final private String _tmpltpp = "template.properties";
private String createTemplateFromSnapshotXenScript;