Updated Branches: refs/heads/4.3 6df26fe50 -> ba894cfe9
add missing files during merging UCS Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ae19fc98 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ae19fc98 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ae19fc98 Branch: refs/heads/4.3 Commit: ae19fc98e1e6f3aaf88012bb45459652dcbe0aa0 Parents: 80e88dd Author: Frank.Zhang <frank.zh...@citrix.com> Authored: Thu Dec 5 22:28:20 2013 -0800 Committer: Frank.Zhang <frank.zh...@citrix.com> Committed: Thu Dec 5 22:28:20 2013 -0800 ---------------------------------------------------------------------- .../com/cloud/ucs/structure/UcsTemplate.java | 57 +++++++++ .../api/DisassociateUcsProfileCmd.java | 98 ++++++++++++++++ ...ntiateUcsTemplateAndAssociateToBladeCmd.java | 116 +++++++++++++++++++ .../cloudstack/api/ListUcsTemplatesCmd.java | 72 ++++++++++++ .../cloudstack/api/RefreshUcsBladesCmd.java | 78 +++++++++++++ .../api/response/UcsTemplateResponse.java | 36 ++++++ 6 files changed, 457 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae19fc98/plugins/hypervisors/ucs/src/com/cloud/ucs/structure/UcsTemplate.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/structure/UcsTemplate.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/structure/UcsTemplate.java new file mode 100644 index 0000000..cbe5590 --- /dev/null +++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/structure/UcsTemplate.java @@ -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; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae19fc98/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/DisassociateUcsProfileCmd.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/DisassociateUcsProfileCmd.java b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/DisassociateUcsProfileCmd.java new file mode 100644 index 0000000..96d662c --- /dev/null +++ b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/DisassociateUcsProfileCmd.java @@ -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; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae19fc98/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/InstantiateUcsTemplateAndAssociateToBladeCmd.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/InstantiateUcsTemplateAndAssociateToBladeCmd.java b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/InstantiateUcsTemplateAndAssociateToBladeCmd.java new file mode 100644 index 0000000..ef7a73f --- /dev/null +++ b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/InstantiateUcsTemplateAndAssociateToBladeCmd.java @@ -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; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae19fc98/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/ListUcsTemplatesCmd.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/ListUcsTemplatesCmd.java b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/ListUcsTemplatesCmd.java new file mode 100644 index 0000000..f0ea2ec --- /dev/null +++ b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/ListUcsTemplatesCmd.java @@ -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; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae19fc98/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/RefreshUcsBladesCmd.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/RefreshUcsBladesCmd.java b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/RefreshUcsBladesCmd.java new file mode 100644 index 0000000..ac9201f --- /dev/null +++ b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/RefreshUcsBladesCmd.java @@ -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; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae19fc98/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/response/UcsTemplateResponse.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/response/UcsTemplateResponse.java b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/response/UcsTemplateResponse.java new file mode 100644 index 0000000..0a31dae --- /dev/null +++ b/plugins/hypervisors/ucs/src/org/apache/cloudstack/api/response/UcsTemplateResponse.java @@ -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; + } +}