add more files

This commit is contained in:
Edison Su 2012-11-02 17:44:28 -07:00
parent 37c95dd11a
commit 7c9e30a6ea
16 changed files with 325 additions and 12 deletions

View File

@ -19,7 +19,7 @@
package org.apache.cloudstack.storage.image;
public interface ImageService {
long registerTemplate(String templateUrl, long accountId);
boolean registerTemplate(long templateId, long imageStoreId);
boolean deleteTemplate(long templateId);
long registerIso(String isoUrl, long accountId);
boolean deleteIso(long isoId);

View File

@ -18,12 +18,25 @@
*/
package org.apache.cloudstack.storage.image;
import javax.inject.Inject;
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
import org.apache.cloudstack.storage.image.manager.ImageDataStoreManager;
import org.apache.cloudstack.storage.image.store.ImageDataStore;
public class ImageServiceImpl implements ImageService {
@Inject
ImageDataStoreManager imageStoreMgr;
@Override
public long registerTemplate(String templateUrl, long accountId) {
// TODO Auto-generated method stub
return 0;
public boolean registerTemplate(long templateId, long imageStoreId) {
ImageDataStore ids = imageStoreMgr.getImageDataStore(imageStoreId);
Template template = ids.registerTemplate(templateId);
if (ids.needDownloadToCacheStorage()) {
ImageDownloader imageDl = ids.getImageDownloader();
imageDl.downloadImage(template);
}
return true;
}
@Override

View File

@ -28,4 +28,11 @@ public class Template {
this.dataStore = dataStore;
this.imageVO = imageVO;
}
public ImageDataStore getImageDataStore() {
return this.dataStore;
}
public String getTemplate
}

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.db;
import com.cloud.utils.db.GenericDao;
public interface ImageDaoStoreDao extends GenericDao<ImageDataStoreVO, Long> {
}

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.db;
import com.cloud.utils.db.GenericDaoBase;
public class ImageDaoStoreDaoImpl extends GenericDaoBase<ImageDataStoreVO, Long> implements ImageDaoStoreDao {
}

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.db;
import com.cloud.utils.db.GenericDao;
public interface ImageDataStoreProviderDao extends GenericDao<ImageDataStoreProviderVO, Long> {
}

View File

@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.db;
import com.cloud.utils.db.GenericDaoBase;
public class ImageDataStoreProviderDaoImpl extends GenericDaoBase<ImageDataStoreProviderVO, Long> implements ImageDataStoreProviderDao {
}

View File

@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.platform.subsystem.api.storage;
package org.apache.cloudstack.storage.image.db;
public interface Template extends DataObject {
public interface ImageDataStoreProviderVO {
}

View File

@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.db;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
@Entity
@Table(name="image_data_store")
public class ImageDataStoreVO {
@Id
@TableGenerator(name="image_data_store_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="image_data_store_seq", allocationSize=1)
@Column(name="id", nullable = false)
private long id;
@Column(name="name", nullable = false)
private String name;
@Column(name="image_provider", nullable = false)
private long provider;
public long getId() {
return this.id;
}
public String getName() {
return this.name;
}
public long getProvider() {
return this.provider;
}
public void setName(String name) {
this.name = name;
}
public void setProvider(long provider) {
this.provider = provider;
}
}

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.downloader;
import org.apache.cloudstack.storage.image.Template;
public interface ImageDownloader {
public void downloadImage(Template template);
}

View File

@ -24,8 +24,8 @@ public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
@Override
public boolean registerTemplate(Template template) {
// TODO Auto-generated method stub
return false;
//TODO: check the availability of template
return true;
}
@Override

View File

@ -18,12 +18,22 @@
*/
package org.apache.cloudstack.storage.image.manager;
import javax.inject.Inject;
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
import org.apache.cloudstack.storage.image.db.ImageDaoStoreDao;
import org.apache.cloudstack.storage.image.db.ImageDataDao;
import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
import org.apache.cloudstack.storage.image.store.ImageDataStore;
public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
@Inject
ImageDaoStoreDao dataStoreDao;
@Inject
ImageDataDao imageDataDao;
@Override
public ImageDataStore getImageDataStore(long dataStoreId) {
ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
// TODO Auto-generated method stub
return null;
}

View File

@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.provider;
public interface ImageDataStoreProviderManager {
public ImageDataStoreProvider getProvider(long providerId);
}

View File

@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.image.provider;
import javax.inject.Inject;
import org.apache.cloudstack.storage.image.db.ImageDataStoreProviderDao;
public class ImageDataStoreProviderManagerImpl implements ImageDataStoreProviderManager {
@Inject
ImageDataStoreProviderDao providerDao;
@Override
public ImageDataStoreProvider getProvider(long providerId) {
return null;
}
}

View File

@ -19,10 +19,13 @@
package org.apache.cloudstack.storage.image.store;
import org.apache.cloudstack.storage.image.Template;
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
public interface ImageDataStore {
Template registerTemplate(long templateId);
String grantAccess(long templateId, long endPointId);
boolean revokeAccess(long templateId, long endPointId);
boolean deleteTemplate(long templateId);
boolean needDownloadToCacheStorage();
ImageDownloader getImageDownloader();
}

View File

@ -18,14 +18,37 @@
*/
package org.apache.cloudstack.storage.image.store;
import javax.inject.Inject;
import org.apache.cloudstack.storage.image.Template;
import org.apache.cloudstack.storage.image.db.ImageDataDao;
import org.apache.cloudstack.storage.image.db.ImageDataVO;
import org.apache.cloudstack.storage.image.downloader.ImageDownloader;
import org.apache.cloudstack.storage.image.driver.ImageDataStoreDriver;
public class ImageDataStoreImpl implements ImageDataStore {
@Inject
ImageDataDao imageDao;
ImageDataStoreDriver driver;
ImageDownloader downloader;
boolean needDownloadToCacheStorage = false;
public ImageDataStoreImpl(ImageDataStoreDriver driver, boolean needDownloadToCacheStorage, ImageDownloader downloader) {
this.driver = driver;
this.needDownloadToCacheStorage = needDownloadToCacheStorage;
this.downloader = downloader;
}
@Override
public Template registerTemplate(long templateId) {
// TODO Auto-generated method stub
return null;
ImageDataVO idv = imageDao.findById(templateId);
Template template = new Template(this, idv);
if (driver.registerTemplate(template)) {
return template;
} else {
return null;
}
}
@Override
@ -46,4 +69,15 @@ public class ImageDataStoreImpl implements ImageDataStore {
return false;
}
@Override
public boolean needDownloadToCacheStorage() {
// TODO Auto-generated method stub
return false;
}
@Override
public ImageDownloader getImageDownloader() {
return this.downloader;
}
}