...
To define your own services and stacks to be managed by Ambari, follow the steps below to define your own services or stacks.
There is also an example you can follow to create your custom stack and service.
...
Component scripts should extend resource_management.Script
class and provide methods required for that component's lifecycle.
Taken from the page on how to create custom stack, the following methods are needed for MASTER, SLAVE and CLIENT components to go through their lifecycle.
Code Block |
---|
language | py |
---|
title | master.py |
---|
linenumbers | true |
---|
|
import sys
from resource_management import *
class Master(Script):
def install(self, env):
print 'Install the Sample Srv Master';
def stop(self, env):
print 'Stop the Sample Srv Master';
def start(self, env):
print 'Start the Sample Srv Master';
def status(self, env):
print 'Status of the Sample Srv Master';
def configure(self, env):
print 'Configure the Sample Srv Master';
if __name__ == "__main__":
Master().execute() |
Code Block |
---|
language | py |
---|
title | slave.py |
---|
linenumbers | true |
---|
|
import sys
from resource_management import *
class Slave(Script):
def install(self, env):
print 'Install the Sample Srv Slave';
def stop(self, env):
print 'Stop the Sample Srv Slave';
def start(self, env):
print 'Start the Sample Srv Slave';
def status(self, env):
print 'Status of the Sample Srv Slave';
def configure(self, env):
print 'Configure the Sample Srv Slave';
if __name__ == "__main__":
Slave().execute() |
Code Block |
---|
language | py |
---|
title | client.py |
---|
linenumbers | true |
---|
|
import sys
from resource_management import *
class SampleClient(Script):
def install(self, env):
print 'Install the Sample Srv Client';
def configure(self, env):
print 'Configure the Sample Srv Client';
if __name__ == "__main__":
SampleClient().execute() |
Ambari provides helpful Python libraries below which are useful in writing service scripts. For complete reference on these libraries visit the Ambari Python Libraries page. TODO
- resource_management
- ambari_commons
- ambari_simplejson
Configuration
Files
Alerts
Kerberos
...