Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set ServerMetaData #625

Closed
marvincaspar opened this issue Aug 25, 2015 · 2 comments
Closed

Unable to set ServerMetaData #625

marvincaspar opened this issue Aug 25, 2015 · 2 comments

Comments

@marvincaspar
Copy link

I try to add some metadata to a server with the following code:

/** @var \OpenCloud\Compute\Resource\Server $server */
$server = $this->service->server($id);

/** @var \OpenCloud\Compute\Resource\ServerMetadata $metaData */
$metaData = $server->metadata();
$metaData->__set("some_key", "some_value");
$metaData->create();

The create() method in \OpenCloud\Compute\Resource\ServerMetadata calls getMetadataJson(). There the metadata should add to a new object which will be json encoded. But in this method something is wrong. Only the medadata value is stored and not the key-value-pair. In my example the metadata-object looks like: "some_value" => "". This brings up two problems:

  1. You are not able to get the value from a given key
  2. After adding new metadata you get an exception in line 184 Cannnot access empty property.

I think the easiest way is to replace the foreach in line 183 with $object->metadata = $this->keylist();

After this change the metadata are stored correctly.

jamiehannaford pushed a commit that referenced this issue Aug 25, 2015
Fix metadata creation for servers; fixes #625
@jamiehannaford
Copy link
Contributor

@mc388 thanks for reporting this. I've pushed a fix to working. Can you point your Composer dependency to dev-working and let me know if it works for you?

@marvincaspar
Copy link
Author

@jamiehannaford thank you for the very quick fix. I referenced the working branch in my composer file and it works fine. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants