Uploaded image for project: 'Libcloud'
  1. Libcloud
  2. LIBCLOUD-219

Libcloud should not always set up a network id when creating a node

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.11.0
    • Component/s: Compute
    • Labels:
      None

      Description

      I am using libcloud from trunk and here is what I get when I try to create a node:

      Creating node  Bigtop-4-test-13
      Traceback (most recent call last):
        File "/home/bruno/cloudstack.py", line 35, in <module>
          main()                                                                                                                                                   
        File "/home/bruno/cloudstack.py", line 32, in main                                                                                                         
          node = cs.create_node( 'Bigtop-4-test-' + str(num), sizes[image_size], images[image_name])                                                               
        File "/home/bruno/freesoftware/libcloud/libcloud/compute/drivers/cloudstack.py", line 239, in create_node                                                  
          **extra_args                                                                                                                                             
        File "/home/bruno/freesoftware/libcloud/libcloud/common/cloudstack.py", line 122, in _async_request                                                        
          return self.connection._async_request(command, **kwargs)                                                                                                 
        File "/home/bruno/freesoftware/libcloud/libcloud/common/cloudstack.py", line 70, in _async_request                                                         
          context=context)                                                                                                                                         
        File "/home/bruno/freesoftware/libcloud/libcloud/common/base.py", line 690, in async_request                                                               
          response = request(**kwargs)                                                                                                                             
        File "/home/bruno/freesoftware/libcloud/libcloud/common/cloudstack.py", line 96, in _sync_request                                                          
          result = self.request(self.driver.path, params=kwargs)                                                                                                   
        File "/home/bruno/freesoftware/libcloud/libcloud/common/base.py", line 583, in request                                                                     
          connection=self)                                                                                                                                         
        File "/home/bruno/freesoftware/libcloud/libcloud/common/base.py", line 76, in __init__                                                                     
          raise Exception(self.parse_error())                                                                                                                      
      Exception: {'deployvirtualmachineresponse': {'errorcode': 431, 'uuidList': [], 'errortext': "Can't specify network Ids in Basic zone"}}        
      

      But when doing the following modification, I can get it working:

      diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py                                                                 
      index e8a0012..f80ab56 100644                                                                                                                                
      --- a/libcloud/compute/drivers/cloudstack.py                                                                                                                 
      +++ b/libcloud/compute/drivers/cloudstack.py                                                                                                                 
      @@ -222,12 +222,7 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):                                                                          
                   location = self.list_locations()[0]                                                                                                             
                                                                                                                                                                   
               network_id = kwargs.pop('network_id', None)
      -        if network_id is None:
      -            networks = self._sync_request('listNetworks')
      -
      -            if networks:
      -                extra_args['networkids'] = networks['network'][0]['id']
      -        else:
      +        if network_id is not None:
                   extra_args['networkids'] = network_id
       
               result = self._async_request('deployVirtualMachine',
      

      I am not familiar enough with cloudstack to tell when the network_id should or should not be passed.

        Activity

        Hide
        kami Tomaz Muraus added a comment -

        Which version of CloudStack API are you using?

        Show
        kami Tomaz Muraus added a comment - Which version of CloudStack API are you using?
        Hide
        kami Tomaz Muraus added a comment -

        Sorry, didn't mean to resolve it just yet.

        Show
        kami Tomaz Muraus added a comment - Sorry, didn't mean to resolve it just yet.
        Hide
        bmahe Bruno Mahé added a comment -

        CloudStack 3.0.3

        Show
        bmahe Bruno Mahé added a comment - CloudStack 3.0.3
        Hide
        kami Tomaz Muraus added a comment -

        I just checked API docs for the past couple of API versions and yes it seems like network_id argument is optional. I modified the code and now you need to explicitly pass "network_id" argument to the create_node method.

        Show
        kami Tomaz Muraus added a comment - I just checked API docs for the past couple of API versions and yes it seems like network_id argument is optional. I modified the code and now you need to explicitly pass "network_id" argument to the create_node method.

          People

          • Assignee:
            kami Tomaz Muraus
            Reporter:
            bmahe Bruno Mahé
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development