Skip to content

Commit a8860d0

Browse files
committed
implmentation stub
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent d3b292a commit a8860d0

7 files changed

Lines changed: 445 additions & 0 deletions

File tree

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.ingestion;
19+
20+
import java.util.Collection;
21+
import java.util.HashMap;
22+
import java.util.Iterator;
23+
import java.util.List;
24+
import java.util.Map;
25+
26+
import javax.inject.Inject;
27+
28+
import org.apache.cloudstack.api.ACL;
29+
import org.apache.cloudstack.api.APICommand;
30+
import org.apache.cloudstack.api.ApiConstants;
31+
import org.apache.cloudstack.api.BaseAsyncCmd;
32+
import org.apache.cloudstack.api.Parameter;
33+
import org.apache.cloudstack.api.ResponseObject;
34+
import org.apache.cloudstack.api.ServerApiException;
35+
import org.apache.cloudstack.api.command.admin.AdminCmd;
36+
import org.apache.cloudstack.api.response.ClusterResponse;
37+
import org.apache.cloudstack.api.response.DomainResponse;
38+
import org.apache.cloudstack.api.response.ImportUnmanagedInstanceResponse;
39+
import org.apache.cloudstack.api.response.NetworkResponse;
40+
import org.apache.cloudstack.api.response.ProjectResponse;
41+
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
42+
import org.apache.cloudstack.ingestion.VmIngestionService;
43+
import org.apache.log4j.Logger;
44+
45+
import com.cloud.exception.ConcurrentOperationException;
46+
import com.cloud.exception.InsufficientCapacityException;
47+
import com.cloud.exception.NetworkRuleConflictException;
48+
import com.cloud.exception.ResourceAllocationException;
49+
import com.cloud.exception.ResourceUnavailableException;
50+
51+
@APICommand(name = "importUnmanagedInstances",
52+
description = "Import unmanaged virtual machine from a given cluster/host.",
53+
responseObject = ImportUnmanagedInstanceResponse.class,
54+
responseView = ResponseObject.ResponseView.Full,
55+
requestHasSensitiveInfo = false,
56+
responseHasSensitiveInfo = true)
57+
public class ImportUnmanageInstanceCmd extends BaseAsyncCmd implements AdminCmd {
58+
public static final Logger s_logger = Logger.getLogger(ImportUnmanageInstanceCmd.class.getName());
59+
60+
@Inject
61+
public VmIngestionService vmIngestionService;
62+
63+
@Parameter(name = ApiConstants.CLUSTER_ID,
64+
type = CommandType.UUID,
65+
entityType = ClusterResponse.class,
66+
description = "the cluster ID")
67+
private Long clusterId;
68+
69+
@Parameter(name = ApiConstants.NAME,
70+
type = CommandType.UUID,
71+
description = "the hypervisor name of the instance")
72+
private Long name;
73+
74+
@Parameter(name = ApiConstants.DOMAIN_ID,
75+
type = CommandType.UUID,
76+
entityType = DomainResponse.class,
77+
description = "import instance to the domain specified")
78+
private Long domainId;
79+
80+
@Parameter(name = ApiConstants.PROJECT_ID,
81+
type = CommandType.UUID,
82+
entityType = ProjectResponse.class,
83+
description = "import instance for the project")
84+
private Long projectId;
85+
86+
@ACL
87+
@Parameter(name = ApiConstants.SERVICE_OFFERING_ID,
88+
type = CommandType.UUID,
89+
entityType = ServiceOfferingResponse.class,
90+
required = true,
91+
description = "the ID of the service offering for the virtual machine")
92+
private Long serviceOfferingId;
93+
94+
@Parameter(name = ApiConstants.NETWORK_ID,
95+
type = CommandType.UUID,
96+
entityType = NetworkResponse.class,
97+
description = "network id used by virtual machine")
98+
private List<Long> networkIds;
99+
100+
@Parameter(name = ApiConstants.DATADISK_OFFERING_LIST,
101+
type = CommandType.MAP,
102+
description = "datadisk template to disk-offering mapping")
103+
private Map dataDiskToDiskOfferingList;
104+
105+
@Parameter(name = ApiConstants.DETAILS,
106+
type = CommandType.MAP,
107+
description = "used to specify the custom parameters.")
108+
private Map details;
109+
110+
public Long getClusterId() {
111+
return clusterId;
112+
}
113+
114+
public Long getName() {
115+
return name;
116+
}
117+
118+
public Long getDomainId() {
119+
return domainId;
120+
}
121+
122+
public Long getProjectId() {
123+
return projectId;
124+
}
125+
126+
public Long getServiceOfferingId() {
127+
return serviceOfferingId;
128+
}
129+
130+
public List<Long> getNetworkIds() {
131+
return networkIds;
132+
}
133+
134+
public Map getDataDiskToDiskOfferingList() {
135+
return dataDiskToDiskOfferingList;
136+
}
137+
138+
public Map getDetails() {
139+
Map<String, String> customParameterMap = new HashMap<String, String>();
140+
if (details != null && details.size() != 0) {
141+
Collection parameterCollection = details.values();
142+
Iterator iter = parameterCollection.iterator();
143+
while (iter.hasNext()) {
144+
HashMap<String, String> value = (HashMap<String, String>)iter.next();
145+
for (Map.Entry<String,String> entry: value.entrySet()) {
146+
customParameterMap.put(entry.getKey(),entry.getValue());
147+
}
148+
}
149+
}
150+
return customParameterMap;
151+
}
152+
153+
@Override
154+
public String getEventType() {
155+
return null;
156+
}
157+
158+
@Override
159+
public String getEventDescription() {
160+
return null;
161+
}
162+
163+
@Override
164+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
165+
166+
}
167+
168+
@Override
169+
public String getCommandName() {
170+
return null;
171+
}
172+
173+
@Override
174+
public long getEntityOwnerId() {
175+
return 0;
176+
}
177+
178+
@Override
179+
public ResponseObject.ResponseView getResponseView() {
180+
return null;
181+
}
182+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.ingestion;
19+
20+
import javax.inject.Inject;
21+
22+
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiConstants;
24+
import org.apache.cloudstack.api.BaseAsyncCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.ResponseObject;
27+
import org.apache.cloudstack.api.ServerApiException;
28+
import org.apache.cloudstack.api.command.admin.AdminCmd;
29+
import org.apache.cloudstack.api.response.ClusterResponse;
30+
import org.apache.cloudstack.api.response.UnmanagedInstanceResponse;
31+
import org.apache.cloudstack.ingestion.UnmanagedInstance;
32+
import org.apache.cloudstack.ingestion.VmIngestionService;
33+
import org.apache.log4j.Logger;
34+
35+
import com.cloud.exception.ConcurrentOperationException;
36+
import com.cloud.exception.InsufficientCapacityException;
37+
import com.cloud.exception.NetworkRuleConflictException;
38+
import com.cloud.exception.ResourceAllocationException;
39+
import com.cloud.exception.ResourceUnavailableException;
40+
41+
@APICommand(name = "listUnmanagedInstances",
42+
description = "Lists unmanaged virtual machines for a given cluster/host.",
43+
responseObject = UnmanagedInstanceResponse.class,
44+
responseView = ResponseObject.ResponseView.Full,
45+
entityType = {UnmanagedInstance.class},
46+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
47+
public class ListUnmanagedInstancesCmd extends BaseAsyncCmd implements AdminCmd {
48+
public static final Logger s_logger = Logger.getLogger(ListUnmanagedInstancesCmd.class.getName());
49+
50+
@Inject
51+
public VmIngestionService vmIngestionService;
52+
53+
@Parameter(name = ApiConstants.CLUSTER_ID,
54+
type = CommandType.UUID,
55+
entityType = ClusterResponse.class,
56+
description = "the cluster ID")
57+
private Long clusterId;
58+
59+
@Parameter(name = ApiConstants.NAME,
60+
type = CommandType.UUID,
61+
description = "the hypervisor name of the instance")
62+
private Long name;
63+
64+
public Long getClusterId() {
65+
return clusterId;
66+
}
67+
68+
public Long getName() {
69+
return name;
70+
}
71+
72+
@Override
73+
public String getEventType() {
74+
return null;
75+
}
76+
77+
@Override
78+
public String getEventDescription() {
79+
return null;
80+
}
81+
82+
@Override
83+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
84+
85+
}
86+
87+
@Override
88+
public String getCommandName() {
89+
return null;
90+
}
91+
92+
@Override
93+
public long getEntityOwnerId() {
94+
return 0;
95+
}
96+
97+
@Override
98+
public ResponseObject.ResponseView getResponseView() {
99+
return ResponseObject.ResponseView.Full;
100+
}
101+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.response;
19+
20+
import org.apache.cloudstack.api.ApiConstants;
21+
import org.apache.cloudstack.api.BaseResponse;
22+
23+
import com.cloud.serializer.Param;
24+
import com.google.gson.annotations.SerializedName;
25+
26+
public class ImportUnmanagedInstanceResponse extends BaseResponse {
27+
28+
@SerializedName(ApiConstants.NAME)
29+
@Param(description = "the name of the virtual machine")
30+
private String name;
31+
32+
public String getName() {
33+
return name;
34+
}
35+
36+
public void setName(String name) {
37+
this.name = name;
38+
}
39+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.response;
19+
20+
import org.apache.cloudstack.api.ApiConstants;
21+
import org.apache.cloudstack.api.BaseResponse;
22+
import org.apache.cloudstack.api.EntityReference;
23+
import org.apache.cloudstack.ingestion.UnmanagedInstance;
24+
25+
import com.cloud.serializer.Param;
26+
import com.google.gson.annotations.SerializedName;
27+
28+
@EntityReference(value = UnmanagedInstance.class)
29+
public class UnmanagedInstanceResponse extends BaseResponse {
30+
31+
@SerializedName(ApiConstants.NAME)
32+
@Param(description = "the name of the virtual machine")
33+
private String name;
34+
35+
public String getName() {
36+
return name;
37+
}
38+
39+
public void setName(String name) {
40+
this.name = name;
41+
}
42+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.ingestion;
19+
20+
public interface UnmanagedInstance {
21+
22+
String getName();
23+
}

0 commit comments

Comments
 (0)