You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/11/16 18:28:00 UTC

CIMI Machine Admin model

Adds the MachineAdmin model and spec.. the CIMI spec MachineAdmin is used when creating a new Machine to define the initial superuser credentials. The spec is doesn't mandate a set of attributes for MachineAdmin but suggests either username/password or key type credentials. Providers are meant to extend the spec using the EntityMetadata to define the type of MachineAdmin attributes they expect. The examples xml and json included here have username/password,

marios

Re: CIMI Machine Admin model

Posted by Tong Li <li...@us.ibm.com>.
In our implementation, we should use metadata to indicate actual
MachineAdmin uses username and password, not certificate.  I believe in the
response to Cloud Entry Point, there should be a section for EntityMetadata
which should have something like this.

      <EntityMetadata xmlns="http://www.dmtf.org/cimi">



      <self>http://example.org/types/machine_admin/machine_admin_01</self>


        <typeURI>http://www.dmtf.org/cimi/MachineAdmin</typeURI>


        <name>Machine Admin #1</name>


        <attribute name="username" namespace="http://example.org/"
      type="string" required="true" />


        <attribute name="password" namespace="http://example.org/"
      type="string" required="true" />


      </EntityMetadata>



That piece of information should be part of the CloudEntryPoint response
(also depends on driver, where EC2, or Mock driver requires different
things), with that, client will know how to deal with MachineAdmin. Also
notice the first child element of EntityMetadata has been changed to <self>
from <uri> in the latest spec, which I think makes the spec worse.
Everybody knows what URI means, element <self> makes very little sense.

Thanks.

Tong Li
Emerging Technologies & Standards
Building 501/B205
litong01@us.ibm.com

marios@redhat.com wrote on 11/16/2011 12:28:00 PM:

> From: marios@redhat.com
> To: deltacloud-dev@incubator.apache.org
> Date: 11/16/2011 02:54 PM
> Subject: CIMI Machine Admin model
>
>
> Adds the MachineAdmin model and spec.. the CIMI spec MachineAdmin is
> used when creating a new Machine to define the initial superuser
> credentials. The spec is doesn't mandate a set of attributes for
> MachineAdmin but suggests either username/password or key type
> credentials. Providers are meant to extend the spec using the
> EntityMetadata to define the type of MachineAdmin attributes they
> expect. The examples xml and json included here have username/password,
>
> marios
>

[PATCH] CIMI MachineAdmin model and spec

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/cimi/model.rb                     |    1 +
 server/lib/cimi/model/machine_admin.rb       |   26 +++++++
 server/spec/cimi/data/machine_admin.json     |   14 ++++
 server/spec/cimi/data/machine_admin.xml      |   10 +++
 server/spec/cimi/model/machine_admin_spec.rb |   99 ++++++++++++++++++++++++++
 5 files changed, 150 insertions(+), 0 deletions(-)
 create mode 100644 server/lib/cimi/model/machine_admin.rb
 create mode 100644 server/spec/cimi/data/machine_admin.json
 create mode 100644 server/spec/cimi/data/machine_admin.xml
 create mode 100644 server/spec/cimi/model/machine_admin_spec.rb

diff --git a/server/lib/cimi/model.rb b/server/lib/cimi/model.rb
index 1e4a34a..cfcff72 100644
--- a/server/lib/cimi/model.rb
+++ b/server/lib/cimi/model.rb
@@ -25,3 +25,4 @@ require 'cimi/model/base'
 require 'cimi/model/machine_template'
 require 'cimi/model/machine_image'
 require 'cimi/model/machine_configuration'
