You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/04/05 23:03:26 UTC
[31/50] [abbrv] Removing ^M's from code.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/database/UcsManagerVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/database/UcsManagerVO.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/database/UcsManagerVO.java
index cd8371b..416ba95 100644
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/database/UcsManagerVO.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/database/UcsManagerVO.java
@@ -14,85 +14,85 @@
// 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;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
+//
+package com.cloud.ucs.database;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+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")
+@Entity
+@Table(name="ucs_manager")
public class UcsManagerVO implements InternalIdentity, Identity {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="id")
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
private long id;
-
- @Column(name="zone_id")
+
+ @Column(name="zone_id")
private long zoneId;
-
- @Column(name="uuid")
+
+ @Column(name="uuid")
private String uuid;
-
- @Column(name="name")
+
+ @Column(name="name")
private String name;
-
- @Column(name="url")
+
+ @Column(name="url")
private String url;
-
- @Column(name="username")
+
+ @Column(name="username")
private String username;
-
- @Column(name="password")
- private String password;
-
- public long getId() {
- return id;
- }
- public void setId(long id) {
- this.id = id;
- }
- public String getUuid() {
- return uuid;
- }
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
- public String getUrl() {
- return url;
- }
- public void setUrl(String url) {
- this.url = url;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public long getZoneId() {
- return zoneId;
- }
- public void setZoneId(long zoneId) {
- this.zoneId = zoneId;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
+
+ @Column(name="password")
+ private String password;
+
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public String getUuid() {
+ return uuid;
+ }
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ public String getUsername() {
+ return username;
+ }
+ public void setUsername(String username) {
+ this.username = username;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public long getZoneId() {
+ return zoneId;
+ }
+ public void setZoneId(long zoneId) {
+ this.zoneId = zoneId;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
}
-}
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java
index ce8e40e..274cfbd 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java
@@ -14,113 +14,113 @@
// 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;
-
-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.BaseCmd.CommandType;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
+//
+package com.cloud.ucs.manager;
+
+import javax.inject.Inject;
+
+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.BaseCmd.CommandType;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ZoneResponse;
-import org.apache.log4j.Logger;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.server.ManagementService;
-import com.cloud.user.Account;
-
-@APICommand(name="addUcsManager", description="Adds a Ucs manager", responseObject=UcsManagerResponse.class)
-public class AddUcsManagerCmd extends BaseCmd {
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.server.ManagementService;
+import com.cloud.user.Account;
+
+@APICommand(name="addUcsManager", description="Adds a Ucs manager", responseObject=UcsManagerResponse.class)
+public class AddUcsManagerCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddUcsManagerCmd.class);
-
- @Inject
- private UcsManager mgr;
-
- @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, description="the Zone id for the ucs manager", entityType=ZoneResponse.class, required=true)
+
+ @Inject
+ private UcsManager mgr;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, description="the Zone id for the ucs manager", entityType=ZoneResponse.class, required=true)
private Long zoneId;
-
- @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of UCS manager")
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of UCS manager")
private String name;
-
- @Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the name of UCS url", required=true)
+
+ @Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the name of UCS url", required=true)
private String url;
-
- @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of UCS", required=true)
+
+ @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of UCS", required=true)
private String username;
-
- @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="the password of UCS", required=true)
+
+ @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="the password of UCS", required=true)
private String password;
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
- ResourceAllocationException, NetworkRuleConflictException {
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+ ResourceAllocationException, NetworkRuleConflictException {
try {
- UcsManagerResponse rsp = mgr.addUcsManager(this);
+ UcsManagerResponse rsp = mgr.addUcsManager(this);
rsp.setObjectName("ucsmanager");
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 "addUcsManagerResponse";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- public void setZoneId(Long zoneId) {
- this.zoneId = zoneId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
-}
+ } catch (Exception e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return "addUcsManagerResponse";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public void setZoneId(Long zoneId) {
+ this.zoneId = zoneId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java
index c463828..0f95bb9 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java
@@ -14,83 +14,83 @@
// 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;
-
-import org.apache.cloudstack.api.APICommand;
+//
+package com.cloud.ucs.manager;
+
+import javax.inject.Inject;
+
+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.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.log4j.Logger;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-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=UcsBladeResponse.class)
-public class AssociateUcsProfileToBladeCmd extends BaseCmd {
- public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
-
- @Inject
- private UcsManager mgr;
-
- @Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
- 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, entityType=UcsBladeResponse.class, description="blade id", required=true)
- private Long bladeId;
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
- ResourceAllocationException, NetworkRuleConflictException {
- try {
- UcsBladeResponse rsp = mgr.associateProfileToBlade(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 "associateucsprofiletobladeresponse";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- public Long getUcsManagerId() {
- return ucsManagerId;
- }
-
- public void setUcsManagerId(Long ucsManagerId) {
- this.ucsManagerId = ucsManagerId;
- }
-
- public String getProfileDn() {
- return profileDn;
- }
-
- public void setProfileDn(String profileDn) {
- this.profileDn = profileDn;
- }
-
- public Long getBladeId() {
- return bladeId;
- }
-
- public void setBladeId(Long bladeId) {
- this.bladeId = bladeId;
- }
-}
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+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=UcsBladeResponse.class)
+public class AssociateUcsProfileToBladeCmd extends BaseCmd {
+ public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
+
+ @Inject
+ private UcsManager mgr;
+
+ @Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
+ 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, entityType=UcsBladeResponse.class, description="blade id", required=true)
+ private Long bladeId;
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+ ResourceAllocationException, NetworkRuleConflictException {
+ try {
+ UcsBladeResponse rsp = mgr.associateProfileToBlade(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 "associateucsprofiletobladeresponse";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ public Long getUcsManagerId() {
+ return ucsManagerId;
+ }
+
+ public void setUcsManagerId(Long ucsManagerId) {
+ this.ucsManagerId = ucsManagerId;
+ }
+
+ public String getProfileDn() {
+ return profileDn;
+ }
+
+ public void setProfileDn(String profileDn) {
+ this.profileDn = profileDn;
+ }
+
+ public Long getBladeId() {
+ return bladeId;
+ }
+
+ public void setBladeId(Long bladeId) {
+ this.bladeId = bladeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsBladeCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsBladeCmd.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsBladeCmd.java
index 5440e4f..3c6587e 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsBladeCmd.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsBladeCmd.java
@@ -1,87 +1,87 @@
-// 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 javax.inject.Inject;
-
-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;
-import org.apache.log4j.Logger;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.user.Account;
-
-@APICommand(name="listUcsBlade", description="List ucs blades", responseObject=UcsBladeResponse.class)
-public class ListUcsBladeCmd extends BaseListCmd {
- public static final Logger s_logger = Logger.getLogger(ListUcsBladeCmd.class);
-
- @Inject
- private UcsManager mgr;
-
- @Parameter(name=ApiConstants.UCS_MANAGER_ID, type=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;
- }
-
- public Long getUcsManagerId() {
- return ucsManagerId;
- }
-
- public void setUcsManagerId(Long ucsManagerId) {
- this.ucsManagerId = ucsManagerId;
- }
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
- ResourceAllocationException, NetworkRuleConflictException {
- try {
- ListResponse<UcsBladeResponse> response = mgr.listUcsBlades(this);
- response.setResponseName(getCommandName());
- response.setObjectName("ucsblade");
- this.setResponseObject(response);
- } catch (Exception e) {
- s_logger.warn(e.getMessage(), e);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
- }
- }
-
- @Override
- public String getCommandName() {
- return "listucsbladeresponse";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-}
+// 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 javax.inject.Inject;
+
+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;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.user.Account;
+
+@APICommand(name="listUcsBlade", description="List ucs blades", responseObject=UcsBladeResponse.class)
+public class ListUcsBladeCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListUcsBladeCmd.class);
+
+ @Inject
+ private UcsManager mgr;
+
+ @Parameter(name=ApiConstants.UCS_MANAGER_ID, type=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;
+ }
+
+ public Long getUcsManagerId() {
+ return ucsManagerId;
+ }
+
+ public void setUcsManagerId(Long ucsManagerId) {
+ this.ucsManagerId = ucsManagerId;
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+ ResourceAllocationException, NetworkRuleConflictException {
+ try {
+ ListResponse<UcsBladeResponse> response = mgr.listUcsBlades(this);
+ response.setResponseName(getCommandName());
+ response.setObjectName("ucsblade");
+ this.setResponseObject(response);
+ } catch (Exception e) {
+ s_logger.warn(e.getMessage(), e);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return "listucsbladeresponse";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java
index 862f631..e705b17 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java
@@ -23,66 +23,66 @@
//
// 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;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiErrorCode;
-import org.apache.cloudstack.api.BaseCmd;
+package com.cloud.ucs.manager;
+
+import javax.inject.Inject;
+
+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;
-import org.apache.log4j.Logger;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.server.ManagementService;
-import com.cloud.user.Account;
-@APICommand(description="List ucs manager", responseObject=UcsManagerResponse.class)
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+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 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)
- private Long zoneId;
-
- @Inject
- private UcsManager mgr;
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the zone id", required=true)
+ private Long zoneId;
+
+ @Inject
+ private UcsManager mgr;
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException {
- try {
- ListResponse<UcsManagerResponse> response = mgr.listUcsManager(this);
+ try {
+ ListResponse<UcsManagerResponse> response = mgr.listUcsManager(this);
response.setResponseName(getCommandName());
response.setObjectName("ucsmanager");
- this.setResponseObject(response);
- } catch (Exception e) {
- s_logger.warn("Exception: ", e);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
- }
- }
-
- @Override
- public String getCommandName() {
- return "listucsmanagerreponse";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- public Long getZoneId() {
- return zoneId;
- }
-
- public void setZoneId(Long zoneId) {
- this.zoneId = zoneId;
- }
-}
+ this.setResponseObject(response);
+ } catch (Exception e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return "listucsmanagerreponse";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ public void setZoneId(Long zoneId) {
+ this.zoneId = zoneId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java
index c8a2cc5..7bc4dec 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java
@@ -14,68 +14,68 @@
// 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;
-
-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.BaseCmd.CommandType;
+//
+package com.cloud.ucs.manager;
+
+import javax.inject.Inject;
+
+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.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;
-import org.apache.log4j.Logger;
-
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.NetworkRuleConflictException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.server.ManagementService;
-import com.cloud.user.Account;
-@APICommand(name="listUcsProfile", description="List profile in ucs manager", responseObject=UcsProfileResponse.class)
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.server.ManagementService;
+import com.cloud.user.Account;
+@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);
-
+ public static final Logger s_logger = Logger.getLogger(ListUcsProfileCmd.class);
+
@Inject UcsManager mgr;
-
- @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() {
- return ucsManagerId;
- }
-
- public void setUcsManagerId(Long ucsManagerId) {
- this.ucsManagerId = ucsManagerId;
- }
-
- @Override
- public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+
+ @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() {
+ return ucsManagerId;
+ }
+
+ public void setUcsManagerId(Long ucsManagerId) {
+ this.ucsManagerId = ucsManagerId;
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException {
- try {
+ try {
ListResponse<UcsProfileResponse> response = mgr.listUcsProfiles(this);
response.setResponseName(getCommandName());
response.setObjectName("ucsprofiles");
this.setResponseObject(response);
- } catch (Exception e) {
- s_logger.warn("Exception: ", e);
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
- }
- }
-
- @Override
- public String getCommandName() {
- return "listucsprofileresponse";
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
-}
+ } catch (Exception e) {
+ s_logger.warn("Exception: ", e);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return "listucsprofileresponse";
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/StringTemplate.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/StringTemplate.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/StringTemplate.java
index 72bbfcb..a6b17c9 100644
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/StringTemplate.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/StringTemplate.java
@@ -14,26 +14,26 @@
// 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;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class StringTemplate {
- public static String replaceTokens(String text, Map<String, String> replacements) {
- Pattern pattern = Pattern.compile("\\[(.+?)\\]");
- Matcher matcher = pattern.matcher(text);
- StringBuffer buffer = new StringBuffer();
- while (matcher.find()) {
- String replacement = replacements.get(matcher.group(1));
- if (replacement != null) {
- matcher.appendReplacement(buffer, "");
- buffer.append(replacement);
- }
- }
- matcher.appendTail(buffer);
- return buffer.toString();
- }
-}
+//
+package com.cloud.ucs.manager;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class StringTemplate {
+ public static String replaceTokens(String text, Map<String, String> replacements) {
+ Pattern pattern = Pattern.compile("\\[(.+?)\\]");
+ Matcher matcher = pattern.matcher(text);
+ StringBuffer buffer = new StringBuffer();
+ while (matcher.find()) {
+ String replacement = replacements.get(matcher.group(1));
+ if (replacement != null) {
+ matcher.appendReplacement(buffer, "");
+ buffer.append(replacement);
+ }
+ }
+ matcher.appendTail(buffer);
+ return buffer.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsBladeResponse.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsBladeResponse.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsBladeResponse.java
index 862b206..b06d62a 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsBladeResponse.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsBladeResponse.java
@@ -1,84 +1,84 @@
-// 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.ApiConstants;
-import org.apache.cloudstack.api.BaseResponse;
-import org.apache.cloudstack.api.EntityReference;
-
-import com.cloud.serializer.Param;
-import com.cloud.ucs.database.UcsBladeVO;
-import com.google.gson.annotations.SerializedName;
-@EntityReference(value=UcsBladeVO.class)
-public class UcsBladeResponse extends BaseResponse {
- @SerializedName(ApiConstants.ID)
- @Param(description = "ucs blade id")
- private String id;
- @SerializedName(ApiConstants.UCS_MANAGER_ID)
- @Param(description = "ucs manager id")
- private String ucsManagerId;
- @SerializedName(ApiConstants.HOST_ID)
- @Param(description = "cloudstack host id this blade associates to")
- private String hostId;
- @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;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getUcsManagerId() {
- return ucsManagerId;
- }
-
- public void setUcsManagerId(String ucsManagerId) {
- this.ucsManagerId = ucsManagerId;
- }
-
- public String getHostId() {
- return hostId;
- }
-
- public void setHostId(String hostId) {
- this.hostId = hostId;
- }
-
- public String getDn() {
- return dn;
- }
-
- public void setDn(String dn) {
- this.dn = dn;
- }
-
- public String getAssociatedProfileDn() {
- return associatedProfileDn;
- }
-
- public void setAssociatedProfileDn(String associatedProfileDn) {
- this.associatedProfileDn = associatedProfileDn;
- }
-
-}
+// 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.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.serializer.Param;
+import com.cloud.ucs.database.UcsBladeVO;
+import com.google.gson.annotations.SerializedName;
+@EntityReference(value=UcsBladeVO.class)
+public class UcsBladeResponse extends BaseResponse {
+ @SerializedName(ApiConstants.ID)
+ @Param(description = "ucs blade id")
+ private String id;
+ @SerializedName(ApiConstants.UCS_MANAGER_ID)
+ @Param(description = "ucs manager id")
+ private String ucsManagerId;
+ @SerializedName(ApiConstants.HOST_ID)
+ @Param(description = "cloudstack host id this blade associates to")
+ private String hostId;
+ @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;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getUcsManagerId() {
+ return ucsManagerId;
+ }
+
+ public void setUcsManagerId(String ucsManagerId) {
+ this.ucsManagerId = ucsManagerId;
+ }
+
+ public String getHostId() {
+ return hostId;
+ }
+
+ public void setHostId(String hostId) {
+ this.hostId = hostId;
+ }
+
+ public String getDn() {
+ return dn;
+ }
+
+ public void setDn(String dn) {
+ this.dn = dn;
+ }
+
+ public String getAssociatedProfileDn() {
+ return associatedProfileDn;
+ }
+
+ public void setAssociatedProfileDn(String associatedProfileDn) {
+ this.associatedProfileDn = associatedProfileDn;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsCommands.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsCommands.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsCommands.java
index eb99991..9bb77a2 100644
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsCommands.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsCommands.java
@@ -14,87 +14,87 @@
// 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;
-
-public class UcsCommands {
- public static String loginCmd(String username, String password) {
- XmlObject cmd = new XmlObject("aaaLogin");
- cmd.putElement("inName", username);
- cmd.putElement("inPassword", password);
- return cmd.dump();
- }
-
- public static String listComputeBlades(String cookie) {
- XmlObject cmd = new XmlObject("configResolveClass");
- cmd.putElement("classId", "computeBlade");
- cmd.putElement("cookie", cookie);
- cmd.putElement("inHierarchical", "false");
- return cmd.dump();
- }
-
- public static String listProfiles(String cookie) {
- XmlObject cmd = new XmlObject("configFindDnsByClassId");
- cmd.putElement("classId", "lsServer");
- cmd.putElement("cookie", cookie);
- return cmd.dump();
- }
-
- public static String cloneProfile(String cookie, String srcDn, String newProfileName) {
- XmlObject cmd = new XmlObject("lsClone");
- cmd.putElement("cookie", cookie);
- cmd.putElement("dn", srcDn);
- cmd.putElement("inTargetOrg", "org-root");
- cmd.putElement("inServerName", newProfileName);
- cmd.putElement("inHierarchical", "false");
- return cmd.dump();
- }
-
- public static String configResolveDn(String cookie, String dn) {
- XmlObject cmd = new XmlObject("configResolveDn");
- cmd.putElement("cookie", cookie);
- cmd.putElement("dn", dn);
- return cmd.toString();
- }
-
- public static String associateProfileToBlade(String cookie, String profileDn, String bladeDn) {
- XmlObject cmd = new XmlObject("configConfMos").putElement("inHierarchical", "true").putElement(
- "inConfigs", new XmlObject("inConfigs").putElement(
- "pair", new XmlObject("pair").putElement("key", profileDn).putElement(
- "lsServer", new XmlObject("lsServer")
- .putElement("agentPolicyName", "")
- .putElement("biosProfileName", "")
- .putElement("bootPolicyName", "")
- .putElement("descr", "")
- .putElement("dn", profileDn)
- .putElement("dynamicConPolicyName", "")
- .putElement("extIPState", "none")
- .putElement("hostFwPolicyName", "")
- .putElement("identPoolName", "")
- .putElement("localDiskPolicyName", "")
- .putElement("maintPolicyName", "")
- .putElement("mgmtAccessPolicyName", "")
- .putElement("mgmtFwPolicyName", "")
- .putElement("powerPolicyName", "")
- .putElement("scrubPolicyName", "")
- .putElement("solPolicyName", "")
- .putElement("srcTemplName", "")
- .putElement("statsPolicyName", "default")
- .putElement("status", "")
- .putElement("usrLbl", "")
- .putElement("uuid", "")
- .putElement("vconProfileName", "")
- .putElement("lsBinding", new XmlObject("lsBinding")
- .putElement("pnDn", bladeDn)
- .putElement("restrictMigration", "no")
- .putElement("rn", "pn")
- )
- )
- )
- );
-
- return cmd.dump();
- }
-}
+//
+package com.cloud.ucs.manager;
+
+import com.cloud.utils.xmlobject.XmlObject;
+
+public class UcsCommands {
+ public static String loginCmd(String username, String password) {
+ XmlObject cmd = new XmlObject("aaaLogin");
+ cmd.putElement("inName", username);
+ cmd.putElement("inPassword", password);
+ return cmd.dump();
+ }
+
+ public static String listComputeBlades(String cookie) {
+ XmlObject cmd = new XmlObject("configResolveClass");
+ cmd.putElement("classId", "computeBlade");
+ cmd.putElement("cookie", cookie);
+ cmd.putElement("inHierarchical", "false");
+ return cmd.dump();
+ }
+
+ public static String listProfiles(String cookie) {
+ XmlObject cmd = new XmlObject("configFindDnsByClassId");
+ cmd.putElement("classId", "lsServer");
+ cmd.putElement("cookie", cookie);
+ return cmd.dump();
+ }
+
+ public static String cloneProfile(String cookie, String srcDn, String newProfileName) {
+ XmlObject cmd = new XmlObject("lsClone");
+ cmd.putElement("cookie", cookie);
+ cmd.putElement("dn", srcDn);
+ cmd.putElement("inTargetOrg", "org-root");
+ cmd.putElement("inServerName", newProfileName);
+ cmd.putElement("inHierarchical", "false");
+ return cmd.dump();
+ }
+
+ public static String configResolveDn(String cookie, String dn) {
+ XmlObject cmd = new XmlObject("configResolveDn");
+ cmd.putElement("cookie", cookie);
+ cmd.putElement("dn", dn);
+ return cmd.toString();
+ }
+
+ public static String associateProfileToBlade(String cookie, String profileDn, String bladeDn) {
+ XmlObject cmd = new XmlObject("configConfMos").putElement("inHierarchical", "true").putElement(
+ "inConfigs", new XmlObject("inConfigs").putElement(
+ "pair", new XmlObject("pair").putElement("key", profileDn).putElement(
+ "lsServer", new XmlObject("lsServer")
+ .putElement("agentPolicyName", "")
+ .putElement("biosProfileName", "")
+ .putElement("bootPolicyName", "")
+ .putElement("descr", "")
+ .putElement("dn", profileDn)
+ .putElement("dynamicConPolicyName", "")
+ .putElement("extIPState", "none")
+ .putElement("hostFwPolicyName", "")
+ .putElement("identPoolName", "")
+ .putElement("localDiskPolicyName", "")
+ .putElement("maintPolicyName", "")
+ .putElement("mgmtAccessPolicyName", "")
+ .putElement("mgmtFwPolicyName", "")
+ .putElement("powerPolicyName", "")
+ .putElement("scrubPolicyName", "")
+ .putElement("solPolicyName", "")
+ .putElement("srcTemplName", "")
+ .putElement("statsPolicyName", "default")
+ .putElement("status", "")
+ .putElement("usrLbl", "")
+ .putElement("uuid", "")
+ .putElement("vconProfileName", "")
+ .putElement("lsBinding", new XmlObject("lsBinding")
+ .putElement("pnDn", bladeDn)
+ .putElement("restrictMigration", "no")
+ .putElement("rn", "pn")
+ )
+ )
+ )
+ );
+
+ return cmd.dump();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsHttpClient.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsHttpClient.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsHttpClient.java
index 5c60601..66d2ed2 100644
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsHttpClient.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsHttpClient.java
@@ -14,42 +14,42 @@
// 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;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class UcsHttpClient {
- private static HttpClient client = new HttpClient();
- private String url;
-
- public UcsHttpClient(String ip) {
- this.url = String.format("http://%s/nuova", ip);
- }
-
- public String call(String xml) {
- PostMethod post = new PostMethod(url);
- post.setRequestEntity(new StringRequestEntity(xml));
- post.setRequestHeader("Content-type", "text/xml");
- try {
- int result = client.executeMethod(post);
- if (result != 200) {
- throw new CloudRuntimeException("Call failed: " + post.getResponseBodyAsString());
- }
+//
+package com.cloud.ucs.manager;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class UcsHttpClient {
+ private static HttpClient client = new HttpClient();
+ private String url;
+
+ public UcsHttpClient(String ip) {
+ this.url = String.format("http://%s/nuova", ip);
+ }
+
+ public String call(String xml) {
+ PostMethod post = new PostMethod(url);
+ post.setRequestEntity(new StringRequestEntity(xml));
+ post.setRequestHeader("Content-type", "text/xml");
+ try {
+ int result = client.executeMethod(post);
+ if (result != 200) {
+ throw new CloudRuntimeException("Call failed: " + 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 {
- post.releaseConnection();
- }
- }
-}
+ return res;
+ } catch (Exception e) {
+ throw new CloudRuntimeException(e.getMessage(), e);
+ } finally {
+ post.releaseConnection();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManager.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManager.java
index aa45f8c..7250318 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManager.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManager.java
@@ -14,22 +14,22 @@
// 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;
+//
+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, PluggableService {
- UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd);
-
+
+public interface UcsManager extends Manager, PluggableService {
+ UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd);
+
ListResponse<UcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd);
-
- ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd);
-
+
+ ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd);
+
UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd);
-
- ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd);
-}
+
+ ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
index f428e03..e0aefcf 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
@@ -14,262 +14,262 @@
// 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;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.ResponseGenerator;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.ClusterResponse;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cxf.helpers.FileUtils;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.dc.ClusterDetailsDao;
+//
+package com.cloud.ucs.manager;
+
+import java.io.File;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.ResponseGenerator;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cxf.helpers.FileUtils;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.DataCenterVO;
-import com.cloud.dc.dao.ClusterDao;
+import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.host.HostVO;
+import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.org.Cluster;
-import com.cloud.resource.ResourceService;
-import com.cloud.ucs.database.UcsBladeDao;
-import com.cloud.ucs.database.UcsBladeVO;
-import com.cloud.ucs.database.UcsManagerDao;
-import com.cloud.ucs.database.UcsManagerVO;
-import com.cloud.ucs.structure.ComputeBlade;
-import com.cloud.ucs.structure.UcsProfile;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.Script;
-import com.cloud.utils.xmlobject.XmlObject;
-import com.cloud.utils.xmlobject.XmlObjectParser;
-
-@Local(value = { UcsManager.class })
-public class UcsManagerImpl implements UcsManager {
- public static final Logger s_logger = Logger.getLogger(UcsManagerImpl.class);
-
- @Inject
- private UcsManagerDao ucsDao;
- @Inject
- private ResourceService resourceService;
- @Inject
- private ClusterDao clusterDao;
- @Inject
- private ClusterDetailsDao clusterDetailsDao;
- @Inject
- private UcsBladeDao bladeDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.org.Cluster;
+import com.cloud.resource.ResourceService;
+import com.cloud.ucs.database.UcsBladeDao;
+import com.cloud.ucs.database.UcsBladeVO;
+import com.cloud.ucs.database.UcsManagerDao;
+import com.cloud.ucs.database.UcsManagerVO;
+import com.cloud.ucs.structure.ComputeBlade;
+import com.cloud.ucs.structure.UcsProfile;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+import com.cloud.utils.xmlobject.XmlObject;
+import com.cloud.utils.xmlobject.XmlObjectParser;
+
+@Local(value = { UcsManager.class })
+public class UcsManagerImpl implements UcsManager {
+ public static final Logger s_logger = Logger.getLogger(UcsManagerImpl.class);
+
+ @Inject
+ private UcsManagerDao ucsDao;
+ @Inject
+ private ResourceService resourceService;
+ @Inject
+ private ClusterDao clusterDao;
+ @Inject
+ private ClusterDetailsDao clusterDetailsDao;
+ @Inject
+ private UcsBladeDao bladeDao;
@Inject
- private HostDao hostDao;
+ private HostDao hostDao;
@Inject
private DataCenterDao dcDao;
-
+
private Map<Long, String> cookies = new HashMap<Long, String>();
private String name;
private int runLevel;
- private Map<String, Object> params;
-
- @Override
- public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
- return true;
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- return true;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- private void discoverBlades(UcsManagerVO ucsMgrVo) {
- List<ComputeBlade> blades = listBlades(ucsMgrVo.getId());
- for (ComputeBlade b : blades) {
- UcsBladeVO vo = new UcsBladeVO();
- vo.setDn(b.getDn());
- vo.setUcsManagerId(ucsMgrVo.getId());
- vo.setUuid(UUID.randomUUID().toString());
- bladeDao.persist(vo);
- }
- }
-
- @Override
- @DB
- public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
- UcsManagerVO vo = new UcsManagerVO();
- vo.setUuid(UUID.randomUUID().toString());
- vo.setPassword(cmd.getPassword());
- vo.setUrl(cmd.getUrl());
- vo.setUsername(cmd.getUsername());
- vo.setZoneId(cmd.getZoneId());
- vo.setName(cmd.getName());
-
- Transaction txn = Transaction.currentTxn();
- txn.start();
- ucsDao.persist(vo);
- txn.commit();
- UcsManagerResponse rsp = new UcsManagerResponse();
- rsp.setId(String.valueOf(vo.getId()));
- rsp.setName(vo.getName());
- rsp.setUrl(vo.getUrl());
- rsp.setZoneId(String.valueOf(vo.getZoneId()));
-
- discoverBlades(vo);
-
- return rsp;
- }
-
- private String getCookie(Long ucsMgrId) {
- try {
- String cookie = cookies.get(ucsMgrId);
- if (cookie == null) {
- UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
- UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
- String login = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
+ private Map<String, Object> params;
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ return true;
+ }
+
+ @Override
+ public boolean start() {
+ return true;
+ }
+
+ @Override
+ public boolean stop() {
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ private void discoverBlades(UcsManagerVO ucsMgrVo) {
+ List<ComputeBlade> blades = listBlades(ucsMgrVo.getId());
+ for (ComputeBlade b : blades) {
+ UcsBladeVO vo = new UcsBladeVO();
+ vo.setDn(b.getDn());
+ vo.setUcsManagerId(ucsMgrVo.getId());
+ vo.setUuid(UUID.randomUUID().toString());
+ bladeDao.persist(vo);
+ }
+ }
+
+ @Override
+ @DB
+ public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
+ UcsManagerVO vo = new UcsManagerVO();
+ vo.setUuid(UUID.randomUUID().toString());
+ vo.setPassword(cmd.getPassword());
+ vo.setUrl(cmd.getUrl());
+ vo.setUsername(cmd.getUsername());
+ vo.setZoneId(cmd.getZoneId());
+ vo.setName(cmd.getName());
+
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ ucsDao.persist(vo);
+ txn.commit();
+ UcsManagerResponse rsp = new UcsManagerResponse();
+ rsp.setId(String.valueOf(vo.getId()));
+ rsp.setName(vo.getName());
+ rsp.setUrl(vo.getUrl());
+ rsp.setZoneId(String.valueOf(vo.getZoneId()));
+
+ discoverBlades(vo);
+
+ return rsp;
+ }
+
+ private String getCookie(Long ucsMgrId) {
+ try {
+ String cookie = cookies.get(ucsMgrId);
+ if (cookie == null) {
+ UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
+ UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
+ String login = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
String ret = client.call(login);
XmlObject xo = XmlObjectParser.parseFromString(ret);
- cookie = xo.get("outCookie");
- cookies.put(ucsMgrId, cookie);
- }
-
- return cookie;
- } catch (Exception e) {
- throw new CloudRuntimeException("Cannot get cookie", e);
- }
- }
-
- private List<ComputeBlade> listBlades(Long ucsMgrId) {
- String cookie = getCookie(ucsMgrId);
- UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
- UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
- String cmd = UcsCommands.listComputeBlades(cookie);
- String ret = client.call(cmd);
- return ComputeBlade.fromXmString(ret);
- }
-
- private List<UcsProfile> getUcsProfiles(Long ucsMgrId) {
- String cookie = getCookie(ucsMgrId);
- UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
- String cmd = UcsCommands.listProfiles(cookie);
- UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
- String res = client.call(cmd);
- List<UcsProfile> profiles = UcsProfile.fromXmlString(res);
- return profiles;
- }
-
- @Override
- public ListResponse<UcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd) {
- List<UcsProfile> profiles = getUcsProfiles(cmd.getUcsManagerId());
- ListResponse<UcsProfileResponse> response = new ListResponse<UcsProfileResponse>();
- List<UcsProfileResponse> rs = new ArrayList<UcsProfileResponse>();
- for (UcsProfile p : profiles) {
- UcsProfileResponse r = new UcsProfileResponse();
- r.setObjectName("ucsprofile");
- r.setDn(p.getDn());
- rs.add(r);
- }
- response.setResponses(rs);
- return response;
- }
-
- private String cloneProfile(Long ucsMgrId, String srcDn, String newProfileName) {
- UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
- UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
- String cookie = getCookie(ucsMgrId);
- String cmd = UcsCommands.cloneProfile(cookie, srcDn, newProfileName);
- String res = client.call(cmd);
- XmlObject xo = XmlObjectParser.parseFromString(res);
- return xo.get("outConfig.lsServer.dn");
- }
-
- private boolean isProfileAssociated(Long ucsMgrId, String dn) {
- UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
- UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
- String cookie = getCookie(ucsMgrId);
- String cmd = UcsCommands.configResolveDn(cookie, dn);
- String res = client.call(cmd);
- XmlObject xo = XmlObjectParser.parseFromString(res);
- return xo.get("outConfig.computeBlade.association").equals("associated");
- }
-
- @Override
- 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());
- UcsBladeVO bvo = q.find();
- if (bvo == null) {
- throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
- }
-
- if (bvo.getHostId() != null) {
- throw new CloudRuntimeException(String.format("blade[id:%s, dn:%s] has been associated with host[id:%s]", bvo.getId(), bvo.getDn(), bvo.getHostId()));
- }
-
- UcsManagerVO mgrvo = ucsDao.findById(cmd.getUcsManagerId());
- String cookie = getCookie(cmd.getUcsManagerId());
- String pdn = cloneProfile(mgrvo.getId(), cmd.getProfileDn(), "profile-for-blade-" + bvo.getId());
- String ucscmd = UcsCommands.associateProfileToBlade(cookie, pdn, bvo.getDn());
- UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
- String res = client.call(ucscmd);
- int count = 0;
- int timeout = 600;
- while (count < timeout) {
- if (isProfileAssociated(mgrvo.getId(), bvo.getDn())) {
- break;
- }
-
- try {
- TimeUnit.SECONDS.sleep(2);
- } catch (InterruptedException e) {
- throw new CloudRuntimeException(e);
- }
-
- count += 2;
- }
-
- if (count >= timeout) {
- throw new CloudRuntimeException(String.format("associating profile[%s] to balde[%s] timeout after 600 seconds", pdn, bvo.getDn()));
- }
-
+ cookie = xo.get("outCookie");
+ cookies.put(ucsMgrId, cookie);
+ }
+
+ return cookie;
+ } catch (Exception e) {
+ throw new CloudRuntimeException("Cannot get cookie", e);
+ }
+ }
+
+ private List<ComputeBlade> listBlades(Long ucsMgrId) {
+ String cookie = getCookie(ucsMgrId);
+ UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
+ UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
+ String cmd = UcsCommands.listComputeBlades(cookie);
+ String ret = client.call(cmd);
+ return ComputeBlade.fromXmString(ret);
+ }
+
+ private List<UcsProfile> getUcsProfiles(Long ucsMgrId) {
+ String cookie = getCookie(ucsMgrId);
+ UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
+ String cmd = UcsCommands.listProfiles(cookie);
+ UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
+ String res = client.call(cmd);
+ List<UcsProfile> profiles = UcsProfile.fromXmlString(res);
+ return profiles;
+ }
+
+ @Override
+ public ListResponse<UcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd) {
+ List<UcsProfile> profiles = getUcsProfiles(cmd.getUcsManagerId());
+ ListResponse<UcsProfileResponse> response = new ListResponse<UcsProfileResponse>();
+ List<UcsProfileResponse> rs = new ArrayList<UcsProfileResponse>();
+ for (UcsProfile p : profiles) {
+ UcsProfileResponse r = new UcsProfileResponse();
+ r.setObjectName("ucsprofile");
+ r.setDn(p.getDn());
+ rs.add(r);
+ }
+ response.setResponses(rs);
+ return response;
+ }
+
+ private String cloneProfile(Long ucsMgrId, String srcDn, String newProfileName) {
+ UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
+ UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
+ String cookie = getCookie(ucsMgrId);
+ String cmd = UcsCommands.cloneProfile(cookie, srcDn, newProfileName);
+ String res = client.call(cmd);
+ XmlObject xo = XmlObjectParser.parseFromString(res);
+ return xo.get("outConfig.lsServer.dn");
+ }
+
+ private boolean isProfileAssociated(Long ucsMgrId, String dn) {
+ UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
+ UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
+ String cookie = getCookie(ucsMgrId);
+ String cmd = UcsCommands.configResolveDn(cookie, dn);
+ String res = client.call(cmd);
+ XmlObject xo = XmlObjectParser.parseFromString(res);
+ return xo.get("outConfig.computeBlade.association").equals("associated");
+ }
+
+ @Override
+ 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());
+ UcsBladeVO bvo = q.find();
+ if (bvo == null) {
+ throw new IllegalArgumentException(String.format("cannot find UCS blade[id:%s, ucs manager id:%s]", cmd.getBladeId(), cmd.getUcsManagerId()));
+ }
+
+ if (bvo.getHostId() != null) {
+ throw new CloudRuntimeException(String.format("blade[id:%s, dn:%s] has been associated with host[id:%s]", bvo.getId(), bvo.getDn(), bvo.getHostId()));
+ }
+
+ UcsManagerVO mgrvo = ucsDao.findById(cmd.getUcsManagerId());
+ String cookie = getCookie(cmd.getUcsManagerId());
+ String pdn = cloneProfile(mgrvo.getId(), cmd.getProfileDn(), "profile-for-blade-" + bvo.getId());
+ String ucscmd = UcsCommands.associateProfileToBlade(cookie, pdn, bvo.getDn());
+ UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
+ String res = client.call(ucscmd);
+ int count = 0;
+ int timeout = 600;
+ while (count < timeout) {
+ if (isProfileAssociated(mgrvo.getId(), bvo.getDn())) {
+ break;
+ }
+
+ try {
+ TimeUnit.SECONDS.sleep(2);
+ } catch (InterruptedException e) {
+ throw new CloudRuntimeException(e);
+ }
+
+ count += 2;
+ }
+
+ 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()));
- return rsp;
+ return rsp;
}
-
+
private String hostIdToUuid(Long hostId) {
if (hostId == null) {
return null;
@@ -284,31 +284,31 @@ public class UcsManagerImpl implements UcsManager {
}
private String ucsManagerIdToUuid(Long ucsMgrId) {
- UcsManagerVO vo = ucsDao.findById(ucsMgrId);
+ UcsManagerVO vo = ucsDao.findById(ucsMgrId);
return vo.getUuid();
}
-
- @Override
- public ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd) {
+
+ @Override
+ public ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd) {
SearchCriteriaService<UcsManagerVO, UcsManagerVO> serv = SearchCriteria2.create(UcsManagerVO.class);
serv.addAnd(serv.getEntity().getZoneId(), Op.EQ, cmd.getZoneId());
List<UcsManagerVO> vos = serv.list();
-
+
List<UcsManagerResponse> rsps = new ArrayList<UcsManagerResponse>(vos.size());
for (UcsManagerVO vo : vos) {
- UcsManagerResponse rsp = new UcsManagerResponse();
+ UcsManagerResponse rsp = new UcsManagerResponse();
rsp.setObjectName("ucsmanager");
- rsp.setId(vo.getUuid());
+ rsp.setId(vo.getUuid());
rsp.setName(vo.getName());
- rsp.setUrl(vo.getUrl());
- rsp.setZoneId(zoneIdToUuid(vo.getZoneId()));
+ rsp.setUrl(vo.getUrl());
+ rsp.setZoneId(zoneIdToUuid(vo.getZoneId()));
rsps.add(rsp);
}
ListResponse<UcsManagerResponse> response = new ListResponse<UcsManagerResponse>();
- response.setResponses(rsps);
- return response;
+ response.setResponses(rsps);
+ return response;
}
-
+
private UcsBladeResponse bladeVOToResponse(UcsBladeVO vo) {
UcsBladeResponse rsp = new UcsBladeResponse();
rsp.setObjectName("ucsblade");
@@ -332,33 +332,33 @@ public class UcsManagerImpl implements UcsManager {
ListResponse<UcsBladeResponse> response = new ListResponse<UcsBladeResponse>();
response.setResponses(rsps);
-
+
return response;
- }
-
- @Override
+ }
+
+ @Override
public void setName(String name) {
- this.name = name;
- }
-
- @Override
+ this.name = name;
+ }
+
+ @Override
public void setConfigParams(Map<String, Object> params) {
- this.params = params;
- }
-
- @Override
- public Map<String, Object> getConfigParams() {
- return this.params;
- }
-
- @Override
- public int getRunLevel() {
- return runLevel;
- }
-
- @Override
+ this.params = params;
+ }
+
+ @Override
+ public Map<String, Object> getConfigParams() {
+ return this.params;
+ }
+
+ @Override
+ public int getRunLevel() {
+ return runLevel;
+ }
+
+ @Override
public void setRunLevel(int level) {
- this.runLevel = level;
+ this.runLevel = level;
}
@Override
@@ -370,5 +370,5 @@ public class UcsManagerImpl implements UcsManager {
cmds.add(AddUcsManagerCmd.class);
cmds.add(AssociateUcsProfileToBladeCmd.class);
return cmds;
- }
-}
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerResponse.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerResponse.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerResponse.java
index 6a82dae..e389a83 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerResponse.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerResponse.java
@@ -14,60 +14,60 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-//
-package com.cloud.ucs.manager;
-
+//
+package com.cloud.ucs.manager;
+
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.EntityReference;
-
-import org.apache.cloudstack.api.BaseResponse;
-
-import com.cloud.serializer.Param;
+
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
import com.cloud.ucs.database.UcsManagerVO;
-import com.google.gson.annotations.SerializedName;
-@EntityReference(value=UcsManagerVO.class)
-public class UcsManagerResponse extends BaseResponse {
- @SerializedName(ApiConstants.ID) @Param(description="the ID of the ucs manager")
+import com.google.gson.annotations.SerializedName;
+@EntityReference(value=UcsManagerVO.class)
+public class UcsManagerResponse extends BaseResponse {
+ @SerializedName(ApiConstants.ID) @Param(description="the ID of the ucs manager")
private String id;
-
- @SerializedName(ApiConstants.NAME) @Param(description="the name of ucs manager")
+
+ @SerializedName(ApiConstants.NAME) @Param(description="the name of ucs manager")
private String name;
-
- @SerializedName(ApiConstants.URL) @Param(description="the url of ucs manager")
+
+ @SerializedName(ApiConstants.URL) @Param(description="the url of ucs manager")
private String url;
-
- @SerializedName(ApiConstants.ZONE_ID) @Param(description="the zone ID of ucs manager")
- private String zoneId;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getZoneId() {
- return zoneId;
- }
-
- public void setZoneId(String zoneId) {
- this.zoneId = zoneId;
- }
-}
+
+ @SerializedName(ApiConstants.ZONE_ID) @Param(description="the zone ID of ucs manager")
+ private String zoneId;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getZoneId() {
+ return zoneId;
+ }
+
+ public void setZoneId(String zoneId) {
+ this.zoneId = zoneId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/469c4dd1/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsProfileResponse.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsProfileResponse.java b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsProfileResponse.java
index 0621f6f..14a2215 100755
--- a/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsProfileResponse.java
+++ b/plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsProfileResponse.java
@@ -14,24 +14,24 @@
// 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;
-import org.apache.cloudstack.api.BaseResponse;
-
-import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
-
-public class UcsProfileResponse extends BaseResponse {
- @SerializedName(ApiConstants.UCS_DN) @Param(description="ucs profile dn")
+//
+package com.cloud.ucs.manager;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+public class UcsProfileResponse extends BaseResponse {
+ @SerializedName(ApiConstants.UCS_DN) @Param(description="ucs profile dn")
private String dn;
-
- public String getDn() {
- return dn;
- }
-
- public void setDn(String dn) {
- this.dn = dn;
+
+ public String getDn() {
+ return dn;
+ }
+
+ public void setDn(String dn) {
+ this.dn = dn;
}
-}
+}