Skip to content

Commit 342624e

Browse files
committed
Merged with head
2 parents 3047929 + 47f6d65 commit 342624e

77 files changed

Lines changed: 3763 additions & 809 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObjectType.java renamed to api/src/com/cloud/agent/api/to/DataObjectType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.cloudstack.engine.subsystem.api.storage;
19+
package com.cloud.agent.api.to;
2020

2121
public enum DataObjectType {
2222
VOLUME,

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataTO.java renamed to api/src/com/cloud/agent/api/to/DataTO.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.cloudstack.engine.subsystem.api.storage;
20-
21-
import com.cloud.agent.api.to.DataStoreTO;
19+
package com.cloud.agent.api.to;
2220

2321
public interface DataTO {
2422
public DataObjectType getObjectType();
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.cloud.agent.api.to;
20+
21+
import com.cloud.storage.Volume;
22+
23+
public class DiskTO {
24+
private DataTO data;
25+
private Long diskSeq;
26+
private Volume.Type type;
27+
public DiskTO() {
28+
29+
}
30+
31+
public DiskTO(DataTO data, Long diskSeq, Volume.Type type) {
32+
this.data = data;
33+
this.diskSeq = diskSeq;
34+
this.type = type;
35+
}
36+
37+
public DataTO getData() {
38+
return data;
39+
}
40+
41+
public void setData(DataTO data) {
42+
this.data = data;
43+
}
44+
45+
public Long getDiskSeq() {
46+
return diskSeq;
47+
}
48+
49+
public void setDiskSeq(Long diskSeq) {
50+
this.diskSeq = diskSeq;
51+
}
52+
53+
public Volume.Type getType() {
54+
return type;
55+
}
56+
57+
public void setType(Volume.Type type) {
58+
this.type = type;
59+
}
60+
}

api/src/com/cloud/agent/api/to/VirtualMachineTO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class VirtualMachineTO {
5757
Map<String, String> params;
5858
String uuid;
5959

60-
VolumeTO[] disks;
60+
DiskTO[] disks;
6161
NicTO[] nics;
6262

6363
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) {
@@ -206,11 +206,11 @@ public void setBootupScripts(String[] bootupScripts) {
206206
this.bootupScripts = bootupScripts;
207207
}
208208

209-
public VolumeTO[] getDisks() {
209+
public DiskTO[] getDisks() {
210210
return disks;
211211
}
212212

213-
public void setDisks(VolumeTO[] disks) {
213+
public void setDisks(DiskTO[] disks) {
214214
this.disks = disks;
215215
}
216216

api/src/com/cloud/vm/VirtualMachineProfile.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import com.cloud.agent.api.to.DataTO;
23+
import com.cloud.agent.api.to.DiskTO;
2224
import com.cloud.agent.api.to.VolumeTO;
2325
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2426
import com.cloud.offering.ServiceOffering;
@@ -111,11 +113,11 @@ public String getName() {
111113

112114
List<NicProfile> getNics();
113115

114-
List<VolumeTO> getDisks();
116+
List<DiskTO> getDisks();
115117

116118
void addNic(int index, NicProfile nic);
117119

118-
void addDisk(int index, VolumeTO disk);
120+
void addDisk(int index, DiskTO disk);
119121

120122
StringBuilder getBootArgsBuilder();
121123

@@ -125,7 +127,7 @@ public String getName() {
125127

126128
void addNic(NicProfile nic);
127129

128-
void addDisk(VolumeTO disk);
130+
void addDisk(DiskTO disk);
129131

130132
VirtualMachine.Type getType();
131133

core/src/com/cloud/serializer/GsonHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
import java.util.List;
2222

23-
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
2423
import org.apache.log4j.Logger;
2524

2625
import com.cloud.agent.api.Answer;
2726
import com.cloud.agent.api.Command;
2827
import com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig;
2928
import com.cloud.agent.api.to.DataStoreTO;
29+
import com.cloud.agent.api.to.DataTO;
3030
import com.cloud.agent.transport.ArrayTypeAdaptor;
3131
import com.cloud.agent.transport.InterfaceTypeAdaptor;
3232
import com.cloud.agent.transport.LoggingExclusionStrategy;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.cloud.storage.resource;
20+
21+
import org.apache.cloudstack.storage.command.AttachCommand;
22+
import org.apache.cloudstack.storage.command.CopyCommand;
23+
import org.apache.cloudstack.storage.command.CreateObjectCommand;
24+
import org.apache.cloudstack.storage.command.DeleteCommand;
25+
import org.apache.cloudstack.storage.command.DettachCommand;
26+
27+
import com.cloud.agent.api.Answer;
28+
import com.cloud.agent.api.to.DataTO;
29+
import com.cloud.agent.api.to.DiskTO;
30+
31+
public interface StorageProcessor {
32+
public Answer copyTemplateToPrimaryStorage(CopyCommand cmd);
33+
public Answer cloneVolumeFromBaseTemplate(CopyCommand cmd);
34+
public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd);
35+
public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd);
36+
public Answer createTemplateFromVolume(CopyCommand cmd);
37+
public Answer backupSnasphot(CopyCommand cmd);
38+
public Answer attachIso(AttachCommand cmd);
39+
public Answer attachVolume(AttachCommand cmd);
40+
public Answer dettachIso(DettachCommand cmd);
41+
public Answer dettachVolume(DettachCommand cmd);
42+
public Answer createVolume(CreateObjectCommand cmd);
43+
public Answer createSnapshot(CreateObjectCommand cmd);
44+
public Answer deleteVolume(DeleteCommand cmd);
45+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.cloud.storage.resource;
20+
21+
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
22+
23+
import com.cloud.agent.api.Answer;
24+
25+
public interface StorageSubsystemCommandHandler {
26+
public Answer handleStorageCommands(StorageSubSystemCommand command);
27+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.cloud.storage.resource;
20+
21+
import org.apache.cloudstack.storage.command.AttachCommand;
22+
import org.apache.cloudstack.storage.command.CopyCommand;
23+
import org.apache.cloudstack.storage.command.CreateObjectAnswer;
24+
import org.apache.cloudstack.storage.command.CreateObjectCommand;
25+
import org.apache.cloudstack.storage.command.DeleteCommand;
26+
import org.apache.cloudstack.storage.command.DettachCommand;
27+
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
28+
import org.apache.log4j.Logger;
29+
30+
import com.cloud.agent.api.Answer;
31+
import com.cloud.agent.api.Command;
32+
import com.cloud.agent.api.to.DataObjectType;
33+
import com.cloud.agent.api.to.DataStoreTO;
34+
import com.cloud.agent.api.to.DataTO;
35+
import com.cloud.agent.api.to.DiskTO;
36+
import com.cloud.agent.api.to.NfsTO;
37+
import com.cloud.storage.DataStoreRole;
38+
import com.cloud.storage.Volume;
39+
40+
public class StorageSubsystemCommandHandlerBase implements StorageSubsystemCommandHandler {
41+
private static final Logger s_logger = Logger.getLogger(StorageSubsystemCommandHandlerBase.class);
42+
private StorageProcessor processor;
43+
public StorageSubsystemCommandHandlerBase(StorageProcessor processor) {
44+
this.processor = processor;
45+
}
46+
@Override
47+
public Answer handleStorageCommands(StorageSubSystemCommand command) {
48+
if (command instanceof CopyCommand) {
49+
return this.execute((CopyCommand)command);
50+
} else if (command instanceof CreateObjectCommand) {
51+
return execute((CreateObjectCommand) command);
52+
} else if (command instanceof DeleteCommand) {
53+
return execute((DeleteCommand)command);
54+
} else if (command instanceof AttachCommand) {
55+
return execute((AttachCommand)command);
56+
} else if (command instanceof DettachCommand) {
57+
return execute((DettachCommand)command);
58+
}
59+
return new Answer((Command)command, false, "not implemented yet");
60+
}
61+
62+
protected Answer execute(CopyCommand cmd) {
63+
DataTO srcData = cmd.getSrcTO();
64+
DataTO destData = cmd.getDestTO();
65+
DataStoreTO srcDataStore = srcData.getDataStore();
66+
DataStoreTO destDataStore = destData.getDataStore();
67+
68+
if ((srcData.getObjectType() == DataObjectType.TEMPLATE) && (srcDataStore instanceof NfsTO) && (destData.getDataStore().getRole() == DataStoreRole.Primary)) {
69+
//copy template to primary storage
70+
return processor.copyTemplateToPrimaryStorage(cmd);
71+
} else if (srcData.getObjectType() == DataObjectType.TEMPLATE && srcDataStore.getRole() == DataStoreRole.Primary && destDataStore.getRole() == DataStoreRole.Primary) {
72+
//clone template to a volume
73+
return processor.cloneVolumeFromBaseTemplate(cmd);
74+
} else if (srcData.getObjectType() == DataObjectType.VOLUME && (srcData.getDataStore().getRole() == DataStoreRole.ImageCache || srcDataStore.getRole() == DataStoreRole.Image)) {
75+
//copy volume from image cache to primary
76+
return processor.copyVolumeFromImageCacheToPrimary(cmd);
77+
} else if (srcData.getObjectType() == DataObjectType.VOLUME && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
78+
if (destData.getObjectType() == DataObjectType.VOLUME) {
79+
return processor.copyVolumeFromPrimaryToSecondary(cmd);
80+
} else if (destData.getObjectType() == DataObjectType.TEMPLATE) {
81+
return processor.createTemplateFromVolume(cmd);
82+
}
83+
} else if (srcData.getObjectType() == DataObjectType.SNAPSHOT && srcData.getDataStore().getRole() == DataStoreRole.Primary) {
84+
return processor.backupSnasphot(cmd);
85+
}
86+
87+
return new Answer(cmd, false, "not implemented yet");
88+
}
89+
90+
91+
protected Answer execute(CreateObjectCommand cmd) {
92+
DataTO data = cmd.getData();
93+
try {
94+
if (data.getObjectType() == DataObjectType.VOLUME) {
95+
return processor.createVolume(cmd);
96+
} else if (data.getObjectType() == DataObjectType.SNAPSHOT) {
97+
return processor.createSnapshot(cmd);
98+
}
99+
return new CreateObjectAnswer("not supported type");
100+
} catch (Exception e) {
101+
s_logger.debug("Failed to create object: " + data.getObjectType() + ": " + e.toString());
102+
return new CreateObjectAnswer(e.toString());
103+
}
104+
}
105+
106+
protected Answer execute(DeleteCommand cmd) {
107+
DataTO data = cmd.getData();
108+
Answer answer = null;
109+
if (data.getObjectType() == DataObjectType.VOLUME) {
110+
answer = processor.deleteVolume(cmd);
111+
} else {
112+
answer = new Answer(cmd, false, "unsupported type");
113+
}
114+
115+
return answer;
116+
}
117+
118+
protected Answer execute(AttachCommand cmd) {
119+
DiskTO disk = cmd.getDisk();
120+
if (disk.getType() == Volume.Type.ISO) {
121+
return processor.attachIso(cmd);
122+
} else {
123+
return processor.attachVolume(cmd);
124+
}
125+
}
126+
127+
protected Answer execute(DettachCommand cmd) {
128+
DiskTO disk = cmd.getDisk();
129+
if (disk.getType() == Volume.Type.ISO) {
130+
return processor.dettachIso(cmd);
131+
} else {
132+
return processor.dettachVolume(cmd);
133+
}
134+
}
135+
}

core/src/com/cloud/storage/template/S3TemplateDownloader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ public long download(boolean resume, DownloadCompleteCallback callback) {
279279
@Override
280280
public void progressChanged(
281281
ProgressEvent progressEvent) {
282-
s_logger.info(progressEvent.getBytesTransfered()
283-
+ " number of byte transferd "
284-
+ new Date());
282+
// s_logger.debug(progressEvent.getBytesTransfered()
283+
// + " number of byte transferd "
284+
// + new Date());
285285
totalBytes += progressEvent.getBytesTransfered();
286286
if (progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) {
287287
s_logger.info("download completed");

0 commit comments

Comments
 (0)