Re: [openstack-dev] [sdk] issues with using OpenStack SDK Python client
Many thanks ! Adding a gateway to a router: it looks like it works in the router creation method, but not in the router update method. (i.e., passing a external_gateway_info dictionary in conn.network.create_router() worked, but doing the same with conn.network.add_gateway_to_router() did not work) the (verbose) code snippet is: external_network = conn.network.find_network(EXTERNAL_NETWORK_NAME) onap_gateway_external_subnets = [] for ext_subn_id in external_network.subnet_ids: onap_gateway_external_subnets.append({'subnet_id':ext_subn_id}) network_dict_body = { 'network_id': external_network.id, 'enable_snat': True, 'external_fixed_ips': onap_gateway_external_subnets} onap_router = conn.network.create_router( name = ONAP_ROUTER_NAME, description = ONAP_ROUTER_DESC, external_gateway_info = network_dict_body, is_admin_state_up = True) I got the idea of trying at creation time, from the create_router API (external_gateway_info entry) at https://developer.openstack.org/api-ref/network/v2/#layer-3-networking (thanks for the tip!) So there might be a difference between how network.create_router() handles this external_gateway_info, versus how network.add_gateway_to_router() handles it. About identity_api_version in clouds.yaml: yep, that works ! About the "!=None" comparison problem: OK, thanks for the fixing effort in progress ! The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [sdk] issues with using OpenStack SDK Python client
more details about router deletion: I tried replacing the "!=None" test with a try statement: try: onap_router = conn.network.find_router(ONAP_ROUTER_NAME) conn.network.delete_router(onap_router.id) (router print-out just before deleting): openstack.network.v2.router.Router(revision=3, distributed=False, status=ACTIVE, tenant_id=03aa47d3bcfd48199e0470b1c86a7f5b, created_at=2018-05-07T20:37:56Z, name=ONAP_router, admin_state_up=True, tags=[], updated_at=2018-05-07T20:37:59Z, ha=False, id=9fc30b97-3942--856a-69c9e2368e02, availability_zone_hints=[], flavor_id=None, description=Router created for ONAP, availability_zones=['nova'], routes=[], external_gateway_info=None) *** traceback.print_exception(): Traceback (most recent call last): File "auto_script_config_openstack_for_onap.py", line 158, in delete_all_ONAP conn.network.delete_router(onap_router.id) File "/usr/local/lib/python3.5/dist-packages/openstack/network/v2/_proxy.py", line 2255, in delete_router self._delete(_router.Router, router, ignore_missing=ignore_missing) File "/usr/local/lib/python3.5/dist-packages/openstack/proxy.py", line 41, in check return method(self, expected, actual, *args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/openstack/proxy.py", line 146, in _delete value=value, File "/usr/local/lib/python3.5/dist-packages/openstack/resource.py", line 847, in delete self._translate_response(response, has_body=False, **kwargs) File "/usr/local/lib/python3.5/dist-packages/openstack/resource.py", line 666, in _translate_response exceptions.raise_from_response(response, error_message=error_message) File "/usr/local/lib/python3.5/dist-packages/openstack/exceptions.py", line 212, in raise_from_response http_status=http_status, request_id=request_id openstack.exceptions.ConflictException: Unable to delete Router for 9fc30b97-3942--856a-69c9e2368e02 (note: deleting the router from either the openstack CLI or from the Horizon GUI works fine) The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
[openstack-dev] [sdk] identity proxy: users, groups, projects, membership, roles
Hi, I'm wondering if there are (or should be) operations in the Connection.identity proxy to manage user and group membership to projects, and to manage user and group role assignments (there are role management methods in the Project class, but I couldn't find them in the identity proxy): The 8 operations could be something like that: add|remove user|group to|from project (i.e., manage 'Member' role for projects) assign|unassign role to|from user|role (any role) Project operations: Connection.identity.add_user_to_project(user, project, ) user: instance or id project: project or id Connection.identity.remove_user_from_project(user, project, ) Connection.identity.add_group_to_project(group, project, ) group: instance or id Connection.identity.remove_group_from_project(group, project, ) Role operations: Connection.identity.assign_role_to_user(role, user, ) Connection.identity.unassign_role_from_user(role, user, ) Connection.identity.assign_role_to_group(role, group, ) Connection.identity.unassign_role_from_group(role, group, ) Cheers, Gerard The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [sdk] issues with using OpenStack SDK Python client
Many thanks for the welcome ;) And many thanks for the speedy and very useful response ! Details below. Best regards, Gerard For add_gateway_to_router(): So I tried this: external_network = conn.network.find_network(EXTERNAL_NETWORK_NAME) network_dict_body = {'network_id' : external_network.id} conn.network.add_gateway_to_router(onap_router, **network_dict_body) ==> no errors, but the router is not updated (no gateway is set) (external_gateway_info is still None) (same with conn.network.add_gateway_to_router(onap_router, network_id=external_network.id) ) Is the body parameter for add_gateway_to_router() expected to correspond to a Network ? (from a router point of view, a "gateway" is an external network) Should the network's subnet(s) be also specified in the dictionary ? Maybe only if certain specific subnets are desired for the gateway role. Otherwise, the default would apply: there is usually only 1 subnet, and that's the one to be used. So network_id would be enough to specify a gateway used in a standard way. Maybe more details about what is expected in this body dictionary should be documented in the add_gateway_to_router() section? In Horizon, when selecting a router, and selecting "Set Gateway", the user is only asked to pick an external network from a dropdown list. Then, a router interface is implicitly created, with an IP@ picked from the subnet of that network. For router deletion: it looks like it's the "!= None" test on the returned object that has an issue onap_router = conn.network.find_router(ONAP_ROUTER_NAME) if onap_router != None: print('Deleting ONAP router...') conn.network.delete_router(onap_router.id) else: print('No ONAP router found...') I added traceback printouts in the code. printing the router before trying to delete it: onap_router: openstack.network.v2.router.Router(updated_at=2018-05-04T21:07:23Z, description=Router created for ONAP, status=ACTIVE, ha=False, name=ONAP_router, created_at=2018-05-04T21:07:20Z, tenant_id=03aa47d3bcfd48199e0470b1c86a7f5b, availability_zone_hints=[], admin_state_up=True, availability_zones=['nova'], tags=[], revision=3, routes=[], id=675abd14-096a-4b28-b764-31ca7098913b, external_gateway_info=None, distributed=False, flavor_id=None) *** Exception: 'NoneType' object has no attribute '_body' *** traceback.print_tb(): File "auto_script_config_openstack_for_onap.py", line 141, in delete_all_ONAP if onap_router != None: File "/usr/local/lib/python3.5/dist-packages/openstack/resource.py", line 358, in __eq__ return all([self._body.attributes == comparand._body.attributes, *** traceback.print_exception(): Traceback (most recent call last): File "auto_script_config_openstack_for_onap.py", line 141, in delete_all_ONAP if onap_router != None: File "/usr/local/lib/python3.5/dist-packages/openstack/resource.py", line 358, in __eq__ return all([self._body.attributes == comparand._body.attributes, AttributeError: 'NoneType' object has no attribute '_body' For identity_api_version=3 : yes, that worked ! Could that identity_api_version parameter also/instead be specified in the clouds.yaml file ? Here's the traceback info for the flavor error, also on the "!= None" test : *** Exception: 'NoneType' object has no attribute '_body' *** traceback.print_tb(): File "auto_script_config_openstack_for_onap.py", line 537, in configure_all_ONAP if tiny_flavor != None: File "/usr/local/lib/python3.5/dist-packages/openstack/resource.py", line 358, in __eq__ return all([self._body.attributes == comparand._body.attributes, *** traceback.print_exception(): Traceback (most recent call last): File "auto_script_config_openstack_for_onap.py", line 537, in configure_all_ONAP if tiny_flavor != None: File "/usr/local/lib/python3.5/dist-packages/openstack/resource.py", line 358, in __eq__ return all([self._body.attributes == comparand._body.attributes, AttributeError: 'NoneType' object has no attribute '_body' For the image creation: ah, OK, indeed, there is an image proxy (even 2: v1, v2), and maybe the compute / image operations are redundant (or maybe not, for convenience) ? and yes, it worked ! There was no need for additional parameters. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender i
[openstack-dev] [sdk] issues with using OpenStack SDK Python client
Hi everybody, As a bit of a novice, I'm trying to use OpenStack SDK 0.13 in an OPNFV/ONAP project (Auto). I'm able to use the compute and network proxies, but have problems with the identity proxy, so I can't create projects and users. With network, I can create a network, a router, router interfaces, but can't add a gateway to a router. Also, deleting a router fails. With compute, I can't create flavors, and not sure if there is a "create_image" method ? Specific issues are listed below with more details. Any pointers (configuration, installation, usage, ...) and URLs to examples and documentation would be welcome. For documentation, I've been looking mostly at: https://docs.openstack.org/openstacksdk/latest/user/proxies/network.html https://docs.openstack.org/openstacksdk/latest/user/proxies/compute.html https://docs.openstack.org/openstacksdk/latest/user/proxies/identity_v3.html Thanks in advance, Gerard For all code, import statement and Connection creation is as follows (constants defined before): import openstack conn = openstack.connect(cloud=OPENSTACK_CLOUD_NAME, region_name=OPENSTACK_REGION_NAME) 1) problem adding a gateway (external network) to a router: not sure how to build a dictionary body (couldn't find examples online) tried this: network_dict_body = {'network_id': public_network.id} and this (from looking at a router printout): network_dict_body = { 'external_fixed_ips': [{'subnet_id' : public_subnet.id}], 'network_id': public_network.id } in both cases, tried this command: conn.network.add_gateway_to_router(onap_router,network_dict_body) getting the error: Exception: add_gateway_to_router() takes 2 positional arguments but 3 were given printing the router gave this: openstack.network.v2.router.Router(distributed=False, tenant_id=03aa47d3bcfd48199e0470b1c86a7f5b, created_at=2018-05-01T01:16:08Z, external_gateway_info=None, status=ACTIVE, availability_zone_hints=[], ha=False, tags=[], description=Router created for ONAP, admin_state_up=True, revision=1, flavor_id=None, id=b923fba5-5027-47b6-b679-29c331ac1aba, updated_at=2018-05-01T01:16:08Z, routes=[], name=onap_router, availability_zones=[]) 2) problem deleting routers: onap_router = conn.network.find_router(ONAP_ROUTER_NAME) conn.network.delete_router(onap_router.id) (same if conn.network.delete_router(onap_router)) getting the error: Exception: 'NoneType' object has no attribute '_body' printing the router that had been created gave this: openstack.network.v2.router.Router(description=Router created for ONAP, status=ACTIVE, routes=[], updated_at=2018-05-01T01:16:11Z, ha=False, id=b923fba5-5027-47b6-b679-29c331ac1aba, external_gateway_info=None, admin_state_up=True, availability_zone_hints=[], tenant_id=03aa47d3bcfd48199e0470b1c86a7f5b, name=onap_router, availability_zones=['nova'], tags=[], revision=3, distributed=False, flavor_id=None, created_at=2018-05-01T01:16:08Z) 3) problem reaching the identity service: (although I can reach compute and network services, and although there are users and projects in the Openstack instance: "admin" and "service" projects, "ceilometer", "nova", etc. (and "admin") users) print("\nList Users:") i=1 for user in conn.identity.users(): print('User',str(i),'\n',user,'\n') i+=1 getting the error: List Users: Exception: NotFoundException: 404 print("\nList Projects:") i=1 for project in conn.identity.projects(): print('Project',str(i),'\n',project,'\n') i+=1 also getting an error, but not the same as users: List Projects: Exception: 'Proxy' object has no attribute 'projects' if trying to create a project: onap_project = conn.identity.find_project(ONAP_TENANT_NAME) if onap_project != None: print('ONAP project/tenant already exists') else: print('Creating ONAP project/tenant...') onap_project = conn.identity.create_project( name = ONAP_TENANT_NAME, description = ONAP_TENANT_DESC, is_enabled = True) getting the error: Exception: 'Proxy' object has no attribute 'find_project' 4) problem creating flavors: tiny_flavor = conn.compute.find_flavor("m1.tiny") if tiny_flavor != None: print('m1.tiny Flavor already exists') else: print('Creating m1.tiny Flavor...') tiny_flavor = conn.compute.create_flavor( name = 'm1.tiny', vcpus = 1, disk = 1, ram = 512, ephemeral = 0, #swap = 0, #rxtx_factor = 1.0, is_public = True) (by the way, maybe swap and rxtx are not supposed to be set ?) getting the error: Exception: 'NoneType' object has no attribute '_body' 5) how to create images ? there is a compute proxy method: find_image() but it looks like there is no create_ima