Blue Mind
Release 1.0

net.bluemind.core.client.system
Class SystemClient

java.lang.Object
  extended by net.bluemind.core.client.impl.AbstractClientImpl
      extended by net.bluemind.core.client.system.SystemClient
All Implemented Interfaces:
ISystem, ISyncClient

public class SystemClient
extends AbstractClientImpl
implements ISystem


Field Summary
 
Fields inherited from class net.bluemind.core.client.impl.AbstractClientImpl
logger
 
Constructor Summary
SystemClient(java.lang.String bjServicesUrl)
           
 
Method Summary
 void assignToDomain(AccessToken at, java.lang.String tag, Host h, java.lang.String domain)
          Attaches a tagged host to a domain.
 java.util.List<java.lang.String> checkCanDelete(AccessToken at, Domain d)
           
 Domain create(AccessToken at, Domain d)
          Creates a domain
 Host create(AccessToken at, Host h)
          Creates a new host
 void createServiceTag(AccessToken at, java.lang.String serviceTag)
          Declares a new system tag, that will be usable to flag hosts.
 void delete(AccessToken at, Domain d)
          Deletes an existing domain
 void delete(AccessToken at, Host h)
          Deletes an existing host
 void deleteServiceTag(AccessToken at, java.lang.String serviceTag)
          Deletes a system tag.
 java.util.List<java.lang.String> fetchTags(AccessToken at, Host h)
          Fetches the tags associated to a host
 ResultList<Domain> find(AccessToken at, DomainQuery dq)
          Find domains matching the given Query object.
 ResultList<Host> find(AccessToken at, HostQuery hq)
          Finds hosts matching the given query
 java.util.List<Host> findAssignedHosts(AccessToken at, java.lang.String tag, java.lang.String domain)
          Finds the server hosts with a tag and attached to a (non-global) domain.
 java.util.List<Host> findTaggedHosts(AccessToken at, java.lang.String tag)
          Find the list of server hosts having a given tag
 Domain getDomainFromId(AccessToken at, int domainId)
          Get domain from ID
 DomainTemplate getDomainTemplate(AccessToken at)
          Get a DomainTemplateImpl that describes the needed servers in a bj domain.
 java.util.Map<java.lang.String,java.lang.String> getParams(AccessToken at, Host h, java.lang.String tag)
           
 java.util.List<java.lang.String> listServiceTags(AccessToken at)
          Returns all the system tags that can be set on a server host.
 AccessToken login(java.lang.String login, java.lang.String password, java.lang.String origin)
           
 void logout(AccessToken at)
           
 java.util.List<java.lang.String> nodeExecuteCommand(AccessToken at, int hostId, java.lang.String cmd)
           
 java.lang.String nodeExecuteCommandNoOut(AccessToken at, int hostId, java.lang.String cmd)
           
 java.lang.String nodeRead(AccessToken at, int hostId, java.lang.String file)
          Read file from a BM host using bm-node
 java.lang.String nodeWrite(AccessToken at, int hostId, java.lang.String fileName, java.lang.String fileContent)
          Write file content to a BM host using bm-node
 java.lang.String resetCustomProperty(AccessToken at, java.lang.String customPropertyName)
           
 void setParams(AccessToken at, Host h, java.lang.String tag, java.util.Map<java.lang.String,java.lang.String> params)
           
 AccessToken sudo(AccessToken token, java.lang.String loginAtDomain)
          Returns an AccessToken for the given loginAtDomain.
 void tag(AccessToken at, Host h, java.lang.String tag)
          Sets a system tag on a server host.
 void unassignFromDomain(AccessToken at, java.lang.String tag, Host h, Domain d)
          detach a tagged host from a domain.
 void untag(AccessToken at, Host h, java.lang.String tag)
          Removes a system tag on a server host.
 Domain update(AccessToken at, Domain d)
          Modifies an existing domain
 Host update(AccessToken at, Host h)
          Modifies an existing host
 void upgrade(AccessToken at, VersionInfo previous, VersionInfo target)
           
 
Methods inherited from class net.bluemind.core.client.impl.AbstractClientImpl
checkServerError, execute, executeStream, executeVoid, initParams, setToken, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemClient

public SystemClient(java.lang.String bjServicesUrl)
Method Detail

listServiceTags

public java.util.List<java.lang.String> listServiceTags(AccessToken at)
                                                 throws ServerFault
Description copied from interface: ISystem
Returns all the system tags that can be set on a server host.

