Skip to content

Commit ae19fc9

Browse files
author
Frank.Zhang
committed
add missing files during merging UCS
1 parent 80e88dd commit ae19fc9

6 files changed

Lines changed: 457 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 com.cloud.ucs.structure;
19+
20+
import com.cloud.utils.xmlobject.XmlObject;
21+
import com.cloud.utils.xmlobject.XmlObjectParser;
22+
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
26+
/**
27+
* Created with IntelliJ IDEA.
28+
* User: frank
29+
* Date: 10/8/13
30+
* Time: 3:01 PM
31+
* To change this template use File | Settings | File Templates.
32+
*/
33+
public class UcsTemplate {
34+
private String dn;
35+
36+
public static List<UcsTemplate> fromXmlString(String xmlstr) {
37+
List<UcsTemplate> tmps = new ArrayList<UcsTemplate>();
38+
XmlObject xo = XmlObjectParser.parseFromString(xmlstr);
39+
List<XmlObject> xos = xo.getAsList("outConfigs.lsServer");
40+
if (xos != null) {
41+
for (XmlObject x : xos) {
42+
UcsTemplate t = new UcsTemplate();
43+
t.setDn(x.get("dn").toString());
44+
tmps.add(t);
45+
}
46+
}
47+
return tmps;
48+
}
49+
50+
public String getDn() {
51+
return dn;
52+
}
53+
54+
public void setDn(String dn) {
55+
this.dn = dn;
56+
}
57+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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;
19+
20+
import com.cloud.event.EventTypes;
21+
22+
import com.cloud.exception.*;
23+
import com.cloud.ucs.manager.UcsManager;
24+
import com.cloud.user.Account;
25+
import org.apache.cloudstack.api.response.SuccessResponse;
26+
import org.apache.cloudstack.api.response.UcsBladeResponse;
27+
import org.apache.log4j.Logger;
28+
29+
import javax.inject.Inject;
30+
31+
/**
32+
* Created with IntelliJ IDEA.
33+
* User: frank
34+
* Date: 9/13/13
35+
* Time: 6:23 PM
36+
* To change this template use File | Settings | File Templates.
37+
*/
38+
@APICommand(name="disassociateUcsProfileFromBlade", description="disassociate a profile from a blade", responseObject=UcsBladeResponse.class)
39+
public class DisassociateUcsProfileCmd extends BaseAsyncCmd {
40+
private static Logger logger = Logger.getLogger(DisassociateUcsProfileCmd.class);
41+
42+
@Inject
43+
private UcsManager mgr;
44+
45+
@Parameter(name=ApiConstants.UCS_BLADE_ID, type=CommandType.UUID, entityType=UcsBladeResponse.class, description="blade id", required=true)
46+
private Long bladeId;
47+
48+
@Parameter(name=ApiConstants.UCS_DELETE_PROFILE, type=CommandType.BOOLEAN, description="is deleting profile after disassociating")
49+
private boolean deleteProfile;
50+
51+
@Override
52+
public String getEventType() {
53+
return EventTypes.EVENT_UCS_DISASSOCIATED_PROFILE;
54+
}
55+
56+
@Override
57+
public String getEventDescription() {
58+
return "disassociate a profile from blade";
59+
}
60+
61+
public Long getBladeId() {
62+
return bladeId;
63+
}
64+
65+
public void setBladeId(Long bladeId) {
66+
this.bladeId = bladeId;
67+
}
68+
69+
public boolean isDeleteProfile() {
70+
return deleteProfile;
71+
}
72+
73+
public void setDeleteProfile(boolean deleteProfile) {
74+
this.deleteProfile = deleteProfile;
75+
}
76+
77+
@Override
78+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
79+
try {
80+
UcsBladeResponse rsp = mgr.disassociateProfile(this);
81+
rsp.setResponseName(getCommandName());
82+
this.setResponseObject(rsp);
83+
} catch(Exception e) {
84+
logger.warn(e.getMessage(), e);
85+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
86+
}
87+
}
88+
89+
@Override
90+
public String getCommandName() {
91+
return "disassociateucsprofilefrombladeresponse";
92+
}
93+
94+
@Override
95+
public long getEntityOwnerId() {
96+
return Account.ACCOUNT_ID_SYSTEM;
97+
}
98+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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;
19+
20+
import com.cloud.event.EventTypes;
21+
import com.cloud.exception.*;
22+
import com.cloud.ucs.manager.UcsManager;
23+
import com.cloud.user.Account;
24+
import org.apache.cloudstack.api.response.UcsBladeResponse;
25+
import org.apache.cloudstack.api.response.UcsManagerResponse;
26+
import org.apache.log4j.Logger;
27+
28+
import javax.inject.Inject;
29+
30+
/**
31+
* Created with IntelliJ IDEA.
32+
* User: frank
33+
* Date: 10/8/13
34+
* Time: 3:17 PM
35+
* To change this template use File | Settings | File Templates.
36+
*/
37+
@APICommand(name="instantiateUcsTemplateAndAssocaciateToBlade", description="create a profile of template and associate to a blade", responseObject=UcsBladeResponse.class)
38+
public class InstantiateUcsTemplateAndAssociateToBladeCmd extends BaseAsyncCmd{
39+
public static final Logger s_logger = Logger.getLogger(InstantiateUcsTemplateAndAssociateToBladeCmd.class);
40+
41+
@Inject
42+
private UcsManager mgr;
43+
44+
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type= BaseCmd.CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
45+
private Long ucsManagerId;
46+
@Parameter(name=ApiConstants.UCS_TEMPLATE_DN, type= BaseCmd.CommandType.STRING, description="template dn", required=true)
47+
private String templateDn;
48+
@Parameter(name=ApiConstants.UCS_BLADE_ID, type= BaseCmd.CommandType.UUID, entityType=UcsBladeResponse.class, description="blade id", required=true)
49+
private Long bladeId;
50+
@Parameter(name=ApiConstants.UCS_PROFILE_NAME, type= BaseCmd.CommandType.STRING, description="profile name")
51+
private String profileName;
52+
53+
@Override
54+
public String getEventType() {
55+
return EventTypes.EVENT_UCS_INSTANTIATE_TEMPLATE_AND_ASSOCIATE;
56+
}
57+
58+
@Override
59+
public String getEventDescription() {
60+
return "create a profile off template and associate to a blade";
61+
}
62+
63+
@Override
64+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
65+
try {
66+
UcsBladeResponse rsp = mgr.instantiateTemplateAndAssociateToBlade(this);
67+
rsp.setResponseName(getCommandName());
68+
this.setResponseObject(rsp);
69+
} catch (Exception e) {
70+
s_logger.warn("Exception: ", e);
71+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
72+
}
73+
}
74+
75+
@Override
76+
public String getCommandName() {
77+
return "instantiateucstemplateandassociatetobladeresponse";
78+
}
79+
80+
@Override
81+
public long getEntityOwnerId() {
82+
return Account.ACCOUNT_ID_SYSTEM;
83+
}
84+
85+
public Long getUcsManagerId() {
86+
return ucsManagerId;
87+
}
88+
89+
public void setUcsManagerId(Long ucsManagerId) {
90+
this.ucsManagerId = ucsManagerId;
91+
}
92+
93+
public String getTemplateDn() {
94+
return templateDn;
95+
}
96+
97+
public void setTemplateDn(String templateDn) {
98+
this.templateDn = templateDn;
99+
}
100+
101+
public Long getBladeId() {
102+
return bladeId;
103+
}
104+
105+
public void setBladeId(Long bladeId) {
106+
this.bladeId = bladeId;
107+
}
108+
109+
public String getProfileName() {
110+
return profileName;
111+
}
112+
113+
public void setProfileName(String profileName) {
114+
this.profileName = profileName;
115+
}
116+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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;
19+
20+
import com.cloud.exception.*;
21+
import com.cloud.ucs.manager.UcsManager;
22+
import org.apache.cloudstack.api.response.ListResponse;
23+
import org.apache.cloudstack.api.response.UcsManagerResponse;
24+
import org.apache.cloudstack.api.response.UcsProfileResponse;
25+
import org.apache.cloudstack.api.response.UcsTemplateResponse;
26+
import org.apache.log4j.Logger;
27+
28+
import javax.inject.Inject;
29+
30+
/**
31+
* Created with IntelliJ IDEA.
32+
* User: frank
33+
* Date: 10/8/13
34+
* Time: 3:08 PM
35+
* To change this template use File | Settings | File Templates.
36+
*/
37+
@APICommand(name="listUcsTemplates", description="List templates in ucs manager", responseObject=UcsTemplateResponse.class)
38+
public class ListUcsTemplatesCmd extends BaseListCmd {
39+
public static final Logger s_logger = Logger.getLogger(ListUcsTemplatesCmd.class);
40+
41+
@Inject
42+
UcsManager mgr;
43+
44+
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type= BaseCmd.CommandType.UUID, entityType=UcsManagerResponse.class, description="the id for the ucs manager", required=true)
45+
private Long ucsManagerId;
46+
47+
@Override
48+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
49+
try {
50+
ListResponse<UcsTemplateResponse> response = mgr.listUcsTemplates(this);
51+
response.setResponseName(getCommandName());
52+
response.setObjectName("ucstemplate");
53+
this.setResponseObject(response);
54+
} catch (Exception e) {
55+
s_logger.warn("Exception: ", e);
56+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
57+
}
58+
}
59+
60+
@Override
61+
public String getCommandName() {
62+
return "listucstemplatesresponse";
63+
}
64+
65+
public Long getUcsManagerId() {
66+
return ucsManagerId;
67+
}
68+
69+
public void setUcsManagerId(Long ucsManagerId) {
70+
this.ucsManagerId = ucsManagerId;
71+
}
72+
}

0 commit comments

Comments
 (0)