This commit is contained in:
Joe Brockmeier 2013-02-28 19:00:13 -06:00
commit 13ec069129
30 changed files with 203 additions and 151 deletions

View File

@ -35,8 +35,6 @@
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-utils</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -90,6 +90,11 @@
<artifactId>cloud-plugin-hypervisor-baremetal</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-hypervisor-ucs</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-hypervisor-ovm</artifactId>

View File

@ -58,6 +58,9 @@
<bean id="BaremetalKickStartPxeService" class="com.cloud.baremetal.networkservice.BaremetalKickStartServiceImpl"/>
<bean id="BaremetalPingPxeService" class="com.cloud.baremetal.networkservice.BareMetalPingServiceImpl" />
<bean id="BaremetalPxeManager" class="com.cloud.baremetal.networkservice.BaremetalPxeManagerImpl" />
<bean id="UcsManager" class="com.cloud.ucs.manager.UcsManagerImpl" />
<bean id="UcsBladeDao" class="com.cloud.ucs.database.UcsBladeDaoImpl" />
<bean id="UcsManagerDao" class="com.cloud.ucs.database.UcsManagerDaoImpl" />
<!--

View File

@ -1,41 +0,0 @@
// 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.engine.cloud.entity.api;
import com.cloud.utils.component.ComponentContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;
@Component
public class VirtualMachineEntityFactory implements FactoryBean<VirtualMachineEntityImpl>{
@Override
public VirtualMachineEntityImpl getObject() throws Exception {
return ComponentContext.inject(VirtualMachineEntityImpl.class.newInstance());
}
@Override
public Class<?> getObjectType() {
return VirtualMachineEntityImpl.class;
}
@Override
public boolean isSingleton() {
return false;
}
}

View File

@ -29,7 +29,6 @@ import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityFactory;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
@ -66,9 +65,6 @@ public class CloudOrchestrator implements OrchestrationService {
@Inject
private VMEntityManager vmEntityManager;
@Inject
private VirtualMachineEntityFactory _vmEntityFactory;
@Inject
private VirtualMachineManager _itMgr;
@ -174,12 +170,7 @@ public class CloudOrchestrator implements OrchestrationService {
}
}
VirtualMachineEntityImpl vmEntity = null;
try {
vmEntity = _vmEntityFactory.getObject();
} catch (Exception e) {
// add error handling here
}
VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));

View File

@ -5,15 +5,16 @@
// 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.database;
import com.cloud.utils.db.GenericDao;

View File

