On 05/04/2018 01:34 PM, gerard.d...@wipro.com wrote:
Hi everybody,

As a bit of a novice, I'm trying to use OpenStack SDK 0.13 in an OPNFV/ONAP project (Auto).

Yay! Welcome.

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

Yes, that's all good documentation to follow.


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: <class 'TypeError'> add_gateway_to_router() takes 2 positional arguments but 3 were given

The signature for add_gateway_to_router looks like this:

  def add_gateway_to_router(self, router, **body):

the ** indicate that it's looking for the body as keyword arguments. Change your code to:

  conn.network.add_gateway_to_router(onap_router, **network_dict_body)

and it should work.

You could also, should you feel like it, do:

  conn.network.add_gateway_to_router(
      onap_router,
      external_fixed_ips=[{'subnet_id' : public_subnet.id}],
      network_id=public_network.id
  )

which is basically what the ** in **network_dict_body is doing.

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: <class 'AttributeError'> 'NoneType' object has no attribute '_body'

I'm not sure yet what's causing this - it's the same issue you're having below with flavors - I'm looking in to it.

Do you have tracebacks for the exception?

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:

There is an underlying bug/deficiency in the code that's next on my list to fix, but I'm waiting to land a patch to keystoneauth first. For now, add identity_api_version=3 to your openstack.connect line and it should work.

Also - sorry about that - that's a terrible experience and is definitely not the way it should/will work.

(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: <class 'openstack.exceptions.NotFoundException'> 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: <class 'AttributeError'> '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: <class 'AttributeError'> '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: <class 'AttributeError'> 'NoneType' object has no attribute '_body'

Same thing - not sure what's up yet , do you have a traceback?

5) how to create images ?

there is a compute proxy method: find_image()

but it looks like there is no create_image() ?

That is correct. Image methods are all on the image proxy (and we should actually get rid of that compute.find_image() method before we release a 1.0) ... HOWEVER ...

say you wanted to add this image: Ubuntu Server 16.04 LTS (Xenial Xerus)

https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img

I *highly* recommend using the shade layer for image creation, because image creation is exceptionally complicated and all the logic to deal with it is there. We haven't finished combining them, but it'll work for you in its current form.

https://docs.openstack.org/openstacksdk/latest/user/connection.html#openstack.connection.Connection.create_image

You'll need to download the image file locally - as of right now there is not support for directly importing from a url on the glance side. Once you do:

  conn.create_image(
      'Ubuntu Server 16.04 LTS (Xenial Xerus',
      filename='xenial-server-cloudimg-amd64-disk1.img')

should do the trick - although you might have to add a parameter or two.


I'll keep looking in to the other two errors and see what I can find, but hopefully this will help you for now.

how would you do it ?

openstacksdk version 0.13.0 is installed:

$ pip3 list

Package             Version

------------------- ---------

appdirs             1.4.3

certifi             2018.4.16

chardet             3.0.4

command-not-found   0.3

decorator           4.3.0

deprecation         2.0.2

dogpile.cache       0.6.5

idna                2.6

iso8601             0.1.12

jmespath            0.9.3

jsonpatch           1.23

jsonpointer         2.0

keystoneauth1       3.5.0

language-selector   0.1

munch               2.3.1

netifaces           0.10.6

openstacksdk        0.13.0

os-service-types    1.2.0

packaging           17.1

pbr                 4.0.2

pip                 10.0.1

pycurl              7.43.0

pygobject           3.20.0

pyparsing           2.2.0

python-apt          1.1.0b1

python-debian       0.1.27

python-systemd      231

PyYAML              3.12

requests            2.18.4

requestsexceptions  1.4.0

setuptools          20.7.0

six                 1.10.0

ssh-import-id       5.5

stevedore           1.28.0

ufw                 0.35

unattended-upgrades 0.1

urllib3             1.22

wheel               0.29.0

$ pip3 check

No broken requirements found.

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 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

Reply via email to