+require 'cimi/model/machine_admin'
diff --git a/server/lib/cimi/model/machine_admin.rb b/server/lib/cimi/model/machine_admin.rb
new file mode 100644
index 0000000..d175bbb
--- /dev/null
+++ b/server/lib/cimi/model/machine_admin.rb
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+class CIMI::Model::MachineAdmin < CIMI::Model::Base
+
+  scalar :username
+  scalar :password
+  text :key
+
+  array :operations do
+    scalar :rel, :href
+  end
+
+end
diff --git a/server/spec/cimi/data/machine_admin.json b/server/spec/cimi/data/machine_admin.json
new file mode 100644
index 0000000..d6d2622
--- /dev/null
+++ b/server/spec/cimi/data/machine_admin.json
@@ -0,0 +1,14 @@
+{
+  "uri": "http://cimi.example.org/machine_admin/1",
+  "name": "credentials1",
+  "description": "Machine Admin One",
+  "created": "2011-11-16",
+  "username": "mockuser",
+  "password": "mockpassword",
+  "operations": [
+  { "rel": "edit",
+    "href": "http://cimi.example.org/machine_admin/1/edit" },
+  { "rel": "delete",
+    "href": "http://cimi.example.org/machine_admin/1/delete" }
+  ]
+}
diff --git a/server/spec/cimi/data/machine_admin.xml b/server/spec/cimi/data/machine_admin.xml
new file mode 100644
index 0000000..a3cfd35
--- /dev/null
+++ b/server/spec/cimi/data/machine_admin.xml
@@ -0,0 +1,10 @@
+<MachineAdmin xmlns="http://www.dmtf.org/cimi">
+  <uri>http://cimi.example.org/machine_admin/1</uri>
+  <name>credentials1</name>
+  <description>Machine Admin One</description>
+  <created>2011-11-16</created>
+  <username>mockuser</username>
+  <password>mockpassword</password>
+  <operation rel="edit" href="http://cimi.example.org/machine_admin/1/edit"/>
+  <operation rel="delete" href="http://cimi.example.org/machine_admin/1/delete"/>
+</MachineAdmin>
diff --git a/server/spec/cimi/model/machine_admin_spec.rb b/server/spec/cimi/model/machine_admin_spec.rb
new file mode 100644
index 0000000..a8763a0
--- /dev/null
+++ b/server/spec/cimi/model/machine_admin_spec.rb
@@ -0,0 +1,99 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+describe "MachineAdmin model" do
+
+  before(:all) do
+    @xml = IO::read(File::join(DATA_DIR, "machine_admin.xml"))
+    @json = IO::read(File::join(DATA_DIR, "machine_admin.json"))
+  end
+
+  describe "XML" do
+    it "can be constructed" do
+      admin = CIMI::Model::MachineAdmin.from_xml(@xml)
+      admin.should_not be_nil
+      admin.should serialize_to @xml, :fmt => :xml
+    end
+
+    it "should have default properties" do
+      admin = CIMI::Model::MachineAdmin.from_xml(@xml)
+      admin.uri.should == "http://cimi.example.org/machine_admin/1"
+      admin.name.should == "credentials1"
+      admin.description.should == "Machine Admin One"
+      admin.created.should == "2011-11-16"
+    end
+
+    it "should have username and password properties" do
+      admin = CIMI::Model::MachineAdmin.from_xml(@xml)
+      admin.username.should_not be_nil
+      admin.username.first["content"].should == "mockuser"
+      admin.password.should_not be_nil
+      admin.password.first["content"].should == "mockpassword"
+    end
+
+    it "should have edit and delete operations" do
+      admin = CIMI::Model::MachineAdmin.from_xml(@xml)
+      admin.operations.any? { |operation| operation.rel == 'edit' }.should be_true
+      admin.operations.any? { |operation| operation.rel == 'delete' }.should be_true
+      admin.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ }
+    end
+
+    it "should convert strings in keys to symbols when contructed from XML" do
+      admin = CIMI::Model::MachineAdmin.from_xml(@xml)
+      admin.should_not be_nil
+      admin.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) }
+    end
+  end
+
+  describe 'JSON' do
+    it "can be constructed" do
+      admin = CIMI::Model::MachineAdmin.from_json(@json)
+      admin.should_not be_nil
+      admin.should serialize_to @json, :fmt => :json
+    end
+
+    it "should have default properties" do
+      admin = CIMI::Model::MachineAdmin.from_json(@json)
+      admin.uri.should == "http://cimi.example.org/machine_admin/1"
+      admin.name.should == "credentials1"
+      admin.description.should == "Machine Admin One"
+      admin.created.should == "2011-11-16"
+    end
+
+    it "should have username and password properties" do
+      admin = CIMI::Model::MachineAdmin.from_json(@json)
+      admin.username.should_not be_nil
+      admin.username.should == "mockuser"
+      admin.password.should_not be_nil
+      admin.password.should == "mockpassword"
+    end
+
+    it "should have edit and delete operations" do
+      admin = CIMI::Model::MachineAdmin.from_json(@json)
+      admin.operations.any? { |operation| operation.rel == 'edit' }.should be_true
+      admin.operations.any? { |operation| operation.rel == 'delete' }.should be_true
+      admin.operations.each { |operation| operation.href.should =~ /^http:\/\/.*\/(#{operation.rel})$/ }
+    end
+
+
+    it "should convert strings in keys to symbols when contructed from JSON" do
+      admin = CIMI::Model::MachineAdmin.from_json(@json)
+      admin.should_not be_nil
+      admin.attribute_values.keys.each { |key| key.should be_a_kind_of(Symbol) }
+    end
+  end
+
+end
-- 
1.7.6.4