Specified by:
listServiceTags in interface ISystem
Parameters:
at - the user session
Returns:
the list of tag names
Throws:
ServerFault

createServiceTag

public void createServiceTag(AccessToken at,
                             java.lang.String serviceTag)
                      throws ServerFault
Description copied from interface: ISystem
Declares a new system tag, that will be usable to flag hosts.

Specified by:
createServiceTag in interface ISystem
Throws:
ServerFault

deleteServiceTag

public void deleteServiceTag(AccessToken at,
                             java.lang.String serviceTag)
                      throws ServerFault
Description copied from interface: ISystem
Deletes a system tag. All hosts with this tag will be un-tagged.

Specified by:
deleteServiceTag in interface ISystem
Throws:
ServerFault

findTaggedHosts

public java.util.List<Host> findTaggedHosts(AccessToken at,
                                            java.lang.String tag)
                                     throws ServerFault
Description copied from interface: ISystem
Find the list of server hosts having a given tag

Specified by:
findTaggedHosts in interface ISystem
tag - the tag you are looking for
Returns:
Throws:
ServerFault

fetchTags

public java.util.List<java.lang.String> fetchTags(AccessToken at,
                                                  Host h)
                                           throws ServerFault
Description copied from interface: ISystem
Fetches the tags associated to a host

Specified by:
fetchTags in interface ISystem
Returns:
the list of tags (might be empty)
Throws:
ServerFault

findAssignedHosts

public java.util.List<Host> findAssignedHosts(AccessToken at,
                                              java.lang.String tag,
                                              java.lang.String domain)
                                       throws ServerFault
Description copied from interface: ISystem
Finds the server hosts with a tag and attached to a (non-global) domain.

Specified by:
findAssignedHosts in interface ISystem
Returns:
Throws:
ServerFault

tag

public void tag(AccessToken at,
                Host h,
                java.lang.String tag)
         throws ServerFault
Description copied from interface: ISystem
Sets a system tag on a server host. Does nothing if the host is already tagged. The tag is created automatically if it did not exist.

Specified by:
tag in interface ISystem
Throws:
ServerFault

untag

public void untag(AccessToken at,
                  Host h,
                  java.lang.String tag)
           throws ServerFault
Description copied from interface: ISystem
Removes a system tag on a server host.

Specified by:
untag in interface ISystem
Throws:
ServerFault

setParams

public void setParams(AccessToken at,
                      Host h,
                      java.lang.String tag,
                      java.util.Map<java.lang.String,java.lang.String> params)
Specified by:
setParams in interface ISystem

getParams

public java.util.Map<java.lang.String,java.lang.String> getParams(AccessToken at,
                                                                  Host h,
                                                                  java.lang.String tag)
Specified by:
getParams in interface ISystem

assignToDomain

public void assignToDomain(AccessToken at,
                           java.lang.String tag,
                           Host h,
                           java.lang.String domain)
                    throws ServerFault
Description copied from interface: ISystem
Attaches a tagged host to a domain. If the host has multiple tag, only the given tag is used, eg. a server can be 'mail/imap' for zz.com and 'mail/smtp_in' for foo.org.

Specified by:
assignToDomain in interface ISystem
Throws:
ServerFault

unassignFromDomain

public void unassignFromDomain(AccessToken at,
                               java.lang.String tag,
                               Host h,
                               Domain d)
                        throws ServerFault
Description copied from interface: ISystem
detach a tagged host from a domain. If the host has multiple tag, only the given tag is used.

Specified by:
unassignFromDomain in interface ISystem
Throws:
ServerFault

login

public AccessToken login(java.lang.String login,
                         java.lang.String password,
                         java.lang.String origin)
Specified by:
login in interface ISyncClient
Overrides:
login in class AbstractClientImpl

logout

public void logout(AccessToken at)
Specified by:
logout in interface ISyncClient
Overrides:
logout in class AbstractClientImpl

create

public Host create(AccessToken at,
                   Host h)
            throws ServerFault
Description copied from interface: ISystem
Creates a new host

Specified by:
create in interface ISystem
Returns:
Throws:
ServerFault

delete

public void delete(AccessToken at,
                   Host h)
            throws ServerFault
Description copied from interface: ISystem
Deletes an existing host

Specified by:
delete in interface ISystem
Throws:
ServerFault

find

public ResultList<Host> find(AccessToken at,
                             HostQuery hq)
                      throws ServerFault
Description copied from interface: ISystem
Finds hosts matching the given query

Specified by:
find in interface ISystem
Returns:
Throws:
ServerFault

