mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-9315: Removed unused Classes (#1448)
* Remove some unused Classes These classes were deleted because they have no references in our code base. They are not in Spring execution flow nor instantiated with "new": - com.cloud.agent.api.CheckStateAnswer - com.cloud.agent.api.StartupVMMAgentCommand - com.cloud.agent.api.routing.UserDataCommand - remove from description at com.cloud.configuration.Config.ExecuteInSequenceNetworkElementCommands enum - com.cloud.agent.api.storage.UpgradeDiskCommand - com.cloud.agent.api.storage.CreatePrivateTemplateCommand - com.cloud.agent.api.storage.DestroyAnswer - Note: "FIXME: Should have an DestroyAnswer" at com.cloud.storage.resource.StoragePoolResource - com.cloud.agent.api.storage.UpgradeDiskAnswer - com.cloud.agent.api.storage.ManageVolumeAvailabilityAnswer - com.cloud.agent.api.storage.ManageVolumeAvailabilityCommand - com.cloud.exception.UsageServerException - com.cloud.info.SecStorageVmLoadInfo - com.cloud.serializer.SerializerHelper * PR#1448 update description of 'execute.in.sequence.network.element.commands' param Update description of 'execute.in.sequence.network.element.commands'parameter to reflect an unused command that has been removed. The removed class command is 'UserDataCommand'. * Add cloud schema to update SQL
This commit is contained in:
parent
323d381767
commit
cdc6e6e50a
|
|
@ -1,49 +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 com.cloud.agent.api;
|
||||
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CheckStateAnswer extends Answer {
|
||||
State state;
|
||||
|
||||
public CheckStateAnswer() {
|
||||
}
|
||||
|
||||
public CheckStateAnswer(CheckStateCommand cmd, State state) {
|
||||
this(cmd, state, null);
|
||||
}
|
||||
|
||||
public CheckStateAnswer(CheckStateCommand cmd, String details) {
|
||||
super(cmd, false, details);
|
||||
this.state = null;
|
||||
}
|
||||
|
||||
public CheckStateAnswer(CheckStateCommand cmd, State state, String details) {
|
||||
super(cmd, true, details);
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,86 +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 com.cloud.agent.api;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
|
||||
/**
|
||||
* Implementation of bootstrap command sent from management server to agent running on
|
||||
* System Center Virtual Machine Manager host
|
||||
**/
|
||||
|
||||
public class StartupVMMAgentCommand extends Command {
|
||||
Host.Type type;
|
||||
long dataCenter;
|
||||
Long pod;
|
||||
String clusterName;
|
||||
String guid;
|
||||
String managementServerIP;
|
||||
String port;
|
||||
String version;
|
||||
|
||||
public StartupVMMAgentCommand() {
|
||||
|
||||
}
|
||||
|
||||
public StartupVMMAgentCommand(long dataCenter, Long pod, String clusterName, String guid, String managementServerIP, String port, String version) {
|
||||
super();
|
||||
this.dataCenter = dataCenter;
|
||||
this.pod = pod;
|
||||
this.clusterName = clusterName;
|
||||
this.guid = guid;
|
||||
this.type = Host.Type.Routing;
|
||||
this.managementServerIP = managementServerIP;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public long getDataCenter() {
|
||||
return dataCenter;
|
||||
}
|
||||
|
||||
public Long getPod() {
|
||||
return pod;
|
||||
}
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
}
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public String getManagementServerIP() {
|
||||
return managementServerIP;
|
||||
}
|
||||
|
||||
public String getport() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +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 com.cloud.agent.api.routing;
|
||||
|
||||
public class UserDataCommand extends NetworkElementCommand {
|
||||
|
||||
String userData;
|
||||
String vmIpAddress;
|
||||
String routerPrivateIpAddress;
|
||||
String vmName;
|
||||
boolean executeInSequence = false;
|
||||
|
||||
protected UserDataCommand() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return executeInSequence;
|
||||
}
|
||||
|
||||
public UserDataCommand(String userData, String vmIpAddress, String routerPrivateIpAddress, String vmName, boolean executeInSequence) {
|
||||
this.userData = userData;
|
||||
this.vmIpAddress = vmIpAddress;
|
||||
this.routerPrivateIpAddress = routerPrivateIpAddress;
|
||||
this.vmName = vmName;
|
||||
this.executeInSequence = executeInSequence;
|
||||
}
|
||||
|
||||
public String getRouterPrivateIpAddress() {
|
||||
return routerPrivateIpAddress;
|
||||
}
|
||||
|
||||
public String getVmIpAddress() {
|
||||
return vmIpAddress;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public String getUserData() {
|
||||
return userData;
|
||||
}
|
||||
|
||||
public void setUserData(String userData) {
|
||||
this.userData = userData;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,95 +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 com.cloud.agent.api.storage;
|
||||
|
||||
public class CreatePrivateTemplateCommand extends StorageCommand {
|
||||
private String _snapshotFolder;
|
||||
private String _snapshotPath;
|
||||
private String _userFolder;
|
||||
private String _userSpecifiedName;
|
||||
private String _uniqueName;
|
||||
private long _templateId;
|
||||
private long _accountId;
|
||||
|
||||
// For XenServer
|
||||
private String _secondaryStorageURL;
|
||||
private String _snapshotName;
|
||||
|
||||
public CreatePrivateTemplateCommand() {
|
||||
}
|
||||
|
||||
public CreatePrivateTemplateCommand(String secondaryStorageURL, long templateId, long accountId, String userSpecifiedName, String uniqueName, String snapshotFolder,
|
||||
String snapshotPath, String snapshotName, String userFolder) {
|
||||
_secondaryStorageURL = secondaryStorageURL;
|
||||
_templateId = templateId;
|
||||
_accountId = accountId;
|
||||
_userSpecifiedName = userSpecifiedName;
|
||||
_uniqueName = uniqueName;
|
||||
_snapshotFolder = snapshotFolder;
|
||||
_snapshotPath = snapshotPath;
|
||||
_snapshotName = snapshotName;
|
||||
_userFolder = userFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getSecondaryStorageURL() {
|
||||
return _secondaryStorageURL;
|
||||
}
|
||||
|
||||
public String getTemplateName() {
|
||||
return _userSpecifiedName;
|
||||
}
|
||||
|
||||
public String getUniqueName() {
|
||||
return _uniqueName;
|
||||
}
|
||||
|
||||
public String getSnapshotFolder() {
|
||||
return _snapshotFolder;
|
||||
}
|
||||
|
||||
public String getSnapshotPath() {
|
||||
return _snapshotPath;
|
||||
}
|
||||
|
||||
public String getSnapshotName() {
|
||||
return _snapshotName;
|
||||
}
|
||||
|
||||
public String getUserFolder() {
|
||||
return _userFolder;
|
||||
}
|
||||
|
||||
public long getTemplateId() {
|
||||
return _templateId;
|
||||
}
|
||||
|
||||
public long getAccountId() {
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public void setTemplateId(long templateId) {
|
||||
_templateId = templateId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +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 com.cloud.agent.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
||||
public class DestroyAnswer extends Answer {
|
||||
public DestroyAnswer(DestroyCommand cmd, boolean result, String details) {
|
||||
super(cmd, result, details);
|
||||
}
|
||||
|
||||
// Constructor for gson.
|
||||
protected DestroyAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,35 +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 com.cloud.agent.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class ManageVolumeAvailabilityAnswer extends Answer {
|
||||
|
||||
protected ManageVolumeAvailabilityAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ManageVolumeAvailabilityAnswer(Command command, boolean success, String details) {
|
||||
super(command, success, details);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,56 +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 com.cloud.agent.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class ManageVolumeAvailabilityCommand extends Command {
|
||||
|
||||
boolean attach;
|
||||
String primaryStorageSRUuid;
|
||||
String volumeUuid;
|
||||
|
||||
public ManageVolumeAvailabilityCommand() {
|
||||
}
|
||||
|
||||
public ManageVolumeAvailabilityCommand(boolean attach, String primaryStorageSRUuid, String volumeUuid) {
|
||||
this.attach = attach;
|
||||
this.primaryStorageSRUuid = primaryStorageSRUuid;
|
||||
this.volumeUuid = volumeUuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getAttach() {
|
||||
return attach;
|
||||
}
|
||||
|
||||
public String getPrimaryStorageSRUuid() {
|
||||
return primaryStorageSRUuid;
|
||||
}
|
||||
|
||||
public String getVolumeUuid() {
|
||||
return volumeUuid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,34 +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 com.cloud.agent.api.storage;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
|
||||
public class UpgradeDiskAnswer extends Answer {
|
||||
|
||||
public UpgradeDiskAnswer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UpgradeDiskAnswer(Command cmd, boolean success, String details) {
|
||||
super(cmd, success, details);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.cloud.agent.api.storage;
|
||||
|
||||
public class UpgradeDiskCommand extends StorageCommand {
|
||||
|
||||
private String _imagePath;
|
||||
private String _newSize;
|
||||
|
||||
public UpgradeDiskCommand() {
|
||||
}
|
||||
|
||||
public UpgradeDiskCommand(String imagePath, String newSize) {
|
||||
_imagePath = imagePath;
|
||||
_newSize = newSize;
|
||||
}
|
||||
|
||||
public String getImagePath() {
|
||||
return _imagePath;
|
||||
}
|
||||
|
||||
public void setImagePath(String imagePath) {
|
||||
_imagePath = imagePath;
|
||||
}
|
||||
|
||||
public String getNewSize() {
|
||||
return _newSize;
|
||||
}
|
||||
|
||||
public void setNewSize(String newSize) {
|
||||
_newSize = newSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeInSequence() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +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 com.cloud.exception;
|
||||
|
||||
public class UsageServerException extends CloudException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8398313106067116466L;
|
||||
|
||||
public UsageServerException() {
|
||||
|
||||
}
|
||||
|
||||
public UsageServerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,51 +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 com.cloud.info;
|
||||
|
||||
public class SecStorageVmLoadInfo {
|
||||
|
||||
private long id;
|
||||
private String name;
|
||||
private int count;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,193 +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 com.cloud.serializer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
/**
|
||||
* Note: toPairList and appendPairList only support simple POJO objects currently
|
||||
*/
|
||||
public class SerializerHelper {
|
||||
public static final Logger s_logger = Logger.getLogger(SerializerHelper.class.getName());
|
||||
public static final String token = "/";
|
||||
|
||||
public static String toSerializedStringOld(Object result) {
|
||||
if (result != null) {
|
||||
Class<?> clz = result.getClass();
|
||||
Gson gson = GsonHelper.getGson();
|
||||
return clz.getName() + token + gson.toJson(result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object fromSerializedString(String result) {
|
||||
try {
|
||||
if (result != null && !result.isEmpty()) {
|
||||
|
||||
String[] serializedParts = result.split(token);
|
||||
|
||||
if (serializedParts.length < 2) {
|
||||
return null;
|
||||
}
|
||||
String clzName = serializedParts[0];
|
||||
String nameField = null;
|
||||
String content = null;
|
||||
if (serializedParts.length == 2) {
|
||||
content = serializedParts[1];
|
||||
} else {
|
||||
nameField = serializedParts[1];
|
||||
int index = result.indexOf(token + nameField + token);
|
||||
content = result.substring(index + nameField.length() + 2);
|
||||
}
|
||||
|
||||
Class<?> clz;
|
||||
try {
|
||||
clz = Class.forName(clzName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Gson gson = GsonHelper.getGson();
|
||||
Object obj = gson.fromJson(content, clz);
|
||||
return obj;
|
||||
}
|
||||
return null;
|
||||
} catch (RuntimeException e) {
|
||||
s_logger.error("Caught runtime exception when doing GSON deserialization on: " + result);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Pair<String, Object>> toPairList(Object o, String name) {
|
||||
List<Pair<String, Object>> l = new ArrayList<Pair<String, Object>>();
|
||||
return appendPairList(l, o, name);
|
||||
}
|
||||
|
||||
public static List<Pair<String, Object>> appendPairList(List<Pair<String, Object>> l, Object o, String name) {
|
||||
if (o != null) {
|
||||
Class<?> clz = o.getClass();
|
||||
|
||||
if (clz.isPrimitive() || clz.getSuperclass() == Number.class || clz == String.class || clz == Date.class) {
|
||||
l.add(new Pair<String, Object>(name, o.toString()));
|
||||
return l;
|
||||
}
|
||||
|
||||
for (Field f : clz.getDeclaredFields()) {
|
||||
if ((f.getModifiers() & Modifier.STATIC) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Param param = f.getAnnotation(Param.class);
|
||||
if (param == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String propName = f.getName();
|
||||
if (!param.propName().isEmpty()) {
|
||||
propName = param.propName();
|
||||
}
|
||||
|
||||
String paramName = param.name();
|
||||
if (paramName.isEmpty()) {
|
||||
paramName = propName;
|
||||
}
|
||||
|
||||
Method method = getGetMethod(o, propName);
|
||||
if (method != null) {
|
||||
try {
|
||||
Object fieldValue = method.invoke(o);
|
||||
if (fieldValue != null) {
|
||||
if (f.getType() == Date.class) {
|
||||
l.add(new Pair<String, Object>(paramName, DateUtil.getOutputString((Date)fieldValue)));
|
||||
} else {
|
||||
l.add(new Pair<String, Object>(paramName, fieldValue.toString()));
|
||||
}
|
||||
}
|
||||
//else
|
||||
// l.add(new Pair<String, Object>(paramName, ""));
|
||||
} catch (IllegalArgumentException e) {
|
||||
s_logger.error("Illegal argument exception when calling POJO " + o.getClass().getName() + " get method for property: " + propName);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
s_logger.error("Illegal access exception when calling POJO " + o.getClass().getName() + " get method for property: " + propName);
|
||||
} catch (InvocationTargetException e) {
|
||||
s_logger.error("Invocation target exception when calling POJO " + o.getClass().getName() + " get method for property: " + propName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
private static Method getGetMethod(Object o, String propName) {
|
||||
Method method = null;
|
||||
String methodName = getGetMethodName("get", propName);
|
||||
try {
|
||||
method = o.getClass().getMethod(methodName);
|
||||
} catch (SecurityException e1) {
|
||||
s_logger.error("Security exception in getting POJO " + o.getClass().getName() + " get method for property: " + propName);
|
||||
} catch (NoSuchMethodException e1) {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("POJO " + o.getClass().getName() + " does not have " + methodName + "() method for property: " + propName +
|
||||
", will check is-prefixed method to see if it is boolean property");
|
||||
}
|
||||
}
|
||||
|
||||
if (method != null) {
|
||||
return method;
|
||||
}
|
||||
|
||||
methodName = getGetMethodName("is", propName);
|
||||
try {
|
||||
method = o.getClass().getMethod(methodName);
|
||||
} catch (SecurityException e1) {
|
||||
s_logger.error("Security exception in getting POJO " + o.getClass().getName() + " get method for property: " + propName);
|
||||
} catch (NoSuchMethodException e1) {
|
||||
s_logger.warn("POJO " + o.getClass().getName() + " does not have " + methodName + "() method for property: " + propName);
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
private static String getGetMethodName(String prefix, String fieldName) {
|
||||
StringBuffer sb = new StringBuffer(prefix);
|
||||
|
||||
if (fieldName.length() >= prefix.length() && fieldName.substring(0, prefix.length()).equals(prefix)) {
|
||||
return fieldName;
|
||||
} else {
|
||||
sb.append(fieldName.substring(0, 1).toUpperCase());
|
||||
sb.append(fieldName.substring(1));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -30,7 +30,6 @@ public interface StoragePoolResource {
|
|||
// FIXME: Should have a PrimaryStorageDownloadAnswer
|
||||
PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd);
|
||||
|
||||
// FIXME: Should have an DestroyAnswer
|
||||
Answer execute(DestroyCommand cmd);
|
||||
|
||||
CopyVolumeAnswer execute(CopyVolumeCommand cmd);
|
||||
|
|
|
|||
|
|
@ -34,4 +34,7 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`,
|
|||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'moveNetworkAclItem', 'ALLOW', 302) ON DUPLICATE KEY UPDATE rule=rule;
|
||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'moveNetworkAclItem', 'ALLOW', 260) ON DUPLICATE KEY UPDATE rule=rule;
|
||||
|
||||
UPDATE `cloud`.`async_job` SET `removed` = now() WHERE `removed` IS NULL;
|
||||
UPDATE `cloud`.`async_job` SET `removed` = now() WHERE `removed` IS NULL;
|
||||
|
||||
-- PR#1448 update description of 'execute.in.sequence.network.element.commands' parameter to reflect an unused command that has been removed. The removed class command is 'UserDataCommand'.
|
||||
update `cloud`.`configuration` set description = 'If set to true, DhcpEntryCommand, SavePasswordCommand, VmDataCommand will be synchronized on the agent side. If set to false, these commands become asynchronous. Default value is false.' where name = 'execute.in.sequence.network.element.commands';
|
||||
|
|
@ -683,8 +683,8 @@ public enum Config {
|
|||
String.class,
|
||||
"hypervisor.list",
|
||||
HypervisorType.Hyperv + "," + HypervisorType.KVM + "," + HypervisorType.XenServer + "," + HypervisorType.VMware + "," + HypervisorType.BareMetal + "," +
|
||||
HypervisorType.Ovm + "," + HypervisorType.LXC + "," + HypervisorType.Ovm3,
|
||||
"The list of hypervisors that this deployment will use.",
|
||||
HypervisorType.Ovm + "," + HypervisorType.LXC + "," + HypervisorType.Ovm3,
|
||||
"The list of hypervisors that this deployment will use.",
|
||||
"hypervisorList"),
|
||||
ManagementNetwork("Advanced", ManagementServer.class, String.class, "management.network.cidr", null, "The cidr of management server network", null),
|
||||
EventPurgeDelay(
|
||||
|
|
@ -1814,8 +1814,8 @@ public enum Config {
|
|||
"s3.singleupload.max.size",
|
||||
"5",
|
||||
"The maximum size limit for S3 single part upload API(in GB). If it is set to 0, then it means always use multi-part upload to upload object to S3. "
|
||||
+ "If it is set to -1, then it means always use single-part upload to upload object to S3. ",
|
||||
null),
|
||||
+ "If it is set to -1, then it means always use single-part upload to upload object to S3. ",
|
||||
null),
|
||||
|
||||
// VMSnapshots
|
||||
VMSnapshotMax("Advanced", VMSnapshotManager.class, Integer.class, "vmsnapshot.max", "10", "Maximum vm snapshots for a vm", null),
|
||||
|
|
@ -1836,9 +1836,9 @@ public enum Config {
|
|||
Boolean.class,
|
||||
"execute.in.sequence.network.element.commands",
|
||||
"false",
|
||||
"If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side."
|
||||
+ " If set to false, these commands become asynchronous. Default value is false.",
|
||||
null),
|
||||
"If set to true, DhcpEntryCommand, SavePasswordCommand, VmDataCommand will be synchronized on the agent side."
|
||||
+ " If set to false, these commands become asynchronous. Default value is false.",
|
||||
null),
|
||||
|
||||
UCSSyncBladeInterval(
|
||||
"Advanced",
|
||||
|
|
|
|||
Loading…
Reference in New Issue