-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CLOUDSTACK-9806: Nuage domain template selection per VPC #1981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fmaximus
merged 1 commit into
apache:master
from
nuagenetworks:feature/nuage_vpc_selectable_domain_template
Nov 17, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...work-elements/nuage-vsp/src/com/cloud/agent/api/manager/ListVspDomainTemplatesAnswer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // | ||
| // 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.agent.api.manager; | ||
|
|
||
| import com.cloud.agent.api.Answer; | ||
| import net.nuage.vsp.acs.client.api.model.VspDomainTemplate; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
| public class ListVspDomainTemplatesAnswer extends Answer { | ||
| private List<VspDomainTemplate> domainTemplates; | ||
|
|
||
| public ListVspDomainTemplatesAnswer(ListVspDomainTemplatesCommand command, List<VspDomainTemplate> domainTemplates) { | ||
| super(command); | ||
|
|
||
| this.domainTemplates = domainTemplates; | ||
| } | ||
|
|
||
| public ListVspDomainTemplatesAnswer(ListVspDomainTemplatesCommand command, Exception e) { | ||
| super(command, e); | ||
| } | ||
|
|
||
| public List<VspDomainTemplate> getDomainTemplates() { | ||
| return domainTemplates; | ||
| } | ||
| } |
47 changes: 47 additions & 0 deletions
47
...ork-elements/nuage-vsp/src/com/cloud/agent/api/manager/ListVspDomainTemplatesCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // | ||
| // 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.agent.api.manager; | ||
|
|
||
| import com.cloud.agent.api.Command; | ||
| import net.nuage.vsp.acs.client.api.model.VspDomain; | ||
|
|
||
|
|
||
| public class ListVspDomainTemplatesCommand extends Command { | ||
| private final VspDomain _domain; | ||
| private final String _name; | ||
|
|
||
| public ListVspDomainTemplatesCommand(VspDomain domain, String name) { | ||
| this._domain = domain; | ||
| this._name = name; | ||
| } | ||
|
|
||
| public VspDomain getDomain() { | ||
| return _domain; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return _name; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean executeInSequence() { | ||
| return false; | ||
| } | ||
| } |
111 changes: 111 additions & 0 deletions
111
...ork-elements/nuage-vsp/src/com/cloud/api/commands/AssociateNuageVspDomainTemplateCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| // | ||
| // 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.api.commands; | ||
|
|
||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.exception.InsufficientCapacityException; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.exception.ResourceAllocationException; | ||
| import com.cloud.exception.ResourceUnavailableException; | ||
| import com.cloud.network.manager.NuageVspManager; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| 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.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.PhysicalNetworkResponse; | ||
| import org.apache.cloudstack.api.response.SuccessResponse; | ||
| import org.apache.cloudstack.api.response.VpcResponse; | ||
| import org.apache.cloudstack.api.response.ZoneResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = AssociateNuageVspDomainTemplateCmd.APINAME, responseObject = SuccessResponse.class, description = "associate a vpc with a domain template", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User}) | ||
| public class AssociateNuageVspDomainTemplateCmd extends BaseCmd { | ||
| static final String APINAME = "associateNuageVspDomainTemplate"; | ||
| @Inject | ||
| NuageVspManager _nuageVspManager; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "VPC ID") | ||
| private Long vpcId; | ||
|
|
||
|
|
||
| @Parameter(name = VspConstants.NUAGE_VSP_API_DOMAIN_TEMPLATE, type = CommandType.STRING, required = true, description = "the name of the domain template") | ||
| private String domainTemplate; | ||
|
|
||
| @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the physical network ID") | ||
| private Long physicalNetworkId; | ||
|
|
||
| @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the zone ID") | ||
| private Long zoneId; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| public Long getVpcId() { | ||
| return vpcId; | ||
| } | ||
|
|
||
| public String getDomainTemplate() { return domainTemplate; } | ||
|
|
||
| public Long getZoneId() { return zoneId; } | ||
|
|
||
| public Long getPhysicalNetworkId() { return physicalNetworkId; } | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////// API Implementation/////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { | ||
| try { | ||
| boolean result =_nuageVspManager.associateNuageVspDomainTemplate(this); | ||
| SuccessResponse response = new SuccessResponse(getCommandName()); | ||
| response.setResponseName(getCommandName()); | ||
| response.setSuccess(result); | ||
| this.setResponseObject(response); | ||
| } catch (InvalidParameterValueException invalidParamExcp) { | ||
| throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); | ||
| } catch (CloudRuntimeException runtimeExcp) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String getCommandName() { | ||
| return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccount().getId(); | ||
| } | ||
|
|
||
| } |
120 changes: 120 additions & 0 deletions
120
...network-elements/nuage-vsp/src/com/cloud/api/commands/ListNuageVspDomainTemplatesCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| // | ||
| // 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.api.commands; | ||
|
|
||
| import com.cloud.api.response.NuageVspDomainTemplateResponse; | ||
| import com.cloud.exception.ConcurrentOperationException; | ||
| import com.cloud.exception.InsufficientCapacityException; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.exception.ResourceAllocationException; | ||
| import com.cloud.exception.ResourceUnavailableException; | ||
| import com.cloud.network.manager.NuageVspManager; | ||
| import com.cloud.utils.exception.CloudRuntimeException; | ||
| import org.apache.cloudstack.acl.RoleType; | ||
| 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.BaseResponse; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.DomainResponse; | ||
| import org.apache.cloudstack.api.response.ListResponse; | ||
| import org.apache.cloudstack.api.response.PhysicalNetworkResponse; | ||
| import org.apache.cloudstack.api.response.ZoneResponse; | ||
|
|
||
| import javax.inject.Inject; | ||
| import java.util.List; | ||
|
|
||
| @APICommand(name = ListNuageVspDomainTemplatesCmd.APINAME, responseObject = BaseResponse.class, description = "Lists Nuage VSP domain templates", since = "4.11", responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User}) | ||
| public class ListNuageVspDomainTemplatesCmd extends BaseCmd { | ||
| static final String APINAME = "listNuageVspDomainTemplates"; | ||
|
|
||
| @Inject | ||
| private NuageVspManager _nuageVspManager; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| //////////////// API parameters ///////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, | ||
| description = "the domain ID") | ||
| private Long domainId; | ||
|
|
||
| @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, | ||
| description = "the physical network ID") | ||
| private Long physicalNetworkId; | ||
|
|
||
| @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, | ||
| description = "the zone ID") | ||
| private Long zoneId; | ||
|
|
||
| @Parameter(name = ApiConstants.KEYWORD, type = CommandType.STRING, | ||
| description = "filters the domain templates which contain the keyword") | ||
| private String keyword; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| public String getKeyword() { | ||
| return keyword; | ||
| } | ||
|
|
||
| public Long getDomainId() { | ||
| return domainId; | ||
| } | ||
|
|
||
| public Long getPhysicalNetworkId() { | ||
| return physicalNetworkId; | ||
| } | ||
|
|
||
| public Long getZoneId() { return zoneId; } | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////// API Implementation/////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Override | ||
| public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { | ||
| try { | ||
| List<NuageVspDomainTemplateResponse> responses = _nuageVspManager.listNuageVspDomainTemplates(this); | ||
| ListResponse<NuageVspDomainTemplateResponse> response = new ListResponse<>(); | ||
| response.setResponses(responses); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } catch (InvalidParameterValueException invalidParamExcp) { | ||
| throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); | ||
| } catch (CloudRuntimeException e) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String getCommandName() { | ||
| return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; | ||
| } | ||
|
|
||
| @Override public long getEntityOwnerId() { | ||
| return 0; //not owned by anyone | ||
| } | ||
|
|
||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgoeminn newline here please, thanks.