Skip to content

Commit

Permalink
merging ("virsh console" approach is commented out until it is tested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrii Zagorodnov committed Jun 17, 2009
2 parents 1e733bd + 9e8ec31 commit d5c9d1d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 12 deletions.
Expand Up @@ -103,7 +103,8 @@ public class EucalyptusWebInterface implements EntryPoint {
private Label label_box = new Label();
private CheckBox check_box = new CheckBox("", false);
private Label remember_label = new Label(MSG.rememberMe());

private static Label statusMessage = new Label();

public void onModuleLoad()
{
sessionId = Cookies.getCookie( cookie_name );
Expand Down Expand Up @@ -715,7 +716,6 @@ public void onFailure( Throwable caught )
userToSave,
new AsyncCallback() {
public void onSuccess(Object result) {
displayDialog("", (String) result);
if (loggedInUser.getUserName().equals(userToSave.getUserName())) {
loggedInUser.setRealName(userToSave.getRealName());
loggedInUser.setEmail(userToSave.getEmail());
Expand All @@ -724,6 +724,12 @@ public void onSuccess(Object result) {
loggedInUser.setAffiliation(userToSave.getAffiliation());
loggedInUser.setProjectDescription(userToSave.getProjectDescription());
loggedInUser.setProjectPIName(userToSave.getProjectPIName());
displayDialog("", (String) result);

} else { // admin updating a user
displayBarAndTabs("");
statusMessage.setText( ( String ) result );
statusMessage.setStyleName("euca-small-text");
}
}

Expand Down Expand Up @@ -1032,6 +1038,29 @@ public void onFailure( Throwable caught )
);
}

public void attemptActionNoReload( String action, String param, final VerticalPanel parent )
{
statusMessage.setText( "Contacting the server..." );
EucalyptusWebBackend.App.getInstance().performAction(
sessionId,
action,
param,
new AsyncCallback() {
public void onSuccess( Object result )
{
displayBarAndTabs("");
statusMessage.setText( ( String ) result );
statusMessage.setStyleName("euca-small-text");
}

public void onFailure( Throwable caught )
{
displayErrorPage( caught.getMessage() );
}
}
);
}

public void executeAction( String action )
{
/* NOTE: some of the checks are repeated by the server,
Expand Down Expand Up @@ -1214,6 +1243,12 @@ public void displayBarAndTabs(String message)
top_bar.setCellHorizontalAlignment(upanel, HorizontalPanel.ALIGN_RIGHT);
top_bar.setCellVerticalAlignment(upanel, HorizontalPanel.ALIGN_MIDDLE);

final HorizontalPanel messageBox = new HorizontalPanel();
messageBox.setSize("100%", "0"); // let the font determine the height
messageBox.setSpacing(3);
messageBox.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
messageBox.add (statusMessage);

final VerticalPanel wrapper = new VerticalPanel();
wrapper.setSize("100%", "80%");
wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
Expand All @@ -1237,6 +1272,7 @@ public void displayBarAndTabs(String message)
allTabs.addTabListener(new TabListener() {
public void onTabSelected(SourcesTabEvents sender, int tabIndex) {
String error = "This tab is not implemented yet, sorry!";
statusMessage.setText("");
wrapper.clear();
currentTabIndex = tabIndex;
if (tabIndex==credsTabIndex) { displayCredentialsTab(wrapper); }
Expand All @@ -1254,6 +1290,7 @@ public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
RootPanel.get().clear();
RootPanel.get().add( top_bar );
RootPanel.get().add( allTabs );
RootPanel.get().add( messageBox );
RootPanel.get().add( wrapper );
allTabs.selectTab(currentTabIndex);
}
Expand Down Expand Up @@ -1897,8 +1934,20 @@ public void onClick(Widget sender) {
"Do you want to delete user '" + userName + "'?", deleteButton);
okButton.setText ("Cancel");
label_box.setStyleName("euca-greeting-warning");

//new EucalyptusDialog ("Sure?", "Do you want to delete user '" + userName + "'?", deleteButton);
}

public void displayConfirmDeletePageNoReload ( final String userName, final VerticalPanel parent )
{
Button deleteButton = new Button ("Delete", new ClickListener() {
public void onClick(Widget sender) {
attemptActionNoReload("delete", userName, parent);
}
});

Button okButton = displayDialog ("Sure?",
"Do you want to delete user '" + userName + "'?", deleteButton);
okButton.setText ("Cancel");
label_box.setStyleName("euca-greeting-warning");
}

private HTML userActionButton (String action, UserInfoWeb user)
Expand All @@ -1910,6 +1959,18 @@ private HTML userActionButton (String action, UserInfoWeb user)
+ "\">" + action + "</a>");
}

private HTML userActionButtonNoReload (final String action, final UserInfoWeb user, final VerticalPanel parent)
{
HTML link = new HTML (action);
link.setStyleName("euca-action-link");
link.addClickListener(new ClickListener() {
public void onClick (Widget sender) {
attemptActionNoReload(action.toLowerCase(), user.getUserName(), parent);
}
});
return link;
}

class EditCallback implements ClickListener {

private EucalyptusWebInterface parent;
Expand Down Expand Up @@ -2007,19 +2068,19 @@ public void onClick(Widget sender) {

// admin can't be disabled or deleted (that breaks things)
if (!u.isAdministrator().booleanValue()) {
HTML act_button = userActionButton ("Disable", u);
HTML act_button = userActionButtonNoReload ("Disable", u, parent);
if (!u.isApproved().booleanValue()) {
act_button = userActionButton ("Approve", u);
act_button = userActionButtonNoReload ("Approve", u, parent);
} else if (!u.isEnabled().booleanValue()) {
act_button = userActionButton ("Enable", u);
act_button = userActionButtonNoReload ("Enable", u, parent);
}
ops.add(act_button);

Hyperlink del_button = new Hyperlink( "Delete", null );
del_button.setStyleName ("euca-action-link");
del_button.addClickListener( new ClickListener() {
public void onClick(Widget sender) {
displayConfirmDeletePage (u.getUserName());
displayConfirmDeletePageNoReload (u.getUserName(), parent);
}
});
ops.add(del_button);
Expand Down
Expand Up @@ -591,7 +591,7 @@ public String changePassword (String sessionId, String oldPassword, String newPa
user.setPasswordExpires( new Long(now + pass_expiration_ms) );
EucalyptusManagement.commitWebUser( user );

return "Your password has been changed";
return "Password has been changed";
}

public String updateUserRecord (String sessionId, UserInfoWeb newRecord )
Expand Down Expand Up @@ -630,7 +630,7 @@ public String updateUserRecord (String sessionId, UserInfoWeb newRecord )

EucalyptusManagement.commitWebUser( oldRecord );

return "Account updated";
return "Account of user '" + userName + "' was updated";
}

public List<ClusterInfoWeb> getClusterList(String sessionId) throws SerializableException
Expand Down
5 changes: 3 additions & 2 deletions node/handlers_xen.c
Expand Up @@ -793,11 +793,10 @@ static int doRebootInstance(ncMetadata *meta, char *instanceId)

static int doGetConsoleOutput(ncMetadata *meta, char *instanceId, char **consoleOutput) {
char *output;
char cmd[256];
int pid, status, rc, bufsize, fd;
char filename[1024];

logprintfl(EUCADEBUG, "getconsoleoutput called\n");
logprintfl (EUCAINFO, "doGetConsoleOutput() invoked (id=%s)\n", instanceId);

if (getuid() != 0) {
output = strdup("NOT SUPPORTED");
Expand All @@ -822,6 +821,8 @@ static int doGetConsoleOutput(ncMetadata *meta, char *instanceId, char **console
dup2(fd, 2);
dup2(2, 1);
close(0);
// TODO: test virsh console:
// rc = execl(rootwrap_command_path, rootwrap_command_path, "virsh", "console", instanceId, NULL);
rc = execl("/usr/sbin/xm", "/usr/sbin/xm", "console", instanceId, NULL);
fprintf(stderr, "execl() failed\n");
close(fd);
Expand Down
1 change: 1 addition & 0 deletions util/eucalyptus.h
Expand Up @@ -6,6 +6,7 @@

/* file paths relative to $EUCALYPTUS */
#define EUCALYPTUS_CONF_LOCATION "%s/etc/eucalyptus/eucalyptus.conf"
#define EUCALYPTUS_ROOTWRAP "%s/usr/lib/eucalyptus/euca_rootwrap"
#define EUCALYPTUS_ADD_KEY "%s/usr/lib/eucalyptus/euca_rootwrap %s/usr/share/eucalyptus/add_key.pl %s/usr/lib/eucalyptus/euca_mountwrap"
#define EUCALYPTUS_GEN_LIBVIRT_XML "%s/usr/lib/eucalyptus/euca_rootwrap %s/usr/share/eucalyptus/gen_libvirt_xml"
#define EUCALYPTUS_GEN_KVM_LIBVIRT_XML "%s/usr/lib/eucalyptus/euca_rootwrap %s/usr/share/eucalyptus/gen_kvm_libvirt_xml"
Expand Down

0 comments on commit d5c9d1d

Please sign in to comment.