mirror of https://github.com/apache/cloudstack.git
add missing files during merging UCS
This commit is contained in:
parent
80e88dd482
commit
ae19fc98e1
|
|
@ -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.ucs.structure;
|
||||
|
||||
import com.cloud.utils.xmlobject.XmlObject;
|
||||
import com.cloud.utils.xmlobject.XmlObjectParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: frank
|
||||
* Date: 10/8/13
|
||||
* Time: 3:01 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class UcsTemplate {
|
||||
private String dn;
|
||||
|
||||
public static List<UcsTemplate> fromXmlString(String xmlstr) {
|
||||
List<UcsTemplate> tmps = new ArrayList<UcsTemplate>();
|
||||
XmlObject xo = XmlObjectParser.parseFromString(xmlstr);
|
||||
List<XmlObject> xos = xo.getAsList("outConfigs.lsServer");
|
||||
if (xos != null) {
|
||||
for (XmlObject x : xos) {
|
||||
UcsTemplate t = new UcsTemplate();
|
||||
t.setDn(x.get("dn").toString());
|
||||
tmps.add(t);
|
||||
}
|
||||
}
|
||||
return tmps;
|
||||
}
|
||||
|
||||
public String getDn() {
|
||||
return dn;
|
||||
}
|
||||
|
||||
public void setDn(String dn) {
|
||||
this.dn = dn;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
// 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 org.apache.cloudstack.api;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
|
||||
import com.cloud.exception.*;
|
||||
import com.cloud.ucs.manager.UcsManager;
|
||||
import com.cloud.user.Account;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.api.response.UcsBladeResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: frank
|
||||
* Date: 9/13/13
|
||||
* Time: 6:23 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@APICommand(name="disassociateUcsProfileFromBlade", description="disassociate a profile from a blade", responseObject=UcsBladeResponse.class)
|
||||
public class DisassociateUcsProfileCmd extends BaseAsyncCmd {
|
||||
private static Logger logger = Logger.getLogger(DisassociateUcsProfileCmd.class);
|
||||
|
||||
@Inject
|
||||
private UcsManager mgr;
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_BLADE_ID, type=CommandType.UUID, entityType=UcsBladeResponse.class, description="blade id", required=true)
|
||||
private Long bladeId;
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_DELETE_PROFILE, type=CommandType.BOOLEAN, description="is deleting profile after disassociating")
|
||||
private boolean deleteProfile;
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_UCS_DISASSOCIATED_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "disassociate a profile from blade";
|
||||
}
|
||||
|
||||
public Long getBladeId() {
|
||||
return bladeId;
|
||||
}
|
||||
|
||||
public void setBladeId(Long bladeId) {
|
||||
this.bladeId = bladeId;
|
||||
}
|
||||
|
||||
public boolean isDeleteProfile() {
|
||||
return deleteProfile;
|
||||
}
|
||||
|
||||
public void setDeleteProfile(boolean deleteProfile) {
|
||||
this.deleteProfile = deleteProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
UcsBladeResponse rsp = mgr.disassociateProfile(this);
|
||||
rsp.setResponseName(getCommandName());
|
||||
this.setResponseObject(rsp);
|
||||
} catch(Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "disassociateucsprofilefrombladeresponse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
// 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 org.apache.cloudstack.api;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.*;
|
||||
import com.cloud.ucs.manager.UcsManager;
|
||||
import com.cloud.user.Account;
|
||||
import org.apache.cloudstack.api.response.UcsBladeResponse;
|
||||
import org.apache.cloudstack.api.response.UcsManagerResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: frank
|
||||
* Date: 10/8/13
|
||||
* Time: 3:17 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@APICommand(name="instantiateUcsTemplateAndAssocaciateToBlade", description="create a profile of template and associate to a blade", responseObject=UcsBladeResponse.class)
|
||||
public class InstantiateUcsTemplateAndAssociateToBladeCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(InstantiateUcsTemplateAndAssociateToBladeCmd.class);
|
||||
|
||||
@Inject
|
||||
private UcsManager mgr;
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type= BaseCmd.CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
|
||||
private Long ucsManagerId;
|
||||
@Parameter(name=ApiConstants.UCS_TEMPLATE_DN, type= BaseCmd.CommandType.STRING, description="template dn", required=true)
|
||||
private String templateDn;
|
||||
@Parameter(name=ApiConstants.UCS_BLADE_ID, type= BaseCmd.CommandType.UUID, entityType=UcsBladeResponse.class, description="blade id", required=true)
|
||||
private Long bladeId;
|
||||
@Parameter(name=ApiConstants.UCS_PROFILE_NAME, type= BaseCmd.CommandType.STRING, description="profile name")
|
||||
private String profileName;
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_UCS_INSTANTIATE_TEMPLATE_AND_ASSOCIATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "create a profile off template and associate to a blade";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
UcsBladeResponse rsp = mgr.instantiateTemplateAndAssociateToBlade(this);
|
||||
rsp.setResponseName(getCommandName());
|
||||
this.setResponseObject(rsp);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "instantiateucstemplateandassociatetobladeresponse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
public Long getUcsManagerId() {
|
||||
return ucsManagerId;
|
||||
}
|
||||
|
||||
public void setUcsManagerId(Long ucsManagerId) {
|
||||
this.ucsManagerId = ucsManagerId;
|
||||
}
|
||||
|
||||
public String getTemplateDn() {
|
||||
return templateDn;
|
||||
}
|
||||
|
||||
public void setTemplateDn(String templateDn) {
|
||||
this.templateDn = templateDn;
|
||||
}
|
||||
|
||||
public Long getBladeId() {
|
||||
return bladeId;
|
||||
}
|
||||
|
||||
public void setBladeId(Long bladeId) {
|
||||
this.bladeId = bladeId;
|
||||
}
|
||||
|
||||
public String getProfileName() {
|
||||
return profileName;
|
||||
}
|
||||
|
||||
public void setProfileName(String profileName) {
|
||||
this.profileName = profileName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
// 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 org.apache.cloudstack.api;
|
||||
|
||||
import com.cloud.exception.*;
|
||||
import com.cloud.ucs.manager.UcsManager;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.UcsManagerResponse;
|
||||
import org.apache.cloudstack.api.response.UcsProfileResponse;
|
||||
import org.apache.cloudstack.api.response.UcsTemplateResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: frank
|
||||
* Date: 10/8/13
|
||||
* Time: 3:08 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@APICommand(name="listUcsTemplates", description="List templates in ucs manager", responseObject=UcsTemplateResponse.class)
|
||||
public class ListUcsTemplatesCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListUcsTemplatesCmd.class);
|
||||
|
||||
@Inject
|
||||
UcsManager mgr;
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type= BaseCmd.CommandType.UUID, entityType=UcsManagerResponse.class, description="the id for the ucs manager", required=true)
|
||||
private Long ucsManagerId;
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
ListResponse<UcsTemplateResponse> response = mgr.listUcsTemplates(this);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("ucstemplate");
|
||||
this.setResponseObject(response);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Exception: ", e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "listucstemplatesresponse";
|
||||
}
|
||||
|
||||
public Long getUcsManagerId() {
|
||||
return ucsManagerId;
|
||||
}
|
||||
|
||||
public void setUcsManagerId(Long ucsManagerId) {
|
||||
this.ucsManagerId = ucsManagerId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
// 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 org.apache.cloudstack.api;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.*;
|
||||
import com.cloud.ucs.manager.UcsManager;
|
||||
import com.cloud.user.Account;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.UcsBladeResponse;
|
||||
import org.apache.cloudstack.api.response.UcsManagerResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: frank
|
||||
* Date: 10/3/13
|
||||
* Time: 2:18 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
@APICommand(name="refreshUcsBlades", description="refresh ucs blades to sync with UCS manager", responseObject=UcsBladeResponse.class)
|
||||
public class RefreshUcsBladesCmd extends BaseListCmd {
|
||||
private static Logger s_logger = Logger.getLogger(RefreshUcsBladesCmd.class);
|
||||
|
||||
@Inject
|
||||
private UcsManager mgr;
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type= BaseCmd.CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
|
||||
private Long ucsManagerId;
|
||||
|
||||
public UcsManager getMgr() {
|
||||
return mgr;
|
||||
}
|
||||
|
||||
public void setMgr(UcsManager mgr) {
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
ListResponse<UcsBladeResponse> response = mgr.refreshBlades(ucsManagerId);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("ucsblade");
|
||||
this.setResponseObject(response);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("unhandled exception:", e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "refreshucsbladesresponse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// 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 org.apache.cloudstack.api.response;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
public class UcsTemplateResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.UCS_DN) @Param(description="ucs template dn")
|
||||
private String dn;
|
||||
|
||||
public String getDn() {
|
||||
return dn;
|
||||
}
|
||||
|
||||
public void setDn(String dn) {
|
||||
this.dn = dn;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue