deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 6/8] CIMI: Added possibility to attach MachineAdmin to Machine
Date Wed, 07 Dec 2011 15:26:50 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 clients/cimi/lib/entities/machine.rb |    9 +++++++--
 clients/cimi/views/machines/new.haml |    8 ++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index 9ef9f3c..d70d0e9 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -20,11 +20,14 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
     @machine_images = CIMI::Model::MachineImageCollection.from_xml(machine_image_xml)
     machine_conf_xml = get_entity_collection('machine_configurations', credentials)
     @machine_configurations = CIMI::Model::MachineConfigurationCollection.from_xml(machine_conf_xml)
+    machine_admins_xml = get_entity_collection('machine_admins', credentials)
+    @machine_admins = CIMI::Model::MachineAdminCollection.from_xml(machine_admins_xml)
     haml :'machines/new'
   end
 
   get '/cimi/machines/:id' do
     machine_xml = get_entity('machines', params[:id], credentials)
+    puts machine_xml
     @machine= CIMI::Model::Machine.from_xml(machine_xml)
     haml :'machines/show'
   end
@@ -84,11 +87,13 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
         xml.name params[:machine][:name]
         xml.description params[:machine][:description]
         xml.MachineTemplate {
-          xml.MachineConfig( :href => params[:machine_configuration] )
-          xml.MachineImage( :href => params[:machine_image] )
+          xml.MachineConfig( :href => params[:machine][:machine_configuration] )
+          xml.MachineImage( :href => params[:machine][:machine_image] )
+          xml.MachineAdmin( :href => params[:machine][:machine_admin] ) unless params[:machine][:machine_admin].empty?
         }
       }
     end.to_xml
+    puts machine_xml
     begin
       result = create_entity('machines', machine_xml, credentials)
       machine = CIMI::Model::MachineCollection.from_xml(result)
diff --git a/clients/cimi/views/machines/new.haml b/clients/cimi/views/machines/new.haml
index 3434142..984ef9b 100644
--- a/clients/cimi/views/machines/new.haml
+++ b/clients/cimi/views/machines/new.haml
@@ -38,6 +38,14 @@
         %select{ :name => 'machine[machine_configuration]' }
           - @machine_configurations.machine_configurations.each do |configuration|
             %option{ :value => configuration.href }=href_to_id(configuration.href)
+    %div.clearfix
+      %label{ :for => 'machine[machine_admin]' }
+        Machine Admin
+      %div.input
+        %select{ :name => 'machine[machine_admin]' }
+          %option{ :value => '', :selected => :selected }
+          - @machine_admins.machine_admins.each do |admin|
+            %option{ :value => admin.href }=href_to_id(admin.href)
     %div.actions
       %input{ :type => :submit, :class => 'btn primary', :value => "Create machine"
}
       %button{ :type => :reset, :class => 'btn' } Reset
-- 
1.7.4.4


Mime
View raw message