@ -5,22 +5,25 @@
// 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.database;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
@Local(value = { UcsBladeDao.class })
@Local(value = { UcsBladeDao.class })
@DB(txn = false)
public class UcsBladeDaoImpl extends GenericDaoBase<UcsBladeVO, Long> implements UcsBladeDao {

View File

@ -5,15 +5,16 @@
// 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.database;
import javax.persistence.Column;
@ -22,10 +23,13 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name="ucs_blade")
public class UcsBladeVO {
public class UcsBladeVO implements InternalIdentity, Identity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
@ -42,6 +46,9 @@ public class UcsBladeVO {
@Column(name="dn")
private String dn;
@Column(name="profile_dn")
private String profileDn;
public long getId() {
return id;
@ -82,4 +89,12 @@ public class UcsBladeVO {
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getProfileDn() {
return profileDn;
}
public void setProfileDn(String profileDn) {
this.profileDn = profileDn;
}
}

View File

@ -5,15 +5,16 @@
// 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.database;
import java.util.List;

View File

@ -5,23 +5,26 @@
// 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.database;
import javax.ejb.Local;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
@Local(value = { UcsManagerDao.class })
@Local(value = { UcsManagerDao.class })
@DB(txn = false)
public class UcsManagerDaoImpl extends GenericDaoBase<UcsManagerVO, Long> implements UcsManagerDao {
}

View File

@ -5,15 +5,16 @@
// 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.database;
import javax.persistence.Column;
@ -22,10 +23,13 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name="ucs_manager")
public class UcsManagerVO {
public class UcsManagerVO implements InternalIdentity, Identity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")

View File

@ -5,15 +5,16 @@
// 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.manager;
import javax.inject.Inject;

View File

@ -5,15 +5,16 @@
// 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.manager;
import javax.inject.Inject;
@ -32,7 +33,7 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@APICommand(name="associatesUscProfileToBlade", description="associate a profile to a blade", responseObject=AssociateUcsProfileToBladeResponse.class)
@APICommand(name="associatesUscProfileToBlade", description="associate a profile to a blade", responseObject=UcsBladeResponse.class)
public class AssociateUcsProfileToBladeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
@ -43,17 +44,15 @@ public class AssociateUcsProfileToBladeCmd extends BaseCmd {
private Long ucsManagerId;
@Parameter(name=ApiConstants.UCS_PROFILE_DN, type=CommandType.STRING, description="profile dn", required=true)
private String profileDn;
@Parameter(name=ApiConstants.UCS_BLADE_ID, type=CommandType.UUID, description="blade id", required=true)
@Parameter(name=ApiConstants.UCS_BLADE_ID, type=CommandType.UUID, entityType=UcsBladeResponse.class, description="blade id", required=true)
private Long bladeId;
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException {
try {
mgr.associateProfileToBlade(this);
AssociateUcsProfileToBladeResponse rsp = new AssociateUcsProfileToBladeResponse();
UcsBladeResponse rsp = mgr.associateProfileToBlade(this);
rsp.setResponseName(getCommandName());
rsp.setObjectName("associateucsprofiletobalde");
this.setResponseObject(rsp);
} catch (Exception e) {
s_logger.warn("Exception: ", e);

View File

@ -1,22 +0,0 @@
// 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.manager;
import org.apache.cloudstack.api.BaseResponse;
public class AssociateUcsProfileToBladeResponse extends BaseResponse {
}

View File

@ -22,6 +22,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse;
@ -35,7 +36,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@APICommand(name="listUcsBlade", description="List ucs blades", responseObject=UcsBladeResponse.class)
public class ListUcsBladeCmd extends BaseCmd {
public class ListUcsBladeCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListUcsBladeCmd.class);
@Inject

View File

@ -5,15 +5,24 @@
// 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.
//
// Automatically generated by addcopyright.py at 02/28/2013
// regarding copyright ownership. The ASF licenses this file
// "License"); you may not use this file except in compliance
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
package com.cloud.ucs.manager;
import javax.inject.Inject;
@ -22,6 +31,7 @@ import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse;
@ -35,7 +45,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.server.ManagementService;
import com.cloud.user.Account;
@APICommand(description="List ucs manager", responseObject=UcsManagerResponse.class)
public class ListUcsManagerCmd extends BaseCmd {
public class ListUcsManagerCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListUcsManagerCmd.class);
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the zone id", required=true)

View File

@ -5,15 +5,16 @@
// 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.manager;
import javax.inject.Inject;
@ -23,6 +24,7 @@ import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseCmd.CommandType;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse;
@ -35,13 +37,13 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.server.ManagementService;
import com.cloud.user.Account;
@APICommand(description="List profile in ucs manager", responseObject=UcsProfileResponse.class)
public class ListUcsProfileCmd extends BaseCmd {
@APICommand(name="listUcsProfile", description="List profile in ucs manager", responseObject=UcsProfileResponse.class)
public class ListUcsProfileCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListUcsProfileCmd.class);
@Inject UcsManager mgr;
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id for the ucs manager", required=true)
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, entityType=UcsManagerResponse.class, description="the id for the ucs manager", required=true)
private Long ucsManagerId;
public Long getUcsManagerId() {
@ -58,7 +60,7 @@ public class ListUcsProfileCmd extends BaseCmd {
try {
ListResponse<UcsProfileResponse> response = mgr.listUcsProfiles(this);
response.setResponseName(getCommandName());
response.setObjectName("ucsprofile");
response.setObjectName("ucsprofiles");
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Exception: ", e);

View File

@ -5,15 +5,16 @@
// 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.manager;
import java.util.Map;

View File

@ -37,6 +37,9 @@ public class UcsBladeResponse extends BaseResponse {
@SerializedName(ApiConstants.UCS_BLADE_DN)
@Param(description = "ucs blade dn")
private String dn;
@SerializedName(ApiConstants.UCS_PROFILE_DN)
@Param(description = "associated ucs profile dn")
private String associatedProfileDn;
public String getId() {
return id;
@ -69,4 +72,13 @@ public class UcsBladeResponse extends BaseResponse {
public void setDn(String dn) {
this.dn = dn;
}
public String getAssociatedProfileDn() {
return associatedProfileDn;
}
public void setAssociatedProfileDn(String associatedProfileDn) {
this.associatedProfileDn = associatedProfileDn;
}
}

View File

@ -5,15 +5,16 @@
// 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.manager;
import com.cloud.utils.xmlobject.XmlObject;
@ -83,7 +84,7 @@ public class UcsCommands {
.putElement("statsPolicyName", "default")
.putElement("status", "")
.putElement("usrLbl", "")
.putElement("", "")
.putElement("uuid", "")
.putElement("vconProfileName", "")
.putElement("lsBinding", new XmlObject("lsBinding")
.putElement("pnDn", bladeDn)

View File

@ -5,15 +5,16 @@
// 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.manager;
import org.apache.commons.httpclient.HttpClient;
@ -39,7 +40,12 @@ public class UcsHttpClient {
if (result != 200) {
throw new CloudRuntimeException("Call failed: " + post.getResponseBodyAsString());
}
return post.getResponseBodyAsString();
String res = post.getResponseBodyAsString();
if (res.contains("errorCode")) {
String err = String.format("ucs call failed:\nsubmitted doc:%s\nresponse:%s\n", xml, res);
throw new CloudRuntimeException(err);
}
return res;
} catch (Exception e) {
throw new CloudRuntimeException(e.getMessage(), e);
} finally {

View File

@ -5,29 +5,31 @@
// 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.manager;
import org.apache.cloudstack.api.response.ListResponse;
import com.cloud.utils.component.Manager;
import com.cloud.utils.component.PluggableService;
public interface UcsManager extends Manager {
public interface UcsManager extends Manager, PluggableService {
UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd);
ListResponse<UcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd);
ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd);
void associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd);
UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd);
ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd);
}

View File

@ -5,15 +5,16 @@
// 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.manager;
import java.io.File;
@ -67,7 +68,6 @@ import com.cloud.utils.xmlobject.XmlObject;
import com.cloud.utils.xmlobject.XmlObjectParser;
@Local(value = { UcsManager.class })
@Component
public class UcsManagerImpl implements UcsManager {
public static final Logger s_logger = Logger.getLogger(UcsManagerImpl.class);
@ -155,7 +155,9 @@ public class UcsManagerImpl implements UcsManager {
UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
String login = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
cookie = client.call(login);
String ret = client.call(login);
XmlObject xo = XmlObjectParser.parseFromString(ret);
cookie = xo.get("outCookie");
cookies.put(ucsMgrId, cookie);
}
@ -206,7 +208,7 @@ public class UcsManagerImpl implements UcsManager {
String cmd = UcsCommands.cloneProfile(cookie, srcDn, newProfileName);
String res = client.call(cmd);
XmlObject xo = XmlObjectParser.parseFromString(res);
return xo.get("lsClone.outConfig.lsServer.dn");
return xo.get("outConfig.lsServer.dn");
}
private boolean isProfileAssociated(Long ucsMgrId, String dn) {
@ -216,11 +218,11 @@ public class UcsManagerImpl implements UcsManager {
String cmd = UcsCommands.configResolveDn(cookie, dn);
String res = client.call(cmd);
XmlObject xo = XmlObjectParser.parseFromString(res);
return xo.get("outConfig.lsServer.assocState").equals("associated");
return xo.get("outConfig.computeBlade.association").equals("associated");
}
@Override
public void associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd) {
public UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd) {
SearchCriteriaService<UcsBladeVO, UcsBladeVO> q = SearchCriteria2.create(UcsBladeVO.class);
q.addAnd(q.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
q.addAnd(q.getEntity().getId(), Op.EQ, cmd.getBladeId());
@ -258,11 +260,20 @@ public class UcsManagerImpl implements UcsManager {
if (count >= timeout) {
throw new CloudRuntimeException(String.format("associating profile[%s] to balde[%s] timeout after 600 seconds", pdn, bvo.getDn()));
}
bvo.setProfileDn(pdn);
bladeDao.update(bvo.getId(), bvo);
UcsBladeResponse rsp = bladeVOToResponse(bvo);
s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", pdn, bvo.getDn()));
s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", pdn, bvo.getDn()));
return rsp;
}
private String hostIdToUuid(Long hostId) {
if (hostId == null) {
return null;
}
HostVO vo = hostDao.findById(hostId);
return vo.getUuid();
}
@ -298,6 +309,16 @@ public class UcsManagerImpl implements UcsManager {
return response;
}
private UcsBladeResponse bladeVOToResponse(UcsBladeVO vo) {
UcsBladeResponse rsp = new UcsBladeResponse();
rsp.setObjectName("ucsblade");
rsp.setId(vo.getUuid());
rsp.setDn(vo.getDn());
rsp.setHostId(hostIdToUuid(vo.getHostId()));
rsp.setUcsManagerId(ucsManagerIdToUuid(vo.getUcsManagerId()));
return rsp;
}
public ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd) {
SearchCriteriaService<UcsBladeVO, UcsBladeVO> serv = SearchCriteria2.create(UcsBladeVO.class);
serv.addAnd(serv.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
@ -305,12 +326,7 @@ public class UcsManagerImpl implements UcsManager {
List<UcsBladeResponse> rsps = new ArrayList<UcsBladeResponse>(vos.size());
for (UcsBladeVO vo : vos) {
UcsBladeResponse rsp = new UcsBladeResponse();
rsp.setObjectName("ucsblade");
rsp.setId(vo.getUuid());
rsp.setDn(vo.getDn());
rsp.setHostId(hostIdToUuid(vo.getHostId()));
rsp.setUcsManagerId(ucsManagerIdToUuid(vo.getUcsManagerId()));
UcsBladeResponse rsp = bladeVOToResponse(vo);
rsps.add(rsp);
}
@ -343,5 +359,16 @@ public class UcsManagerImpl implements UcsManager {
@Override
public void setRunLevel(int level) {
this.runLevel = level;
}
@Override
public List<Class<?>> getCommands() {
List<Class<?>> cmds = new ArrayList<Class<?>>();
cmds.add(ListUcsBladeCmd.class);
cmds.add(ListUcsManagerCmd.class);
cmds.add(ListUcsProfileCmd.class);
cmds.add(AddUcsManagerCmd.class);
cmds.add(AssociateUcsProfileToBladeCmd.class);
return cmds;
}
}

View File

@ -5,15 +5,16 @@
// 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.manager;
import org.apache.cloudstack.api.ApiConstants;

View File

@ -5,15 +5,16 @@
// 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.manager;
import org.apache.cloudstack.api.ApiConstants;

View File

@ -5,15 +5,16 @@
// 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 java.util.ArrayList;
@ -45,7 +46,7 @@ public class ComputeBlade {
public static List<ComputeBlade> fromXmString(String xmlstr) {
XmlObject root = XmlObjectParser.parseFromString(xmlstr);
List<XmlObject> lst = root.getAsList("configResolveClass.outConfigs.computeBlade");
List<XmlObject> lst = root.getAsList("outConfigs.computeBlade");
List<ComputeBlade> blades = new ArrayList<ComputeBlade>();
if (lst == null) {
return blades;

View File

@ -5,15 +5,16 @@
// 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 java.util.ArrayList;
@ -36,7 +37,9 @@ public class UcsProfile {
List<XmlObject> xos = xo.getAsList("outDns.dn");
if (xos != null) {
for (XmlObject x : xos) {
UcsProfile p = UcsProfile.fromXmlObject(x);
//UcsProfile p = UcsProfile.fromXmlObject(x);
UcsProfile p = new UcsProfile();
p.setDn(x.get("value").toString());
ps.add(p);
}
}

View File

@ -77,8 +77,6 @@
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-utils</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>

View File

@ -1653,4 +1653,26 @@ CREATE TABLE `cloud`.`baremetal_pxe_devices` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`ucs_blade` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`uuid` varchar(40) UNIQUE,
`ucs_manager_id` bigint unsigned NOT NULL,
`host_id` bigint unsigned DEFAULT NULL,
`dn` varchar(512) NOT NULL,
`profile_dn` varchar(512) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`ucs_manager` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`uuid` varchar(40) UNIQUE,
`zone_id` bigint unsigned NOT NULL,
`name` varchar(128) DEFAULT NULL,
`url` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET foreign_key_checks = 1;

View File

@ -40,7 +40,10 @@ public class XmlObject {
this.tag = tag;
}
public XmlObject putElement(String key, Object e) {
public XmlObject putElement(String key, Object e) {
if (e == null) {
throw new IllegalArgumentException(String.format("element[%s] can not be null", key));
}
Object old = elements.get(key);
if (old == null) {
System.out.println(String.format("no %s, add new", key));