Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions core/src/com/cloud/agent/api/CreateStoragePoolCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

package com.cloud.agent.api;

import com.cloud.storage.StoragePool;

import java.util.Map;

import com.cloud.storage.StoragePool;

public class CreateStoragePoolCommand extends ModifyStoragePoolCommand {
public static final String DATASTORE_NAME = "datastoreName";
public static final String IQN = "iqn";
Expand All @@ -32,9 +32,6 @@ public class CreateStoragePoolCommand extends ModifyStoragePoolCommand {
private boolean _createDatastore;
private Map<String, String> _details;

public CreateStoragePoolCommand() {
}

public CreateStoragePoolCommand(boolean add, StoragePool pool) {
super(add, pool);
}
Expand Down
37 changes: 17 additions & 20 deletions core/src/com/cloud/agent/api/ModifyStoragePoolAnswer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,41 @@
import com.cloud.storage.template.TemplateProp;

public class ModifyStoragePoolAnswer extends Answer {
StoragePoolInfo poolInfo;
Map<String, TemplateProp> templateInfo;
String localDatastoreName = null;

protected ModifyStoragePoolAnswer() {
}
private StoragePoolInfo _poolInfo;
private Map<String, TemplateProp> _templateInfo;
private String _localDatastoreName;

public ModifyStoragePoolAnswer(ModifyStoragePoolCommand cmd, long capacityBytes, long availableBytes, Map<String, TemplateProp> tInfo) {
super(cmd);
this.result = true;
this.poolInfo =
new StoragePoolInfo(null, cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getLocalPath(), cmd.getPool().getType(), capacityBytes, availableBytes);

this.templateInfo = tInfo;
}
result = true;

public StoragePoolInfo getPoolInfo() {
return poolInfo;
_poolInfo = new StoragePoolInfo(null, cmd.getPool().getHost(), cmd.getPool().getPath(), cmd.getLocalPath(), cmd.getPool().getType(), capacityBytes, availableBytes);

_templateInfo = tInfo;
}

public void setPoolInfo(StoragePoolInfo poolInfo) {
this.poolInfo = poolInfo;
_poolInfo = poolInfo;
}

public Map<String, TemplateProp> getTemplateInfo() {
return templateInfo;
public StoragePoolInfo getPoolInfo() {
return _poolInfo;
}

public void setTemplateInfo(Map<String, TemplateProp> templateInfo) {
this.templateInfo = templateInfo;
_templateInfo = templateInfo;
}

public String getLocalDatastoreName() {
return localDatastoreName;
public Map<String, TemplateProp> getTemplateInfo() {
return _templateInfo;
}

public void setLocalDatastoreName(String localDatastoreName) {
this.localDatastoreName = localDatastoreName;
_localDatastoreName = localDatastoreName;
}

public String getLocalDatastoreName() {
return _localDatastoreName;
}
}
46 changes: 22 additions & 24 deletions core/src/com/cloud/agent/api/ModifyStoragePoolCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,51 +26,49 @@
import com.cloud.storage.StoragePool;

public class ModifyStoragePoolCommand extends Command {

boolean add;
StorageFilerTO pool;
String localPath;
String[] options;
public static final String LOCAL_PATH_PREFIX = "/mnt/";

public ModifyStoragePoolCommand() {

}
private boolean _add;
private StorageFilerTO _pool;
private String _localPath;
private String _storagePath;

public ModifyStoragePoolCommand(boolean add, StoragePool pool, String localPath) {
this.add = add;
this.pool = new StorageFilerTO(pool);
this.localPath = localPath;

_add = add;
_pool = new StorageFilerTO(pool);
_localPath = localPath;
}

public ModifyStoragePoolCommand(boolean add, StoragePool pool) {
this(add, pool, LOCAL_PATH_PREFIX + File.separator + UUID.nameUUIDFromBytes((pool.getHostAddress() + pool.getPath()).getBytes()));
}

public StorageFilerTO getPool() {
return pool;
public boolean getAdd() {
return _add;
}

public void setPool(StoragePool pool) {
this.pool = new StorageFilerTO(pool);
_pool = new StorageFilerTO(pool);
}

public boolean getAdd() {
return add;
public StorageFilerTO getPool() {
return _pool;
}

@Override
public boolean executeInSequence() {
return false;
public String getLocalPath() {
return _localPath;
}

public String getLocalPath() {
return localPath;
public void setStoragePath(String storagePath) {
_storagePath = storagePath;
}

public void setOptions(String[] options) {
this.options = options;
public String getStoragePath() {
return _storagePath;
}

@Override
public boolean executeInSequence() {
return false;
}
}
23 changes: 23 additions & 0 deletions core/src/com/cloud/agent/api/ModifyTargetsAnswer.java
Original file line number Diff line number Diff line change
@@ -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 com.cloud.agent.api;

public class ModifyTargetsAnswer extends Answer {
}
57 changes: 57 additions & 0 deletions core/src/com/cloud/agent/api/ModifyTargetsCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// 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 com.cloud.agent.api;

import java.util.List;
import java.util.Map;

public class ModifyTargetsCommand extends Command {
public static final String IQN = "iqn";
public static final String STORAGE_HOST = "storageHost";
public static final String STORAGE_PORT = "storagePort";
public static final String CHAP_NAME = "chapName";
public static final String CHAP_SECRET = "chapSecret";
public static final String MUTUAL_CHAP_NAME = "mutualChapName";
public static final String MUTUAL_CHAP_SECRET = "mutualChapSecret";

private boolean _add;
private List<Map<String, String>> _targets;

public void setAdd(boolean add) {
_add = add;
}

public boolean getAdd() {
return _add;
}

public void setTargets(List<Map<String, String>> targets) {
_targets = targets;
}

public List<Map<String, String>> getTargets() {
return _targets;
}

@Override
public boolean executeInSequence() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.cloudstack.engine.subsystem.api.storage;

import java.util.List;

import com.cloud.storage.DataStoreProviderApiService;
import com.cloud.utils.component.Manager;

Expand All @@ -29,4 +31,6 @@ public interface DataStoreProviderManager extends Manager, DataStoreProviderApiS
DataStoreProvider getDefaultImageDataStoreProvider();

DataStoreProvider getDefaultCacheDataStoreProvider();

List<DataStoreProvider> getProviders();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
import com.cloud.exception.StorageConflictException;

public interface HypervisorHostListener {
boolean hostAdded(long hostId);

boolean hostConnect(long hostId, long poolId) throws StorageConflictException;

boolean hostDisconnected(long hostId, long poolId);

boolean hostAboutToBeRemoved(long hostId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this event is generated when moving to Removing state. Is there any action that is performed here which cannot be done when the host is in Removed state?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This event was added specifically to address hypervisors like VMware that need to be told to remove iSCSI targets.

Those kind of hypervisor hosts need to be notified to do this before the host is removed because CloudStack can no longer talk to those hosts once they're in the Removed state.


boolean hostRemoved(long hostId, long clusterId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@
import com.cloud.storage.Volume;

public interface PrimaryDataStoreDriver extends DataStoreDriver {
public ChapInfo getChapInfo(VolumeInfo volumeInfo);
ChapInfo getChapInfo(VolumeInfo volumeInfo);

public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);
boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore);

public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);
void revokeAccess(DataObject dataObject, Host host, DataStore dataStore);

// intended for managed storage (cloud.storage_pool.managed = true)
// if not managed, return volume.getSize()
public long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool storagePool);
long getVolumeSizeIncludingHypervisorSnapshotReserve(Volume volume, StoragePool storagePool);

// intended for managed storage (cloud.storage_pool.managed = true)
// if managed storage, return the total number of bytes currently in use for the storage pool in question
// if not managed storage, return 0
public long getUsedBytes(StoragePool storagePool);
long getUsedBytes(StoragePool storagePool);

// intended for managed storage (cloud.storage_pool.managed = true)
// if managed storage, return the total number of IOPS currently in use for the storage pool in question
// if not managed storage, return 0
public long getUsedIops(StoragePool storagePool);
long getUsedIops(StoragePool storagePool);

public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);

public void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback);
void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snapshotOnPrimaryStore, AsyncCompletionCallback<CommandResult> callback);
}
10 changes: 7 additions & 3 deletions engine/components-api/src/com/cloud/agent/AgentManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum TapAgentsAction {
Add, Del, Contains,
}

boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;
boolean handleDirectConnectAgent(Host host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance, boolean newHost) throws ConnectionException;

/**
* easy send method that returns null if there's any errors. It handles all exceptions.
Expand Down Expand Up @@ -131,8 +131,6 @@ public enum TapAgentsAction {

Answer sendTo(Long dcId, HypervisorType type, Command cmd);

// public AgentAttache handleDirectConnectAgent(HostVO host, StartupCommand[] cmds, ServerResource resource, boolean forRebalance) throws ConnectionException;

public boolean agentStatusTransitTo(HostVO host, Status.Event e, long msId);

boolean isAgentAttached(long hostId);
Expand All @@ -146,4 +144,10 @@ public enum TapAgentsAction {
boolean reconnect(long hostId);

void rescan();

void notifyMonitorsOfNewlyAddedHost(long hostId);

void notifyMonitorsOfHostAboutToBeRemoved(long hostId);

void notifyMonitorsOfRemovedHost(long hostId, long clusterId);
}
18 changes: 18 additions & 0 deletions engine/components-api/src/com/cloud/agent/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public interface Listener {
*/
AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd);

/**
* This method is called by AgentManager when a host is added to a cluster.
* @param long the ID of the newly added host
*/
void processHostAdded(long hostId);

/**
* This method is called by AgentManager when an agent made a
* connection to this server if the listener has
Expand All @@ -86,6 +92,18 @@ public interface Listener {
*/
boolean processDisconnect(long agentId, Status state);

/**
* This method is called by AgentManager when a host is about to be removed from a cluster.
* @param long the ID of the host that's about to be removed
*/
void processHostAboutToBeRemoved(long hostId);

/**
* This method is called by AgentManager when a host is removed from a cluster.
* @param long the ID of the newly removed host
*/
void processHostRemoved(long hostId, long clusterId);

/**
* If this Listener is passed to the send() method, this method
* is called by AgentManager after processing an answer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.cloud.agent.api.Command;
import com.cloud.agent.api.MaintainCommand;
import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.ModifyTargetsCommand;
import com.cloud.agent.api.PingTestCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.ReadyCommand;
Expand Down Expand Up @@ -109,11 +110,12 @@ public int compare(final Object o1, final Object o2) {

protected AgentManagerImpl _agentMgr;

public final static String[] s_commandsAllowedInMaintenanceMode = new String[] {MaintainCommand.class.toString(), MigrateCommand.class.toString(),
public final static String[] s_commandsAllowedInMaintenanceMode = new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(),
StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(),
ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(),
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString()};
protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] {StartCommand.class.toString(), CreateCommand.class.toString()};
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(),
ModifyTargetsCommand.class.toString() };
protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
static {
Arrays.sort(s_commandsAllowedInMaintenanceMode);
Arrays.sort(s_commandsNotAllowedInConnectingMode);
Expand Down
Loading