cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nlivens <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-8832 : Update Nuage VSP plugin...
Date Tue, 27 Oct 2015 10:12:32 GMT
Github user nlivens commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/801#discussion_r43102657
  
    --- Diff: plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
---
    @@ -152,50 +241,185 @@ public NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd
cmd) {
                 throw new CloudRuntimeException("A NuageVsp device is already configured
on this physical network");
             }
     
    -        Map<String, String> params = new HashMap<String, String>();
    -        params.put("guid", UUID.randomUUID().toString());
    -        params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
    -        params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
    -        params.put("name", "Nuage VSD - " + cmd.getHostName());
    -        params.put("hostname", cmd.getHostName());
    -        params.put("cmsuser", cmd.getUserName());
    -        String cmsUserPasswordBase64 = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.encodeBase64(cmd.getPassword().getBytes(Charset.forName("UTF-8"))));
    -        params.put("cmsuserpass", cmsUserPasswordBase64);
    -        int port = cmd.getPort();
    -        if (0 == port) {
    -            port = 443;
    -        }
    -        params.put("port", String.valueOf(port));
    -        params.put("apirelativepath", "/nuage/api/" + cmd.getApiVersion());
    -        params.put("retrycount", String.valueOf(cmd.getApiRetryCount()));
    -        params.put("retryinterval", String.valueOf(cmd.getApiRetryInterval()));
    +        try {
    +            NuageVspPluginClientLoader clientLoader = NuageVspPluginClientLoader.getClientLoader(null,
null, 1, 1, null);
     
    -        Map<String, Object> hostdetails = new HashMap<String, Object>();
    -        hostdetails.putAll(params);
    +            Map<String, Object> clientDefaults = clientLoader.getNuageVspManagerClient().getClientDefaults();
    +            String apiVersion = MoreObjects.firstNonNull(cmd.getApiVersion(), (String)
clientDefaults.get("CURRENT_API_VERSION"));
    +            if (!clientLoader.getNuageVspManagerClient().isSupportedApiVersion(apiVersion))
{
    +                throw new CloudRuntimeException("Unsupported API version : " + apiVersion);
    +            }
     
    -        try {
    +            Map<String, String> params = new HashMap<String, String>();
    +            params.put("guid", UUID.randomUUID().toString());
    +            params.put("zoneId", String.valueOf(physicalNetwork.getDataCenterId()));
    +            params.put("physicalNetworkId", String.valueOf(physicalNetwork.getId()));
    +            params.put("name", "Nuage VSD - " + cmd.getHostName());
    --- End diff --
    
    Refactored the whole params approach to be more readable and consistent.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message