Skip to content

Commit

Permalink
Merge pull request #134 from byxorna/gabe-fix-hipchat-user-provisioning
Browse files Browse the repository at this point in the history
Provisioning profiles support for contact and contact_notes fields
  • Loading branch information
William Richard committed Mar 17, 2014
2 parents d5a28e0 + 5385f37 commit 43dfda1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/collins/provisioning/ProfileLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ object ProfileLoader {
optionalButNonEmpty(profile.getPrimary_role()),
optionalButNonEmpty(profile.getPool()),
optionalButNonEmpty(profile.getSecondary_role()),
optionalButNonEmpty(profile.getContact()),
optionalButNonEmpty(profile.getContact_notes()),
Option(profile.getRequires_primary_role()).map(_.booleanValue()).getOrElse(true),
Option(profile.getRequires_pool()).map(_.booleanValue()).getOrElse(true),
Option(profile.getRequires_secondary_role()).map(_.booleanValue()).getOrElse(false)
Expand Down
4 changes: 3 additions & 1 deletion app/collins/provisioning/ProvisionerRoleData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ case class ProvisionerRoleData(
primary_role: Option[String],
pool: Option[String],
secondary_role: Option[String],
contact: Option[String],
contact_notes: Option[String],
requires_primary_role: Boolean,
requires_pool: Boolean,
requires_secondary_role: Boolean
) {
def this() = this(None,None,None,false,false,false)
def this() = this(None,None,None,None,None,false,false,false)
}


8 changes: 5 additions & 3 deletions app/controllers/actions/asset/ProvisionUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,19 @@ trait ProvisionUtil { self: SecureAction =>
}

protected def attribs(request: ProvisionerRequest, form: ProvisionForm): Map[String,String] = {
val contact = form._2
val build_contact = form._2
val suffix = form._3
val role = request.profile.role
val attribSequence =
Seq(
"NODECLASS" -> request.profile.identifier,
"CONTACT" -> contact,
"CONTACT" -> role.contact.getOrElse(""),
"CONTACT_NOTES" -> role.contact_notes.getOrElse(""),
"SUFFIX" -> suffix.getOrElse(""),
"PRIMARY_ROLE" -> role.primary_role.getOrElse(""),
"POOL" -> role.pool.getOrElse(""),
"SECONDARY_ROLE" -> role.secondary_role.getOrElse("")
"SECONDARY_ROLE" -> role.secondary_role.getOrElse(""),
"BUILD_CONTACT" -> build_contact
)
val mapForDelete = Feature.deleteSomeMetaOnRepurpose.map(_.name).map(s => (s -> "")).toMap
mapForDelete ++ Map(attribSequence:_*)
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/tumblr/play/interop/JProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class JProfile implements java.io.Serializable {
private String primary_role;
private String secondary_role;
private String pool;
private String contact;
private String contact_notes;

private Boolean allow_suffix;
private Boolean requires_primary_role;
Expand Down Expand Up @@ -46,6 +48,20 @@ public void setPrimary_role(final String primary_role) {
this.primary_role = primary_role;
}

public String getContact() {
return contact;
}
public void setContact(final String contact) {
this.contact = contact;
}

public String getContact_notes() {
return contact_notes;
}
public void setContact_notes(final String contact_notes) {
this.contact_notes = contact_notes;
}

public String getSecondary_role() {
return secondary_role;
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/asset/showModal/provision.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<li>Come back online without old data on disks</li>
</ul>
}
<p>If that all sounds good, choose an appropriate profile below and provide your hipchat username for notification</p>
<p>If that all sounds good, choose an appropriate profile below and provide your contact for notification</p>
<div class="control-group">
<label for="profile" class="control-label">Profile</label>
<div class="controls">
Expand Down Expand Up @@ -79,7 +79,7 @@
</div>
</div>
<div class="control-group">
<label for="contact" class="control-label">Hipchat User</label>
<label for="contact" class="control-label">Notification Contact</label>
<div class="controls">
<input type="text" name="contact" id="contact" value="@user.username">
</div>
Expand Down

0 comments on commit 43dfda1

Please sign in to comment.