add more files

This commit is contained in:
Edison Su 2012-11-01 17:20:51 -07:00
parent 7397716fcd
commit 37c95dd11a
11 changed files with 292 additions and 159 deletions

View File

@ -1,65 +0,0 @@
package org.apache.cloudstack.storage.datastoreconfigurator;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
import org.apache.cloudstack.platform.subsystem.api.storage.DataStoreConfigurator;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.Storage.StoragePoolType;
public abstract class NfsDataStoreConfigurator implements DataStoreConfigurator {
private enum NfsConfigName {
SERVER,
PORT,
PATH;
}
public NfsDataStoreConfigurator() {
}
public String getProtocol() {
return "NFS";
}
public Map<String, String> getConfigs(URI uri, Map<String, String> extras) {
Map<String, String> configs = new HashMap<String, String>();
String storageHost = uri.getHost();
String hostPath = uri.getPath();
configs.put(NfsConfigName.SERVER.toString(), storageHost);
configs.put(NfsConfigName.PATH.toString(), hostPath);
configs.putAll(extras);
return configs;
}
public List<String> getConfigNames() {
List<String> names = new ArrayList<String>();
names.add(NfsConfigName.SERVER.toString());
names.add(NfsConfigName.PATH.toString());
return names;
}
public boolean validate(Map<String, String> configs) {
String uriHost = configs.get(NfsConfigName.SERVER.toString());
String uriPath = configs.get(NfsConfigName.PATH.toString());
if (uriHost == null || uriPath == null || uriHost.trim().isEmpty() || uriPath.trim().isEmpty()) {
throw new InvalidParameterValueException("host or path is null, should be nfs://hostname/path");
}
return true;
}
public DataStore getDataStore(StoragePool pool) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,55 +0,0 @@
/*
* 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.datastoreconfigurator;
import java.util.Map;
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
import org.apache.cloudstack.storage.datastore.DefaultDataStore;
import org.apache.cloudstack.storage.driver.DefaultNfsSecondaryDriver;
import org.apache.cloudstack.storage.epselector.DefaultNfsSecondaryEndPointSelector;
import org.apache.cloudstack.storage.lifecycle.DefaultNfsSecondaryLifeCycle;
import org.apache.cloudstack.storage.strategy.DefaultTemplateStratey;
import com.cloud.storage.StoragePool;
public class NfsSecondaryStorageConfigurator extends NfsDataStoreConfigurator {
@Override
public DataStore getDataStore(StoragePool pool) {
DefaultDataStore ds = new DefaultDataStore();
ds.setEndPointSelector(new DefaultNfsSecondaryEndPointSelector(ds));
ds.setId(pool.getId());
ds.setType(StoreType.Image);
ds.setURI(pool.getHostAddress() + "/" + pool.getPath());
ds.setUUID(pool.getUuid());
ds.setDataStoreDriver(new DefaultNfsSecondaryDriver(ds));
ds.setTemplateStrategy(new DefaultTemplateStratey(ds));
ds.setLifeCycle(new DefaultNfsSecondaryLifeCycle(ds));
return ds;
}
public StoragePool getStoragePool(Map<String, String> configs) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,38 +0,0 @@
package org.apache.cloudstack.storage.datastoreconfigurator;
import java.util.Map;
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore;
import org.apache.cloudstack.platform.subsystem.api.storage.DataStore.StoreType;
import org.apache.cloudstack.storage.datastore.DefaultDataStore;
import org.apache.cloudstack.storage.driver.XenServerStorageDriver;
import org.apache.cloudstack.storage.epselector.DefaultPrimaryEndpointSelector;
import org.apache.cloudstack.storage.lifecycle.DefaultPrimaryDataStoreLifeCycle;
import org.apache.cloudstack.storage.strategy.XenBackupStrategy;
import org.apache.cloudstack.storage.strategy.XenSnapshotStrategy;
import org.apache.cloudstack.storage.strategy.DefaultVolumeStrategy;
import com.cloud.storage.StoragePool;
public class XenNfsDataStoreConfigurator extends NfsDataStoreConfigurator {
@Override
public DataStore getDataStore(StoragePool pool) {
DefaultDataStore ds = new DefaultDataStore();
ds.setEndPointSelector(new DefaultPrimaryEndpointSelector(ds));
ds.setId(pool.getId());
ds.setType(StoreType.Primary);
ds.setURI(pool.getHostAddress() + "/" + pool.getPath());
ds.setUUID(pool.getUuid());
ds.setDataStoreDriver(new XenServerStorageDriver(ds));
ds.setBackupStrategy(new XenBackupStrategy(ds));
ds.setVolumeStrategy(new DefaultVolumeStrategy(ds));
ds.setSnapshotStrategy(new XenSnapshotStrategy(ds));
ds.setLifeCycle(new DefaultPrimaryDataStoreLifeCycle(ds));
return ds;
}
public StoragePool getStoragePool(Map<String, String> configs) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,71 @@
/*
* 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;
public class ImageServiceImpl implements ImageService {
@Override
public long registerTemplate(String templateUrl, long accountId) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean deleteTemplate(long templateId) {
// TODO Auto-generated method stub
return false;
}
@Override
public long registerIso(String isoUrl, long accountId) {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean deleteIso(long isoId) {
// TODO Auto-generated method stub
return false;
}
@Override
public String grantTemplateAccess(long templateId, long endpointId) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean revokeTemplateAccess(long templateId, long endpointId) {
// TODO Auto-generated method stub
return false;
}
@Override
public String grantIsoAccess(long isoId, long endpointId) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean revokeIsoAccess(long isoId, long endpointId) {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -0,0 +1,31 @@
/*
* 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;
import org.apache.cloudstack.storage.image.db.ImageDataVO;
import org.apache.cloudstack.storage.image.store.ImageDataStore;
public class Template {
protected ImageDataVO imageVO;
protected ImageDataStore dataStore;
public Template(ImageDataStore dataStore, ImageDataVO imageVO) {
this.dataStore = dataStore;
this.imageVO = imageVO;
}
}

View File

@ -0,0 +1,28 @@
/*
* 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.driver;
import org.apache.cloudstack.storage.image.Template;
public interface ImageDataStoreDriver {
boolean registerTemplate(Template template);
String grantAccess(long templateId, long endPointId);
boolean revokeAccess(long templateId, long endPointId);
boolean deleteTemplate(Template template);
}

View File

@ -0,0 +1,51 @@
/*
* 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.driver;
import org.apache.cloudstack.storage.image.Template;
public class ImageDataStoreDriverImpl implements ImageDataStoreDriver {
@Override
public boolean registerTemplate(Template template) {
// TODO Auto-generated method stub
return false;
}
@Override
public String grantAccess(long templateId, long endPointId) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean revokeAccess(long templateId, long endPointId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean deleteTemplate(Template template) {
// TODO Auto-generated method stub
return false;
}
}

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.manager;
import org.apache.cloudstack.storage.image.store.ImageDataStore;
public interface ImageDataStoreManager {
ImageDataStore getImageDataStore(long dataStoreId);
}

View File

@ -0,0 +1,31 @@
/*
* 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.manager;
import org.apache.cloudstack.storage.image.store.ImageDataStore;
public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
@Override
public ImageDataStore getImageDataStore(long dataStoreId) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -18,6 +18,11 @@
*/
package org.apache.cloudstack.storage.image.store;
import org.apache.cloudstack.storage.image.Template;
public interface ImageDataStore {
Template registerTemplate(long templateId);
String grantAccess(long templateId, long endPointId);
boolean revokeAccess(long templateId, long endPointId);
boolean deleteTemplate(long templateId);
}

View File

@ -0,0 +1,49 @@
/*
* 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.store;
import org.apache.cloudstack.storage.image.Template;
public class ImageDataStoreImpl implements ImageDataStore {
@Override
public Template registerTemplate(long templateId) {
// TODO Auto-generated method stub
return null;
}
@Override
public String grantAccess(long templateId, long endPointId) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean revokeAccess(long templateId, long endPointId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean deleteTemplate(long templateId) {
// TODO Auto-generated method stub
return false;
}
}