Skip to content

AttributeError: 'Server' object has no attribute 'cloud_manager' #159

@helioloureiro

Description

@helioloureiro

Hi,

I've tried to apply what is describe on the project page to have a server up and running.

My Server builder is like this:

class CloudServer:
   [...]
    def buildServerData(self):
        ## check again if it exists from existent servers
        for server in self.manager.get_servers():
            if server.hostname == self.args.hostname:
                doesExist = True
                self.uuid = server.uuid
                break
        
        server_networking = []
        for network_type in NETWORK_TYPES.split(","):
            server_networking.append(
                ServerNetworkInterface(
                    {
                        'type': network_type
                        , 'ip_addresses': [
                            {
                                'family': 'IPv4'
                            }
                        ]
                    }
                )
            )
            
        self.server = Server(
            plan=self.args.plan,
            hostname=self.args.hostname,
            zone=self.args.zone,
            storage_devices=[
                Storage(
                    os=self.args.os, 
                    size=self.args.storage_size,
                    encryption=self.args.storage_encryption
                )
            ],
            login_user=self.login_user,
            metadata=self.args.metadata,
            title=f"{self.args.hostname} created by python",
            networking=server_networking,
            simple_backup=self.args.simple_backup,
            uuid=self.uuid
        )
        try:
            print("server:", self.server)
        except TypeError:
            print("server returned a null string")

and it works to create the server.

    def createServer(self):
        if self.uuid is None:
            self.manager.create_server(self.server)
        else:
            print("Server already created and using uuid:", self.uuid)

but it is crashing during shutdown and destroy. The code is this below:

    def destroyServer(self):
        self.server.stop_and_destroy()
        for disk in self.server.storage_devices:
            disk.destroy()

And I get the following error:

Traceback (most recent call last):
  File "/home/helio/upcloud-testing/python/./server1.py", line 154, in <module>
    server.takeAction()
  File "/home/helio/upcloud-testing/python/./server1.py", line 112, in takeAction
    self.destroyServer()
  File "/home/helio/upcloud-testing/python/./server1.py", line 129, in destroyServer
    self.server.stop_and_destroy()
  File "/home/helio/upcloud-testing/python/venv/lib/python3.12/site-packages/upcloud_api/server.py", line 609, in stop_and_destroy
    self.populate()
  File "/home/helio/upcloud-testing/python/venv/lib/python3.12/site-packages/upcloud_api/server.py", line 174, in populate
    server, IPAddresses, storages = self.cloud_manager.get_server_data(self.uuid)
                                    ^^^^^^^^^^^^^^^^^^
AttributeError: 'Server' object has no attribute 'cloud_manager'

So I'm not sure whether I did something wrong, but it complains about this missing attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions