[Libcloud-list] [PATCH server] CSS tweaks - left navigator and new pool form are affected
by Jeremy Perry
Signed-off-by: Jeremy Perry <jeremy.perry(a)redhat.com>
---
src/public/stylesheets/dcloud.css | 133 ++++++++++++++++++++++---------------
1 files changed, 79 insertions(+), 54 deletions(-)
diff --git a/src/public/stylesheets/dcloud.css b/src/public/stylesheets/dcloud.css
index 58b4ad5..e97e0c5 100644
--- a/src/public/stylesheets/dcloud.css
+++ b/src/public/stylesheets/dcloud.css
@@ -1,3 +1,4 @@
+/* Styles for forms */
form {
border: none;
margin: 0;
@@ -35,60 +36,6 @@ input, select {
font-size: 1.4em;
}
-#side {
- padding: 0;
- width: 229px;
-}
-
-#side a.actionlink {
- text-decoration: underline;
- color: blue;
- line-height: 36px;
- font-size: 14px;
- padding-left: 10px;
-}
-
-
-ul#providers {
- list-style-type: none;
- margin: 0;
- padding: 0;
-}
-
-ul#providers li a {
- display: block;
- line-height: 36px;
- border-bottom: 1px solid #ccc;
- padding-left: 10px;
-}
-
-ul#providers li a:hover {
- background: #e8e8e8;
-}
-
-
-ul#providers li ul {
- list-style-type: none;
- line-height: 36px;
-}
-
-ul#providers li ul li {
- line-height: 36px;
- padding-left: 32px;
- background: url(../images/icon_vmpool.png) no-repeat 2px 50%;
-}
-
-
-.providername {
- font-size: 14px;
-}
-
-
-.providername a:active {
- text-decoration: underline;
- color: red;
-}
-
.fieldWithErrors {
display:inline-block;
padding: 3px;
@@ -176,4 +123,82 @@ ul#providers li ul li {
margin-top: 18px;
display: inline;
clear:both;
+}
+
+/* Styles for the left navigator */
+
+#side {
+ padding: 0;
+ width: 229px;
+}
+
+#side a.actionlink {
+ text-decoration: underline;
+ color: blue;
+ line-height: 36px;
+ font-size: 14px;
+ padding-left: 10px;
+}
+
+ul#providers {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+
+ul#providers li {
+ border-bottom: 1px solid #ccc;
+}
+
+ul#providers li a {
+ display: block;
+ line-height: 36px;
+ padding-left: 10px;
+}
+
+ul#providers li a:hover {
+ color: #333;
+ background: #efefef;
+}
+
+
+ul#providers li ul {
+ list-style-type: none;
+ line-height: 36px;
+ margin: 0;
+ padding: 0 0 0 10px;
+
+}
+
+ul#providers li ul li {
+ border-bottom: none;
+}
+
+ul#providers li ul li a {
+ line-height: 36px;
+ padding-left: 32px;
+ border-bottom: none;
+}
+
+ul#providers li ul li a:hover {
+ background: #efefef url(../images/icon_vmpool.png) no-repeat 2px 50%;
+}
+
+
+.providername, .poolname {
+ font-size: 14px;
+}
+
+.poolname {
+ background: url(../images/icon_vmpool.png) no-repeat 2px 50%;
+}
+
+.selected {
+ background: #f2a922;
+ color: #FFF;
+}
+
+.poolname.selected {
+ background: #f2a922 url(../images/icon_vmpool.png) no-repeat 2px 50%;
+ color: #FFF;
}
\ No newline at end of file
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] CSS tweaks - left navigator and new pool form are affected
by Jeremy Perry
Signed-off-by: Jeremy Perry <jeremy.perry(a)redhat.com>
---
src/public/stylesheets/dcloud.css | 136 ++++++++++++++++++++++---------------
1 files changed, 82 insertions(+), 54 deletions(-)
diff --git a/src/public/stylesheets/dcloud.css b/src/public/stylesheets/dcloud.css
index 58b4ad5..fc29c35 100644
--- a/src/public/stylesheets/dcloud.css
+++ b/src/public/stylesheets/dcloud.css
@@ -1,3 +1,4 @@
+/* Styles for forms */
form {
border: none;
margin: 0;
@@ -35,60 +36,6 @@ input, select {
font-size: 1.4em;
}
-#side {
- padding: 0;
- width: 229px;
-}
-
-#side a.actionlink {
- text-decoration: underline;
- color: blue;
- line-height: 36px;
- font-size: 14px;
- padding-left: 10px;
-}
-
-
-ul#providers {
- list-style-type: none;
- margin: 0;
- padding: 0;
-}
-
-ul#providers li a {
- display: block;
- line-height: 36px;
- border-bottom: 1px solid #ccc;
- padding-left: 10px;
-}
-
-ul#providers li a:hover {
- background: #e8e8e8;
-}
-
-
-ul#providers li ul {
- list-style-type: none;
- line-height: 36px;
-}
-
-ul#providers li ul li {
- line-height: 36px;
- padding-left: 32px;
- background: url(../images/icon_vmpool.png) no-repeat 2px 50%;
-}
-
-
-.providername {
- font-size: 14px;
-}
-
-
-.providername a:active {
- text-decoration: underline;
- color: red;
-}
-
.fieldWithErrors {
display:inline-block;
padding: 3px;
@@ -176,4 +123,85 @@ ul#providers li ul li {
margin-top: 18px;
display: inline;
clear:both;
+}
+
+
+
+/* Styles for the left navigator */
+
+#side {
+ padding: 0;
+ width: 229px;
+}
+
+#side a.actionlink {
+ text-decoration: underline;
+ color: blue;
+ line-height: 36px;
+ font-size: 14px;
+ padding-left: 10px;
+}
+
+ul#providers {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+
+ul#providers li {
+ border-bottom: 1px solid #ccc;
+}
+
+ul#providers li a {
+ display: block;
+ line-height: 36px;
+ padding-left: 10px;
+}
+
+ul#providers li a:hover {
+ color: #333;
+ background: #efefef;
+}
+
+
+ul#providers li ul {
+ list-style-type: none;
+ line-height: 36px;
+ margin: 0;
+ padding: 0 0 0 10px;
+
+}
+
+ul#providers li ul li {
+ border-bottom: none;
+}
+
+ul#providers li ul li a {
+ line-height: 36px;
+ padding-left: 32px;
+/* background: url(../images/icon_vmpool.png) no-repeat 2px 50%; */
+ border-bottom: none;
+}
+
+ul#providers li ul li a:hover {
+ background: #efefef url(../images/icon_vmpool.png) no-repeat 2px 50%;
+}
+
+
+.providername, .poolname {
+ font-size: 14px;
+}
+
+.poolname {
+ background: url(../images/icon_vmpool.png) no-repeat 2px 50%;
+}
+
+.selected {
+ background: #f2a922;
+ color: #FFF;
+}
+
+.poolname.selected {
+ background: #f2a922 url(../images/icon_vmpool.png) no-repeat 2px 50%;
+ color: #FFF;
}
\ No newline at end of file
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] Improve nav around the app a bit.
by jason.guiditta
Left links were not right, easier to find stuff now.
Signed-off-by: Jason Guiditta <jason.guiditta(a)gmail.com>
---
src/app/controllers/portal_pool_controller.rb | 6 ++++--
src/app/controllers/provider_controller.rb | 3 ++-
src/app/views/layouts/dcloud.rhtml | 7 ++++++-
src/app/views/portal_pool/show.html.erb | 10 ++++++++--
src/app/views/provider/_form.html.erb | 13 +++++++++++++
src/app/views/provider/index.html.erb | 2 +-
src/app/views/provider/new.html.erb | 14 +-------------
src/app/views/provider/show.html.erb | 10 ++++++++--
8 files changed, 43 insertions(+), 22 deletions(-)
create mode 100644 src/app/views/provider/_form.html.erb
diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb
index 506885b..7c8d587 100644
--- a/src/app/controllers/portal_pool_controller.rb
+++ b/src/app/controllers/portal_pool_controller.rb
@@ -1,9 +1,11 @@
class PortalPoolController < ApplicationController
def index
- @pools = Provider.find(params[:id]).portal_pools
+ render :action => 'new'
end
def show
+ @instances = Instance.find(:all, :conditions => {:portal_pool_id => params[:id]})
+ @pool = params[:id]
end
def new
@@ -19,7 +21,7 @@ class PortalPoolController < ApplicationController
@portal_pool = @account.portal_pools.build(params[:portal_pool])
if @portal_pool.save
flash[:notice] = "Pool added."
- redirect_to :action => 'index', :id => @account.provider_id
+ redirect_to :action => 'show', :id => @portal_pool.id
else
render :action => 'new'
end
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
index 31e6c2b..90d5a2d 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -1,9 +1,10 @@
class ProviderController < ApplicationController
def index
- @provider = Provider.find(params[:id])
+ render :action => 'new'
end
def show
+ @provider = Provider.find(:first, :conditions => {:id => params[:id]})
end
def new
diff --git a/src/app/views/layouts/dcloud.rhtml b/src/app/views/layouts/dcloud.rhtml
index 57cff85..4c2f103 100644
--- a/src/app/views/layouts/dcloud.rhtml
+++ b/src/app/views/layouts/dcloud.rhtml
@@ -71,7 +71,12 @@
<%#= render :partial => '/layouts/tree' %>
<ul id="providers">
<% @providers.each { |provider| %>
- <li><%= link_to provider.name, {:controller => "provider", :action => "index"}, :id => provider, :class => "providername"%>
+ <li><%= link_to provider.name, {:controller => "provider", :action => "show", :id => provider}, :class => "providername"%>
+ <% provider.portal_pools.each { |pool| %>
+ <ul id="portal_pool-<%=provider.id%>">
+ <li><%= link_to pool.name, {:controller => "portal_pool", :action => "show", :id => pool}, :class => "poolname" %></li>
+ </ul>
+ <% } %>
</li>
<% } %>
</ul>
diff --git a/src/app/views/portal_pool/show.html.erb b/src/app/views/portal_pool/show.html.erb
index f1c634a..cd19999 100644
--- a/src/app/views/portal_pool/show.html.erb
+++ b/src/app/views/portal_pool/show.html.erb
@@ -1,2 +1,8 @@
-<h1>ProviderController#show</h1>
-<p>Find me in app/views/provider_controller/show.html.erb</p>
+<% if @instances.size == 0 %>
+<h1>There are no pools to display</h1>
+<% else %>
+ <%(a)instances.each {|instance| %>
+ <%= instance.name %><br/>
+ <% } %>
+<% end %>
+<%= link_to "Add a pool", :controller => "instance", :action => "new", :pool => @pool%>
diff --git a/src/app/views/provider/_form.html.erb b/src/app/views/provider/_form.html.erb
new file mode 100644
index 0000000..7c00a4c
--- /dev/null
+++ b/src/app/views/provider/_form.html.erb
@@ -0,0 +1,13 @@
+<div class="dcloud_form">
+ <%= error_messages_for 'provider' %>
+
+ <h2>Add a cloud provider</h2><br />
+ <% form_for :provider do |f| %>
+ <ul>
+ <li><label>Name<span>Provide a descriptive name for this provider connection.</span></label><%= f.text_field :name, :class => "txtfield" %></li>
+ <li><label>Type<span>Choose the type of provider connection.</span></label><%= select :provider, :cloud_type, [["Mock","Mock"],["EC2", "EC2"],["RHEV-M", "RHEV-M"]], :class => "txtfield" %></li>
+ <li><label>URL<span>Enter the URL of the cloud provider.</span></label><%= f.text_field :url, :class => "txtfield" %></li>
+ </ul>
+ <%= submit_tag "Save", :class => "submit" %>
+ <% end %>
+</div>
\ No newline at end of file
diff --git a/src/app/views/provider/index.html.erb b/src/app/views/provider/index.html.erb
index ed4ddfc..786950e 100644
--- a/src/app/views/provider/index.html.erb
+++ b/src/app/views/provider/index.html.erb
@@ -1 +1 @@
-This will likely just have the 'New Provider' form for now.
+<%= render :partial => 'form' %>
diff --git a/src/app/views/provider/new.html.erb b/src/app/views/provider/new.html.erb
index 7c00a4c..8353b17 100644
--- a/src/app/views/provider/new.html.erb
+++ b/src/app/views/provider/new.html.erb
@@ -1,13 +1 @@
-<div class="dcloud_form">
- <%= error_messages_for 'provider' %>
-
- <h2>Add a cloud provider</h2><br />
- <% form_for :provider do |f| %>
- <ul>
- <li><label>Name<span>Provide a descriptive name for this provider connection.</span></label><%= f.text_field :name, :class => "txtfield" %></li>
- <li><label>Type<span>Choose the type of provider connection.</span></label><%= select :provider, :cloud_type, [["Mock","Mock"],["EC2", "EC2"],["RHEV-M", "RHEV-M"]], :class => "txtfield" %></li>
- <li><label>URL<span>Enter the URL of the cloud provider.</span></label><%= f.text_field :url, :class => "txtfield" %></li>
- </ul>
- <%= submit_tag "Save", :class => "submit" %>
- <% end %>
-</div>
\ No newline at end of file
+<%= render :partial => 'form' %>
\ No newline at end of file
diff --git a/src/app/views/provider/show.html.erb b/src/app/views/provider/show.html.erb
index f1c634a..8bc0334 100644
--- a/src/app/views/provider/show.html.erb
+++ b/src/app/views/provider/show.html.erb
@@ -1,2 +1,8 @@
-<h1>ProviderController#show</h1>
-<p>Find me in app/views/provider_controller/show.html.erb</p>
+<% if @provider.portal_pools.size == 0 %>
+<h1>There are no pools to display</h1>
+<% else %>
+ <%(a)provider.portal_pools.each {|pool| %>
+ <%= pool.name %><br/>
+ <% } %>
+<% end %>
+<%= link_to "Add a pool", :controller => "portal_pool", :action => "new", :provider => @provider%>
\ No newline at end of file
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] Left navigator styling
by Jeremy Perry
Signed-off-by: Jeremy Perry <jeremy.perry(a)redhat.com>
---
src/app/views/layouts/dcloud.rhtml | 9 +++---
src/public/stylesheets/dcloud.css | 49 ++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/src/app/views/layouts/dcloud.rhtml b/src/app/views/layouts/dcloud.rhtml
index c724950..57cff85 100644
--- a/src/app/views/layouts/dcloud.rhtml
+++ b/src/app/views/layouts/dcloud.rhtml
@@ -69,12 +69,13 @@
<div id="side">
<%#= render :partial => '/layouts/tree' %>
- <%=link_to "Add a provider", :controller => "provider", :action => "new" %>
- <ul id="providers">
+ <ul id="providers">
<% @providers.each { |provider| %>
- <li><%= provider.name %></li>
+ <li><%= link_to provider.name, {:controller => "provider", :action => "index"}, :id => provider, :class => "providername"%>
+ </li>
<% } %>
- </ul>
+ </ul>
+ <%=link_to "Add a provider", {:controller => "provider", :action => "new"}, :class => "actionlink" %>
</div>
<div id="tabs-and-content-container">
diff --git a/src/public/stylesheets/dcloud.css b/src/public/stylesheets/dcloud.css
index b7c06cd..8488cb6 100644
--- a/src/public/stylesheets/dcloud.css
+++ b/src/public/stylesheets/dcloud.css
@@ -10,6 +10,55 @@ input, select {
font-size: 1.4em;
}
+a.actionlink {
+ text-decoration: underline;
+ color: blue;
+ line-height: 36px;
+ font-size: 14px;
+}
+
+
+ul#providers {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+/* border-bottom: 1px solid #ccc; */
+}
+
+ul#providers li a {
+ display: block;
+ line-height: 36px;
+ border-bottom: 1px solid #ccc;
+ padding-left: 10px;
+}
+
+ul#providers li a:hover {
+ background: #e8e8e8;
+}
+
+
+ul#providers li ul {
+ list-style-type: none;
+ line-height: 36px;
+}
+
+ul#providers li ul li {
+ line-height: 36px;
+ padding-left: 32px;
+ background: url(../images/icon_vmpool.png) no-repeat 2px 50%;
+}
+
+
+.providername {
+ font-size: 14px;
+}
+
+
+.providername a:active {
+ text-decoration: underline;
+ color: red;
+}
+
.fieldWithErrors {
display:inline-block;
padding: 3px;
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] Style updates for form validation
by Jeremy Perry
Signed-off-by: Jeremy Perry <jeremy.perry(a)redhat.com>
---
src/app/views/provider/new.html.erb | 4 +--
src/public/stylesheets/dcloud.css | 46 ++++++++++++++++++++++++----------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/src/app/views/provider/new.html.erb b/src/app/views/provider/new.html.erb
index f73c15c..ba60da8 100644
--- a/src/app/views/provider/new.html.erb
+++ b/src/app/views/provider/new.html.erb
@@ -1,8 +1,7 @@
-<div id="provider_form">
+<div class="dcloud_form">
<%= error_messages_for 'provider' %>
<h2>Add a cloud provider</h2><br />
- <fieldset>
<% form_for :provider do |f| %>
<ul>
<li><label>Name<span>Provide a descriptive name for this provider connection.</span></label><%= f.text_field :name, :class => "txtfield" %></li>
@@ -11,5 +10,4 @@
</ul>
<%= submit_tag "Save", :class => "submit" %>
<% end %>
- </fieldset>
</div>
\ No newline at end of file
diff --git a/src/public/stylesheets/dcloud.css b/src/public/stylesheets/dcloud.css
index 8ccf511..b7c06cd 100644
--- a/src/public/stylesheets/dcloud.css
+++ b/src/public/stylesheets/dcloud.css
@@ -1,7 +1,8 @@
-fieldset {
+form {
border: none;
margin: 0;
padding: 0;
+ display: inline-block;
}
input, select {
@@ -9,7 +10,28 @@ input, select {
font-size: 1.4em;
}
-#provider_form {
+.fieldWithErrors {
+ display:inline-block;
+ padding: 3px;
+ background: #fff7b2;
+ border: 3px solid #fff7b2;
+}
+
+.errorExplanation {
+ margin: 0 0 24px 0;
+ padding: 9px;
+ background: #fff7b2;
+ color: #867a5e;
+ -moz-border-radius: 3px;
+}
+
+#errorExplanation h2 {
+ font-size: 14px;
+ font-weight: bold;
+ color: #867a5e;
+}
+
+.dcloud_form {
background: #e8e8e8;
border: solid 8px #f5f5f5;
-moz-border-radius: 10px;
@@ -21,7 +43,7 @@ input, select {
padding: 36px;
}
-#provider_form h2{
+.dcloud_form h2 {
font-size: 1.9em;
font-weight: normal;
color: #43728e;
@@ -29,7 +51,7 @@ input, select {
padding: 0;
}
-#provider_form ul {
+.dcloud_form ul {
list-style-image: none;
list-style-position: outside;
list-style-type: none;
@@ -37,7 +59,7 @@ input, select {
padding: 0;
}
-#provider_form ul label {
+.dcloud_form ul label {
display: block;
float: left;
padding: 3px 0 24px 0;
@@ -46,7 +68,7 @@ input, select {
color: #616161;
}
-#provider_form ul label span {
+.dcloud_form ul label span {
display: block;
float: left;
width: 160px;
@@ -54,27 +76,23 @@ input, select {
color: #9a9a9a;
}
-
-#provider_form ul li {
+.dcloud_form ul li {
clear:both;
-/* margin-bottom: 18px; */
}
-#provider_form .txtfield {
+.dcloud_form .txtfield {
border:2px solid #becfe4;
color:#333;
display:block;
float:left;
-/* margin:5px 0 7px; */
outline-color:-moz-use-text-color;
outline-style:none;
outline-width:medium;
padding:3px;
- width:330px;
+ width:318px;
}
-
-#provider_form .submit {
+.dcloud_form .submit {
float: right;
margin-top: 18px;
display: inline;
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] Create New Pool.
by jason.guiditta
This is a combination form that creates a pool for a given
Provider as well as either mapping an existing cloud_account
to this pool, or creating a new one based on the credentials
provided in form.
On completion, user is brought to the list page for the pools
for this portal (just just the names, not formatted). This
will also show # instances in an upcoming patch.
Signed-off-by: Jason Guiditta <jason.guiditta(a)gmail.com>
---
src/app/controllers/portal_pool_controller.rb | 33 +++++++++++++++++++++++++
src/app/controllers/provider_controller.rb | 4 +-
src/app/helpers/portal_pool_helper.rb | 2 +
src/app/models/cloud_account.rb | 12 ++++++++-
src/app/models/provider.rb | 7 +++++
src/app/views/portal_pool/delete.html.erb | 2 +
src/app/views/portal_pool/index.html.erb | 8 ++++++
src/app/views/portal_pool/new.html.erb | 24 ++++++++++++++++++
src/app/views/portal_pool/show.html.erb | 2 +
src/app/views/provider/index.html.erb | 3 +-
src/app/views/provider/new.html.erb | 2 +-
11 files changed, 93 insertions(+), 6 deletions(-)
create mode 100644 src/app/controllers/portal_pool_controller.rb
create mode 100644 src/app/helpers/portal_pool_helper.rb
create mode 100644 src/app/views/portal_pool/delete.html.erb
create mode 100644 src/app/views/portal_pool/index.html.erb
create mode 100644 src/app/views/portal_pool/new.html.erb
create mode 100644 src/app/views/portal_pool/show.html.erb
diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb
new file mode 100644
index 0000000..506885b
--- /dev/null
+++ b/src/app/controllers/portal_pool_controller.rb
@@ -0,0 +1,33 @@
+class PortalPoolController < ApplicationController
+ def index
+ @pools = Provider.find(params[:id]).portal_pools
+ end
+
+ def show
+ end
+
+ def new
+ @portal_pool = PortalPool.new
+ @account = CloudAccount.new
+ @account.provider_id = params[:provider]
+ end
+
+ def create
+ @account = CloudAccount.find_or_create(params[:account])
+ #FIXME: This should probably be in a transaction
+ if @account.save
+ @portal_pool = @account.portal_pools.build(params[:portal_pool])
+ if @portal_pool.save
+ flash[:notice] = "Pool added."
+ redirect_to :action => 'index', :id => @account.provider_id
+ else
+ render :action => 'new'
+ end
+ else
+ render :action => 'new'
+ end
+ end
+
+ def delete
+ end
+end
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
index 3469ac6..b3088f8 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -1,6 +1,6 @@
class ProviderController < ApplicationController
def index
- @providers = Provider.find(:all)
+ @provider = Provider.find(params[:id])
end
def show
@@ -10,7 +10,7 @@ class ProviderController < ApplicationController
@provider = Provider.new(params[:provider])
if request.post? && @provider.save @provider.populate_flavors
flash[:notice] = "Provider added."
- redirect_to :action => "index"
+ redirect_to :action => "index", :id => @provider
end
end
diff --git a/src/app/helpers/portal_pool_helper.rb b/src/app/helpers/portal_pool_helper.rb
new file mode 100644
index 0000000..5572ff3
--- /dev/null
+++ b/src/app/helpers/portal_pool_helper.rb
@@ -0,0 +1,2 @@
+module PortalPoolHelper
+end
diff --git a/src/app/models/cloud_account.rb b/src/app/models/cloud_account.rb
index c99b506..dd84726 100644
--- a/src/app/models/cloud_account.rb
+++ b/src/app/models/cloud_account.rb
@@ -15,6 +15,16 @@ class CloudAccount < ActiveRecord::Base
validates_presence_of :password
def connect
- DeltaCloud.new(username, password, provider.url)
+ begin
+ return DeltaCloud.new(username, password, provider.url)
+ rescue Exception => e
+ #TODO: log or return an exception
+ return nil
+ end
+ end
+
+ def self.find_or_create(account)
+ a = CloudAccount.find_by_username_and_provider_id(account["username"], account["provider_id"])
+ return a.nil? ? CloudAccount.new(account) : a
end
end
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index e4c6890..3ef1d89 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -3,6 +3,7 @@ class Provider < ActiveRecord::Base
has_many :flavors
has_many :images
has_many :realms
+ has_many :portal_pools, :through=>:cloud_accounts
validates_presence_of :name
validates_uniqueness_of :name
@@ -35,6 +36,12 @@ class Provider < ActiveRecord::Base
end
end
+ # TODO: implement or remove - this is meant to contain a hash of
+ # supported cloud_types to use in populating form, though if we
+ # infer that field, we don't need this.
+ def supported_types
+ end
+
protected
def validate
if !nil_or_empty(url)
diff --git a/src/app/views/portal_pool/delete.html.erb b/src/app/views/portal_pool/delete.html.erb
new file mode 100644
index 0000000..b21ec14
--- /dev/null
+++ b/src/app/views/portal_pool/delete.html.erb
@@ -0,0 +1,2 @@
+<h1>ProviderController#delete</h1>
+<p>Find me in app/views/provider_controller/delete.html.erb</p>
diff --git a/src/app/views/portal_pool/index.html.erb b/src/app/views/portal_pool/index.html.erb
new file mode 100644
index 0000000..efb47e8
--- /dev/null
+++ b/src/app/views/portal_pool/index.html.erb
@@ -0,0 +1,8 @@
+<% if @pools.size == 0 %>
+<h1>There are no pools to display</h1>
+<% else %>
+ <%(a)pools.each {|pool| %>
+ <%= pool.name %><br/>
+ <% } %>
+<% end %>
+<%= link_to "Add a pool", :controller => "portal_pool", :action => "new", :provider => @provider%>
diff --git a/src/app/views/portal_pool/new.html.erb b/src/app/views/portal_pool/new.html.erb
new file mode 100644
index 0000000..adba03c
--- /dev/null
+++ b/src/app/views/portal_pool/new.html.erb
@@ -0,0 +1,24 @@
+<div class="dcloud_form">
+ <%= error_messages_for 'portal_pool' %>
+ <%= error_messages_for 'account' %>
+
+ <h2>Add a Pool and Account for this Provider</h2><br />
+
+ <% form_tag :action => 'create' do -%>
+ <fieldset>
+ <legend>Account</legend>
+ <ul>
+ <li><label>UserName<span>UserName for the account you wish to connect to this pool.</span></label><%= text_field :account, :username %></li>
+ <li><label>Password<span>Password for the account you wish to connect to this pool.</span></label><%=password_field :account, :password %></li>
+ </ul>
+ <%=hidden_field :account, :provider_id %>
+ </fieldset>
+ <fieldset>
+ <legend>Pool</legend>
+ <ul>
+ <li><label>Name<span>Provide a descriptive name for this pool.</span></label><%= text_field :portal_pool, :name %></li>
+ </ul>
+ </fieldset>
+ <%= submit_tag "Save", :class => "submit" %>
+ <% end %>
+</div>
\ No newline at end of file
diff --git a/src/app/views/portal_pool/show.html.erb b/src/app/views/portal_pool/show.html.erb
new file mode 100644
index 0000000..f1c634a
--- /dev/null
+++ b/src/app/views/portal_pool/show.html.erb
@@ -0,0 +1,2 @@
+<h1>ProviderController#show</h1>
+<p>Find me in app/views/provider_controller/show.html.erb</p>
diff --git a/src/app/views/provider/index.html.erb b/src/app/views/provider/index.html.erb
index acd2676..ed4ddfc 100644
--- a/src/app/views/provider/index.html.erb
+++ b/src/app/views/provider/index.html.erb
@@ -1,2 +1 @@
-<h1>ProviderController#index</h1>
-<p>Find me in app/views/provider_controller/index.html.erb</p>
+This will likely just have the 'New Provider' form for now.
diff --git a/src/app/views/provider/new.html.erb b/src/app/views/provider/new.html.erb
index f73c15c..edde8f2 100644
--- a/src/app/views/provider/new.html.erb
+++ b/src/app/views/provider/new.html.erb
@@ -6,7 +6,7 @@
<% form_for :provider do |f| %>
<ul>
<li><label>Name<span>Provide a descriptive name for this provider connection.</span></label><%= f.text_field :name, :class => "txtfield" %></li>
- <li><label>Type<span>Choose the type of provider connection.</span></label><%= select :provider, :cloud_type, [["EC2", "EC2"],["RHEV-M", "RHEV-M"]], :class => "txtfield" %></li>
+ <li><label>Type<span>Choose the type of provider connection.</span></label><%= select :provider, :cloud_type, [["Mock","Mock"],["EC2", "EC2"],["RHEV-M", "RHEV-M"]], :class => "txtfield" %></li>
<li><label>URL<span>Enter the URL of the cloud provider.</span></label><%= f.text_field :url, :class => "txtfield" %></li>
</ul>
<%= submit_tag "Save", :class => "submit" %>
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server 2/2] populate flavors when creating provider. Images and Realms will have to be handled when creating the Pool.
by Scott Seago
Signed-off-by: Scott Seago <sseago(a)redhat.com>
---
src/app/controllers/provider_controller.rb | 2 +-
src/app/models/provider.rb | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
index 09ed19f..3469ac6 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -8,7 +8,7 @@ class ProviderController < ApplicationController
def new
@provider = Provider.new(params[:provider])
- if request.post? && @provider.save
+ if request.post? && @provider.save @provider.populate_flavors
flash[:notice] = "Provider added."
redirect_to :action => "index"
end
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index f8d6f09..e4c6890 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -19,6 +19,22 @@ class Provider < ActiveRecord::Base
end
end
+ def populate_flavors
+ flavors = connect.flavors
+ # FIXME: this should probably be in the same transaction as provider.save
+ self.transaction do
+ flavors.each do |flavor|
+ ar_flavor = Flavor.new(:external_key => flavor.id,
+ :name => flavor.name ? flavor.name : flavor.id,
+ :memory => flavor.memory,
+ :storage => flavor.stprage,
+ :architecture => flavor.architecture,
+ :provider_id => id)
+ ar_flavor.save!
+ end
+ end
+ end
+
protected
def validate
if !nil_or_empty(url)
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server 1/2] fixed state issues in Instance and Task model. In particular, don't maintain the task state transitions locally -- we get it from the driver.
by Scott Seago
Signed-off-by: Scott Seago <sseago(a)redhat.com>
---
src/app/models/instance.rb | 5 +++--
src/app/models/instance_task.rb | 34 ++++++++++++++++++----------------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
index bc2acb7..cd1dd1c 100644
--- a/src/app/models/instance.rb
+++ b/src/app/models/instance.rb
@@ -19,9 +19,10 @@ class Instance < ActiveRecord::Base
validates_presence_of :flavor_id
validates_presence_of :image_id
+ STATE_NEW = "new"
STATE_PENDING = "pending"
STATE_RUNNING = "running"
- STATE_TERMINATED = "terminated"
- STATE_FIXME = "tbd"
+ STATE_SHUTTING_DOWN = "shutting_down"
+ STATE_STOPPED = "stopped"
# what about newly created instances?
end
diff --git a/src/app/models/instance_task.rb b/src/app/models/instance_task.rb
index 99b164b..d13c902 100644
--- a/src/app/models/instance_task.rb
+++ b/src/app/models/instance_task.rb
@@ -78,27 +78,28 @@ class InstanceTask < Task
end
end
- def self.valid_actions_for_instance_state(state, instance=nil, user=nil)
+ # FIXME: sort out pending_state issue w/ instance here including
+ # automatic transitions from transient states.
+ def self.valid_actions_for_instance_state(state, instance, user=nil)
actions = []
- ACTIONS.each do |action, hash|
- if hash[:start] == state
+ transitions = c.instance_state(state).transitions
+ transitions.
+ tra
+ transitions.each do |transition|
+ # FIXME if we allow actions based on the expected state after
+ # automatic transitions, we need to call this method again with
+ # the state from transition.to passed in.
+ unless transition.action.nil?
add_action = true
if (instance and user)
- # FIXME: check permissions here
+ # FIXME: check permissions here if we filter actions by permission
end
- actions << action if add_action
+ actions << transition.action if add_action
end
end
actions
end
- def self.action_privilege(action)
- return ACTIONS[action].nil? ? nil : ACTIONS[action][:privilege][0]
- end
- # FIXME: this may not be needed if all action privileges are based on the pool
- def self.action_privilege_object(action, obj)
- return ACTIONS[action].nil? ? nil : obj.portal_pool
- end
def self.action_label(action)
return ACTIONS[action][:label]
end
@@ -109,11 +110,12 @@ class InstanceTask < Task
return [action_label(action), action, action_icon(action)]
end
+ # FIXME: need to pass in provider to filter start and destroy out for ec2
def self.get_instance_actions
- return [label_and_action(InstanceTask::ACTION_START),
- label_and_action(InstanceTask::ACTION_STOP),
- label_and_action(InstanceTask::ACTION_REBOOT_VM),
- label_and_action(InstanceTask::ACTION_DESTROY)]
+ return [["Start", InstanceTask::ACTION_START],
+ ["Stop", InstanceTask::ACTION_STOP],
+ ["Reboot", InstanceTask::ACTION_REBOOT_VM],
+ ["Destroy", InstanceTask::ACTION_DESTROY]]
end
# FIXME: most of these go away when ovirt model leaves
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] Bug fix and minor refactor.
by jason.guiditta
fixed connect method, add exception catching
Signed-off-by: Jason Guiditta <jason.guiditta(a)gmail.com>
---
src/app/models/provider.rb | 14 +++++++-------
src/test/unit/provider_test.rb | 9 +++++++++
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb
index 1832c54..f8d6f09 100644
--- a/src/app/models/provider.rb
+++ b/src/app/models/provider.rb
@@ -11,7 +11,12 @@ class Provider < ActiveRecord::Base
validates_presence_of :url
def connect
- DeltaCloud.new(nil, nil, provider.url)
+ begin
+ return DeltaCloud.new(nil, nil, url)
+ rescue Exception => e
+ #TODO: log or return an exception
+ return nil
+ end
end
protected
@@ -25,11 +30,6 @@ class Provider < ActiveRecord::Base
private
def valid_framework?
- begin
- DeltaCloud.new(nil, nil, url)
- return true
- rescue Exception => e
- return false
- end
+ connect.nil? ? false : true
end
end
diff --git a/src/test/unit/provider_test.rb b/src/test/unit/provider_test.rb
index d9af732..877fd9c 100644
--- a/src/test/unit/provider_test.rb
+++ b/src/test/unit/provider_test.rb
@@ -23,4 +23,13 @@ class ProviderTest < ActiveSupport::TestCase
@provider.url = "http://dcloud.awesome/api"
flunk "Invalid url passed validation" unless @provider.invalid?
end
+
+ test "should return nil if no connection" do
+ assert_equal(nil, @provider.connect)
+ end
+
+ test "should return DeltaCloud if successful connection" do
+ @provider.url = "http://localhost:3000/api"
+ assert_instance_of(DeltaCloud, @provider.connect)
+ end
end
--
1.6.2.5
14 years, 10 months
[Libcloud-list] [PATCH server] UI patch for Add Provider form
by Jeremy Perry
Signed-off-by: Jeremy Perry <jeremy.perry(a)redhat.com>
---
src/app/views/provider/new.html.erb | 14 ++++--
src/public/favicon.ico | Bin 1342 -> 1115 bytes
src/public/stylesheets/dcloud.css | 79 ++++++++++++++++++++++++++++++++++-
src/public/stylesheets/layout.css | 4 --
4 files changed, 86 insertions(+), 11 deletions(-)
diff --git a/src/app/views/provider/new.html.erb b/src/app/views/provider/new.html.erb
index 48c93fd..f73c15c 100644
--- a/src/app/views/provider/new.html.erb
+++ b/src/app/views/provider/new.html.erb
@@ -1,11 +1,15 @@
<div id="provider_form">
<%= error_messages_for 'provider' %>
- Add a provider:<br/>
+ <h2>Add a cloud provider</h2><br />
+ <fieldset>
<% form_for :provider do |f| %>
- Name: <%= f.text_field :name %><br/>
- Type: <%= select_tag :cloud_type, "<option>EC2</option><option>RHEV-M</option>" %><br/>
- URL: <%= f.text_field :url %><br/>
+ <ul>
+ <li><label>Name<span>Provide a descriptive name for this provider connection.</span></label><%= f.text_field :name, :class => "txtfield" %></li>
+ <li><label>Type<span>Choose the type of provider connection.</span></label><%= select :provider, :cloud_type, [["EC2", "EC2"],["RHEV-M", "RHEV-M"]], :class => "txtfield" %></li>
+ <li><label>URL<span>Enter the URL of the cloud provider.</span></label><%= f.text_field :url, :class => "txtfield" %></li>
+ </ul>
<%= submit_tag "Save", :class => "submit" %>
- <% end %>
+ <% end %>
+ </fieldset>
</div>
\ No newline at end of file
diff --git a/src/public/favicon.ico b/src/public/favicon.ico
index 7189cf9d0ecb5462aa95044134ce113a53ea3ea1..7158b4edc3655135e58943d79c7c16d77824ef81 100644
GIT binary patch
literal 1115
zcmex=<NpH&0WUXCHwH#V1_nkTWcdG&!Nxhr)iK0B$VwqSMK`M;HC>_1P|rX?qqI0P
zFI~aY%U!`Mz|~!$%*;qrN1?DZF(<R6Qo&Zi(7=G}|7`|mpjngwkRg<r0Mz~e0D~Y0
zg8+j7Goum%lOQ9rAmjfd4Dvu<vO>&efC5G)W)@a9b`DN1ZlHp#0t`%y%*;$I%&e>|
zEI`$@KzRlhK~^C}Lq|5@z(jVXLJ_0Ji3>TDoi-j64Z8S2#W<;`iIYoATtZSxRZU$(
zQ_IBE%-q7#%Gt%$&E3P(D>x)HEIcAIDmf)JEj=SMtGJ}Jth}PKs=1}Lt-YhOYtrN?
zQ>RUzF>}_U#Y>hhTfSoDs!f}>Y~8kf$Ie}c4j(ys?D&b3r!HN-a`oEv8#iw~eDwIq
z(`V0LynOZX)8{W=zkUDl^B2fpj10{1AcJ@e&0m5*e=)JJFtf0O{Kd#r4#doYEUb!#
zY(kEK?1_cKN=A(wB2E(*Zam1TY#j7KG^yw!mzavlL)DKUuYr9=oX48T@)_J?2!GvT
z;9+J2Mjo>ugFVBalE2+1w`bI8ys}fhvQMtY?Bn&r`TRe!p4MsI{}X=M#<={UJadJ2
z$o>u6<Hc^r{@Cn&?aOX?v71?eQR;08&92u>ZS%tSURe8O_iS7DfQ-%c+46j^tIE4-
z3|BsW7`Ohz_anPR&u#s%`uKg$I>{fw5BnM)ujleyc|Pa+taa@Vdxf2=^F>}<|Modk
zPVwT`+sUh6NVNz>8k;V@b=KbTgZ|NfEW3X=f871RzSkx^`@^Hhk4nEEzAyA6`S`59
z`D<RuN&2QAkZN0N{zuu)xcl&|yp8LQE`IePTi<N<%E-*{3ooUXF29wZP?5?S`SJMC
zd#sy(IDYVc;NM&mocdAd{lmHc8II@+S1dnX72CEs^<k&!dinU5Lj1fHhBcl`GiLqy
z<u);Uk*nU)mGPNk0<Uf@y|80bV?w*`5Btq$|1&%?_BM_*(~qgulbJlteMZP>d5%jD
z&bXEH8MX_CF1OjvKkIn6p=pI%WEr<``^wG(o;rv1kA*It{&<7^;?D{7S4>-e{gpMi
zY8)~xv9(YCcTwe68J10&sRdICOAGu}m-4(#+9<N>&@?sOhlL@E!J=(P{xkf)2>{b`
BsBHiM
literal 1342
zcmd6nKT5<v7{y-}50D$Ul~^uBk}Y!qVQVYF#zJKA0;be0Hh6;U4HUt~CM*_P<_KF@
z*lwvd<9lHS#{5}av~b|ZeDlrs=6%VK009OFLvSAAd=EGPxE^pF;DPa+xkKg1kf^S2
z7-R5Tq9}sLh;c^lEsE3Rc|Il!va$2n`Ep<SkQBs_l1wahF21{Zqt19N8hZIjt9rj5
z#na^R*4HZDc>2_8rB@$KJ>uErhvzN5?_c*wUD>5o?&#!r8Q)x(<Z1RPE%BefVvW4B
zKE2&j&D!<tX6BUtsh+a$cm4<Z^$z}3hyS*_b9Yf%kD^0=YWLKKtM_N!sosxBJM^k`
z=T8~?TEzvCR(-a<7v+dN+!?B$SlqMaT-WFJ_&ZPOG9sN&JR)wt<=;GSw>9v72D}Eq
hY6(;%e<7<jRmJ_BwfodugMBprGd!ecsHguhz5sj|(QW_$
diff --git a/src/public/stylesheets/dcloud.css b/src/public/stylesheets/dcloud.css
index 0e179f2..cf6b254 100644
--- a/src/public/stylesheets/dcloud.css
+++ b/src/public/stylesheets/dcloud.css
@@ -1,8 +1,83 @@
+fieldset {
+ border: none;
+ margin: 0;
+ padding: 0;
+}
+
+input, select {
+ font-family: "Lucida Grande","Luxi Sans","Bitstream Vera Sans","Trebuchet MS",helvetica,verdana,arial,sans-serif;
+ font-size: 1.4em;
+}
+
+
#provider_form {
- width: 50%;
- padding-left: 25%;
+ background: #e8e8e8;
+ border: solid 8px #f5f5f5;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ margin-top: 54px;
+ width: 500px ;
+ margin-left: auto ;
+ margin-right: auto ;
+ padding: 36px;
+}
+
+#provider_form h2{
+ font-size: 1.9em;
+ font-weight: normal;
+ color: #43728e;
+ margin: 0 0 24px 0;
+ padding: 0;
+}
+
+#provider_form ul {
+ list-style-image: none;
+ list-style-position: outside;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+
+#provider_form ul label {
+ display: block;
+ float: left;
+ padding: 3px 0 24px 0;
+ width: 160px;
+ font-size: 1.4em;
+ color: #616161;
+}
+
+#provider_form ul label span {
+ display: block;
+ float: left;
+ width: 160px;
+ font-size: .8em;
+ color: #9a9a9a;
}
+
+#provider_form ul li {
+ clear:both;
+/* margin-bottom: 18px; */
+}
+
+#provider_form .txtfield {
+ border:2px solid #becfe4;
+ color:#333;
+ display:block;
+ float:left;
+/* margin:5px 0 7px; */
+ outline-color:-moz-use-text-color;
+ outline-style:none;
+ outline-width:medium;
+ padding:3px;
+ width:330px;
+}
+
+
#provider_form .submit {
float: right;
+ margin-top: 18px;
+ display: inline;
+ clear:both;
}
\ No newline at end of file
diff --git a/src/public/stylesheets/layout.css b/src/public/stylesheets/layout.css
index f90ee47..41657fc 100644
--- a/src/public/stylesheets/layout.css
+++ b/src/public/stylesheets/layout.css
@@ -28,10 +28,6 @@ img
}
-textarea:focus, input:focus {
- background-color: #FFFFCC;
-}
-
a { color:#000000; text-decoration: none;}
/**************************
--
1.6.2.5
14 years, 10 months