summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/neutron_utils.py
AgeCommit message (Collapse)AuthorFilesLines
2019-01-24Fix an invalid filter attribute when listing floating ipsCédric Ollivier1-1/+1
The request doesn't conform with API [1] and raises exceptions vs Neutron Hunter: neutronclient.common.exceptions.BadRequest: [u'ip'] is invalid attribute for filtering Neutron server returns request_ids: ['req-857b6294-eea5-46cf-8c95-0e57279ed5e6'] [1] https://developer.openstack.org/api-ref/network/v2/index.html?expanded=list-floating-ips-detail Change-Id: I52bac8806152695834f8ece4f0213c3c63134c79 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
2018-07-24Small fix to network/project when creating ports andspisarski1-2/+5
added new tests for routers that create ports to external and shared networks created by the 'admin' user. Change-Id: I0365e9843e0837d720ca8dd907c45afa2c512047 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-07-11Added additional check for the returned project object is not None.spisarski1-1/+1
There were 3 other instances of this check in neutron_utils.py but this one was missed and could potentially cause issues. Change-Id: I599e63e14a9b08ba34f50e060c7dfa5fbdd631f7 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-06-04Fix to a router's internal subnet resoulution.spisarski1-1/+1
Ensures that any subnet added to the router is available to that project. Change-Id: Iddfad14a093551bc0f4a05c52b20f02db2474d78 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-05-29Fixed issue when attempting to add an internal subnet to a router.spisarski1-14/+11
Internal subnets that are owned by the same user who is creating a router now can be added properly. Attempted to fix an issue with the change in https://gerrit.opnfv.org/gerrit/#/c/57853/ that was allowing for subnets with the same name to be assigned but ended up breaking this functionality completely. JIRA: SNAPS-312 Change-Id: I1687f66db47520e93e401d3e9fb5f0c4f45d460f Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-04-19Fixed bug with regards to subnet lookups.spisarski1-7/+32
Neutron returns all subnets regardless of visibility which cause problems within routers if there is another subnet with the same name attached to a different network. JIRA: SNAPS-304 In addition, this patch contains two other minor fixes. launch_utils.py - raise an exception when the creator is not properly instantiated network.py - allow fixed IPs to be none. Change-Id: Ib343074d925be4592a713727a03d5b531890eada Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-04-17Add listing security groups functionalityManuel Buil1-0/+15
JIRA: SNAPS-302 Be able to list the available security groups Change-Id: I82e2daeb388f4eb3bc8cbc5fd02006b30b959c2f Signed-off-by: Manuel Buil <mbuil@suse.com>
2018-04-04Enable get_project_by_id when only tenant_id is providedLinda Wang1-8/+24
This is to improve: https://gerrit.opnfv.org/gerrit/#/c/52675/ Change-Id: I7228e5eadcc121fe94a869c6cbbeac412d972868 Signed-off-by: Linda Wang <wangwulin@huawei.com>
2018-03-12Closing keystone sessions after done with them.spisarski1-2/+5
By not closing all of the keystone sessions being created when running all of the tests, this may be the root cause to the IOError occasionally being observed: IOError: [Errno 24] Too many open files JIRA: SNAPS-285 Change-Id: I7fc7ab0c6cdd02f1ae32bb3ae4f121cb465d5693 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-02-28Ensure project for routers are handled properly.spisarski1-8/+12
Routers should be able to be created by admin users to other projects. Routers without admin users should only be able to create ones to their default project. JIRA: SNAPS-266 Change-Id: I5ecfbcc2ed94bbab211751da9521f3ec1d4ff66d Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-02-22Changed pattern on how objects lookup themselves by name and project.spisarski1-45/+58
The pattern being replaced has unwittingly added the requirement that all creator credentials must be of type 'admin' as when looking up the associated project ID required a call to keystone.projects.list(). As the SNAPS integration tests were always creating users with an 'admin' role, this issue was not caught. As part of this patch, integration test users will no longer be admin. JIRA: SNAPS-274 Change-Id: I02957f69e31a9d4dfa63362d371f061687e59fbf Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-02-16Ensure project IDs are handled correctly for Network/Subnetsspisarski1-25/+42
JIRA: SNAPS-265 Change-Id: If58f5817e52e21be377d2b06a5f7c3a413454350 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-02-15Added functionality for OpenStackSecurityGroup#initialize() not to acceptspisarski1-4/+6
security groups with the same name from a different project JIRA: SNAPS-264 Change-Id: I7c905e5588d5e503b47ea0e9f5997be89e841aec Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-01-29Changed the way floating IPs are getting assigned to VMs as the previousspisarski1-4/+8
means was not compatible with python-novaclient==10.0.0 JIRA: SNAPS-258 Change-Id: I56f7a8341c81e0ae5596f67d4d15ef6c26e0e680 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2018-01-10Added port security flag support to ports.spisarski1-1/+2
Change-Id: Ib66607b7656093c5f0cd0e2cb4c0aa9c3b9c661a Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-12-01Added ability to add a floating IP to an existing instancespisarski1-6/+6
Patch includes: 1. Ability to easily retrive an initialized OpenStackVmInstance object 2. Added method to OpenStackVmInstance named "add_floating_ip" 3. Tests to ensure floating IPs added after initialization actually work JIRA: SNAPS-241, SNAPS-242 Change-Id: I1f413645a752c17fd624ecff26e851068bb77e3f Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-11-21Refactoring of SecurityGroupSettings to extend SecurityGroupConfigspisarski1-1/+1
SecurityGroupSettings, SecurityGroupSettings and neutron_utils have a runtime cyclical dependency. This patch reduces this dependency and deprecates the SecurityGroupSettings and SecurityGroupRuleSettings class with snaps.config.security_group SecurityGroupConfig and SecurityGroupRuleConfg classes JIRA: SNAPS-224 Change-Id: I6cd82ed5be31f4a24449be767b203e86489b1962 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-11-20Refactoring of NetworkSettings to extend NetworkConfigspisarski1-2/+2
This also includes SubnetSettings extending to SubnetConfig and PortSettings extenting to Portconfig and neutron_utils have a runtime cyclical dependency. This patch reduces this dependency and deprecates the NetworkSettings, SubnetSettings, and PortSettings classes. JIRA: SNAPS-220 Change-Id: I996d73d9b910c075a6511a423f01d966f5b6fb74 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-11-20Refactoring of RouterSettings to extend RouterConfigspisarski1-1/+1
RouterSettings and neutron_utils have a runtime cyclical dependency. This patch reduces this dependency and deprecates the RouterSettings class. JIRA: SNAPS-223 Change-Id: I6a2a5e6e6e86204e62148a57e3525da5862841cf Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-11-08Adding tests for IPv6.spisarski1-17/+79
Included in patch: 1. Refactor Network domain object to include Subnet objects 2. Removed subnet members from OpenStackNetwork 3. Added exhausive IPv6 tests to neutron_utils_tests.py 4. Added two IPv6 integration tests to create_network_tests.py 5. Added two tests where VM instances have ports with IPv6 addresses 6. Updated docs JIRA: SNAPS-178 Change-Id: Id3e5448cb431d2acf47029244fe6773f3f29d368 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-11-06Added method to OpenStackHeatStack to return OpenStackSecurityGroup objects.spisarski1-6/+28
Continuation of the story SNAPS-153 for adding creator/state machine instances for OpenStack objects deployed via Heat. JIRA: SNAPS-207 Change-Id: Id479b69c2b166ab38724c3886096d8483998f819 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-11-02Added method to OpenStackHeatStack to return OpenStackRouter objects.spisarski1-3/+32
Continuation of the story SNAPS-153 for adding creator/state machine instances for OpenStack objects deployed via Heat. JIRA: SNAPS-173 Change-Id: Iac9138ef7827c10db1637447d3a909e714a0301b Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-24Added method to return OpenStackVmInstance from Heat.spisarski1-15/+66
OpenStackHeatStack now can introspect the VMs that the template was responsible for deploying and return an instanitated instance of OpenStackVmInstance for each VM deployed. When the VM has a Floating IP, these instances have the ability to connect via SSH just like one created from scratch. JIRA: SNAPS-172 Change-Id: I5a7ed3a09bb871afc55c718aa80a9069b1eb4da7 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-11Merge "SNAPS Stack creators can now return SNAPS network creators."Steven Pisarski1-0/+29
2017-08-09SNAPS Stack creators can now return SNAPS network creators.spisarski1-0/+29
As Heat Stacks are responsible for spawning objects in OpenStack, the class OpenStackHeatStack which is responsible for applying and managing the state of a stack now can retrieve OpenStackNetwork objects for the networks created in the stack for clients who would like to query the networks and subnets or update them outside of Heat. JIRA: SNAPS-171 Change-Id: I9bf0b81d4f7bfeb1b6392f345022c7d9a57d0415 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-09Added feature to update the quotas on a project/tenant.spisarski1-0/+34
JIRA: SNAPS-170 Change-Id: Icf494dd2bddc338b8e85259b0400c0950d2332bc Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-07Refactored neutron_utils#get_router_by_name() to get_router()spisarski1-7/+18
Added a router_settings (RouterSettings) object parameter in addition to router_name for more robust query options. JIRA: SNAPS-163 Change-Id: I47672f531171d6ee0c90dabb6641640bf97c1d20 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-07Refactored neutron_utils#get_security_group()spisarski1-11/+26
Added a sec_grp_settings (SecurityGroupSettings) object parameter in addition to sec_grp_name for more robust query options. JIRA: SNAPS-164 Change-Id: I8bb21ff9e5e6b1f532773ca01d37964f8b47b530 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-07Merge "Refactored neutron_utils#get_subnet_by_name() to get_subnet()"Steven Pisarski1-10/+35
2017-08-07Merge "Refactored port retrieval to include PortSettigs."Steven Pisarski1-7/+21
2017-08-04Refactored neutron_utils#get_subnet_by_name() to get_subnet()spisarski1-10/+35
Renamed utility function and added a subnet_settings parameter to hold a SubnetSettings object to help make the query more robust by being able to leverage values on the settings object. JIRA: SNAPS-165 Change-Id: I226a1217dc4ba7bb50f7d985ecfaf3b7bc4f610b Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-03Refactored port retrieval to include PortSettigs.spisarski1-7/+21
Refactored neutron_utils#get_port_by_name to get_port while adding in a port_settings object for more robust query options. JIRA: SNAPS-162 Change-Id: I01222ad344224db94615859448ad05d8d5bc0c30 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-03Delete 'default' security group associated to new projects.spisarski1-2/+5
OpenStack can create a security group named 'default' each time a new project/tenant has been created but is not cleaned up when the project has been deleted. This patch adds this functionality into OpenStackProject#clean() method. Also added similar routine to KeystoneUtilsTests#tearDown() method. JIRA: SNAPS-169 Change-Id: I29492ae2ddd82e7d59d09b9c4eb759be4835532a Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-08-02Refactor network retrieval API calls.spisarski1-14/+17
Refactored neutron_utils#get_network() to also accept a NetworkSettings object for more robust queries in addition to the old network_name parameter. Also refactored neutron_utils# get_network_by_id to add in the ID to list_networks((**{'id': id) and returning the first item contains the expected ID value. JIRA: SNAPS-161 Change-Id: Ie670a442dd70633bbef7a1233e630672ebac6b0c Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-28Removed floating IP list from OpenStackVmInstance.spisarski1-4/+18
There was a list and dict both holding the same floating IP objects which has been problematic especially when trying to initialize the object with a VM instance that already exists. JIRA: SNAPS-149 Change-Id: If4af6dfef04a40b9c8cd7a8add484c9ec03f1ef8 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-26Expand OpenStackSecurityGroup class tests.spisarski1-11/+3
Improved validation and added another test case. JIRA: SNAPS-148 Change-Id: I249ac0fcce502dd91c82cc2bfb54ca22da5e33bb Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-25Added region support.spisarski1-1/+2
Added region_name attribute to OSCreds Added region_name to neutron, nova, glance, heat, and keystone client retrieval Fixed false positive heat connection test. JIRA: SNAPS-50 & SNAPS-146 Change-Id: If3471ed7a2bdd0e6bfc281455c996386d031235d Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-18Merge "Created new class NeutronException."Steven Pisarski1-13/+21
2017-07-17Last task necessary to stop users from easily obtaining OS objects.spisarski1-11/+10
Changed external interfaces still exposing OpenStack created APIs to either return SNAPS-OO domain objects or objects contained on the OpenStack generated objects as to not leak implementation details that would eventually break the library when new API versions are released. JIRA: SNAPS-125 Change-Id: Iab6d6d298c4c5da68daed4b1b252313a1595a295 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-17Created new class NeutronException.spisarski1-13/+21
Raising NeutronException in neutron_utils.py instead of Exception. JIRA: SNAPS-128 Change-Id: I567db38a5dfcaae9bbfc6c74558521b0e28d9d46 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-13Created domain classes for networks and subnets.spisarski1-22/+24
Created Network and Subnet domain classes so neutron_utils.py functions returning these types of objects will not be leaking out implementation details as each API version can change these data structures which is now being handled by the SNAPS neutron utility. JIRA: SNAPS-113 Change-Id: Id95dd0f8c2618c20a1a73a428abb95686dfa8251 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-13Created domain class for routers.spisarski1-18/+18
Created Router domain class so neutron_utils.py functions returning router objects will not be leaking out implementation details as each API version can change these data structures and this should all be handled by the SNAPS neutron utility. JIRA: SNAPS-115 & SNAPS-14 Change-Id: Ib6d36a735d835a6ed4ede489b14e33a261458fed Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-13Created domain class for ports.spisarski1-7/+12
Create Port domain class so neutron_utils.py functions returning port objects will not be leaking out implementation details as each API version can change these data structures and this should all be handled by the SNAPS neutron utility. JIRA: SNAPS-118 Change-Id: If031a094a9da284e2838691c3b3490359f710c61 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-07-11Created domain classes for security groups.spisarski1-20/+30
Created SecurityGroup and SecurityGroupRule classes so the neutron_utils for security groups will be returning objects of these types instead of the OpenStack objects returned by the API calls. JIRA: SNAPS-116 Change-Id: I76ed1f85f7d54b984fc6f6ac28cee7680a1109e5 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-06-22Use neutron to create floating IPs.spisarski1-34/+147
This patch moves the floating IP creation out of nova and into neutron. Other changes include the use of domain objects for VM and Floating IP instances, addition of new nova_utils tests to exercise the create server functionality, and more PEP8 compliance. JIRA: SNAPS-92 Change-Id: I16c12b26b56008901633e90ae307586ad2045f9b Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-05-17bugfix: get_security_group_by_id always return first elementMorgan Richomme1-2/+3
add check on id before return value fixed kwarg into the neutron.list_security_groups to the correct one 'id' added unit test to ensure this function always works as designed JIRA: SNAPS-82 Change-Id: I965e1dd54fd1efa8c2d7f6efb87c78ab24cca0e5 Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
2017-05-08Modified code to support both Python 2.7 and 3.xspisarski1-8/+8
* Tested on Python 2.7.10 and 3.4.4 * Updated installation documentation JIRA: SNAPS-30 Change-Id: I94a37d218be8ea47bbbcfb560197737430fcb3ba Signed-off-by: spisarski <s.pisarski@cablelabs.com>
2017-02-15Initial patch with all code from CableLabs repository.spisarski1-0/+405
Change-Id: I70a2778718c5e7f21fd14e4ad28c9269d3761cc7 Signed-off-by: spisarski <s.pisarski@cablelabs.com>