update

public Host update(AccessToken at,
                   Host h)
            throws ServerFault
Description copied from interface: ISystem
Modifies an existing host

Specified by:
update in interface ISystem
Returns:
Throws:
ServerFault

create

public Domain create(AccessToken at,
                     Domain d)
              throws AuthFault,
                     ServerFault
Description copied from interface: ISystem
Creates a domain

Specified by:
create in interface ISystem
Returns:
Throws:
AuthFault
ServerFault

update

public Domain update(AccessToken at,
                     Domain d)
              throws ServerFault
Description copied from interface: ISystem
Modifies an existing domain

Specified by:
update in interface ISystem
Returns:
Throws:
ServerFault

delete

public void delete(AccessToken at,
                   Domain d)
            throws ServerFault
Description copied from interface: ISystem
Deletes an existing domain

Specified by:
delete in interface ISystem
Throws:
ServerFault

getDomainTemplate

public DomainTemplate getDomainTemplate(AccessToken at)
                                 throws ServerFault
Description copied from interface: ISystem
Get a DomainTemplateImpl that describes the needed servers in a bj domain.

Specified by:
getDomainTemplate in interface ISystem
Returns:
Throws:
ServerFault

find

public ResultList<Domain> find(AccessToken at,
                               DomainQuery dq)
                        throws ServerFault
Description copied from interface: ISystem
Find domains matching the given Query object.

Specified by:
find in interface ISystem
Returns:
Throws:
ServerFault

checkCanDelete

public java.util.List<java.lang.String> checkCanDelete(AccessToken at,
                                                       Domain d)
                                                throws ServerFault
Specified by:
checkCanDelete in interface ISystem
Throws:
ServerFault

upgrade

public void upgrade(AccessToken at,
                    VersionInfo previous,
                    VersionInfo target)
             throws ServerFault,
                    AuthFault
Specified by:
upgrade in interface ISystem
Throws:
ServerFault
AuthFault

nodeRead

public java.lang.String nodeRead(AccessToken at,
                                 int hostId,
                                 java.lang.String file)
                          throws ServerFault
Description copied from interface: ISystem
Read file from a BM host using bm-node

Specified by:
nodeRead in interface ISystem
Parameters:
at - bm-core global admin token
hostId - read file from this host ID
file - file to read
Returns:
file content
Throws:
ServerFault

nodeWrite

public java.lang.String nodeWrite(AccessToken at,
                                  int hostId,
                                  java.lang.String fileName,
                                  java.lang.String fileContent)
                           throws ServerFault
Description copied from interface: ISystem
Write file content to a BM host using bm-node

Specified by:
nodeWrite in interface ISystem
Parameters:
at - bm-core global admin token
hostId - write file to this host ID
fileName - file name to write
fileContent - file content
Returns:
string like: "OK: file <filename> writed on node: <hostname> (<hostid>)"
Throws:
ServerFault

nodeExecuteCommand

public java.util.List<java.lang.String> nodeExecuteCommand(AccessToken at,
                                                           int hostId,
                                                           java.lang.String cmd)
                                                    throws ServerFault
Specified by:
nodeExecuteCommand in interface ISystem
Throws:
ServerFault

nodeExecuteCommandNoOut

public java.lang.String nodeExecuteCommandNoOut(AccessToken at,
                                                int hostId,
                                                java.lang.String cmd)
                                         throws ServerFault
Specified by:
nodeExecuteCommandNoOut in interface ISystem
Throws:
ServerFault

resetCustomProperty

public java.lang.String resetCustomProperty(AccessToken at,
                                            java.lang.String customPropertyName)
                                     throws ServerFault
Specified by:
resetCustomProperty in interface ISystem
Throws:
ServerFault

getDomainFromId

public Domain getDomainFromId(AccessToken at,
                              int domainId)
                       throws ServerFault
Description copied from interface: ISystem
Get domain from ID

Specified by:
getDomainFromId in interface ISystem
Returns:
Throws:
ServerFault

sudo

public AccessToken sudo(AccessToken token,
                        java.lang.String loginAtDomain)
                 throws AuthFault,
                        ServerFault
Description copied from interface: ISyncClient
Returns an AccessToken for the given loginAtDomain. The provided AccessToken must be an admin0@global.virt token.

Specified by:
sudo in interface ISyncClient
Overrides:
sudo in class AbstractClientImpl
Returns:
Throws:
AuthFault
ServerFault

Blue Mind
Release 1.0