Examples cleanup
1. The auth section and the region_name option are not used anywhere and they were removed from all examples. 2. Now all examples are up to date with the new code in the library. Change-Id: I2b8594046cf217085e73caf7626ae0ab0ae74d97
This commit is contained in:
parent
6cf32e7896
commit
af9c6f1f40
@ -18,12 +18,6 @@ import os_faults
|
||||
def main():
|
||||
# cloud config schema is an extension to os-client-config
|
||||
cloud_config = {
|
||||
'auth': {
|
||||
'username': 'admin',
|
||||
'password': 'admin',
|
||||
'project_name': 'admin',
|
||||
},
|
||||
'region_name': 'RegionOne',
|
||||
'cloud_management': {
|
||||
'driver': 'devstack',
|
||||
'address': 'devstack.local',
|
||||
@ -31,17 +25,14 @@ def main():
|
||||
}
|
||||
}
|
||||
|
||||
logging.info('# Create connection')
|
||||
distractor = os_faults.connect(cloud_config)
|
||||
logging.info('# Create connection to the cloud')
|
||||
destructor = os_faults.connect(cloud_config)
|
||||
|
||||
logging.info('# Verify connection to the cloud')
|
||||
distractor.verify()
|
||||
destructor.verify()
|
||||
|
||||
logging.info('# Get a particular service in the cloud')
|
||||
service = distractor.get_service(name='keystone-api')
|
||||
logging.info('Keystone API Service: %s', service)
|
||||
|
||||
logging.info('# Restart the service')
|
||||
logging.info('# Restart Keystone service on all nodes')
|
||||
service = destructor.get_service(name='keystone')
|
||||
service.restart()
|
||||
|
||||
|
||||
|
@ -18,12 +18,6 @@ import os_faults
|
||||
def main():
|
||||
# cloud config schema is an extension to os-client-config
|
||||
cloud_config = {
|
||||
'auth': {
|
||||
'username': 'admin',
|
||||
'password': 'admin',
|
||||
'project_name': 'admin',
|
||||
},
|
||||
'region_name': 'RegionOne',
|
||||
'cloud_management': {
|
||||
'driver': 'fuel',
|
||||
'address': 'fuel.local',
|
||||
|
@ -18,12 +18,6 @@ import os_faults
|
||||
def main():
|
||||
# cloud config schema is an extension to os-client-config
|
||||
cloud_config = {
|
||||
'auth': {
|
||||
'username': 'admin',
|
||||
'password': 'admin',
|
||||
'project_name': 'admin',
|
||||
},
|
||||
'region_name': 'RegionOne',
|
||||
'cloud_management': {
|
||||
'driver': 'fuel',
|
||||
'address': 'fuel.local',
|
||||
@ -52,5 +46,5 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
|
||||
level=logging.INFO)
|
||||
level=logging.DEBUG)
|
||||
main()
|
||||
|
@ -18,77 +18,61 @@ import os_faults
|
||||
def main():
|
||||
# cloud config schema is an extension to os-client-config
|
||||
cloud_config = {
|
||||
'auth': {
|
||||
'username': 'admin',
|
||||
'password': 'admin',
|
||||
'project_name': 'admin',
|
||||
},
|
||||
'region_name': 'RegionOne',
|
||||
'cloud_management': {
|
||||
'driver': 'fuel',
|
||||
'address': 'fuel.local',
|
||||
'username': 'root',
|
||||
},
|
||||
'power_management': {
|
||||
'driver': 'kvm',
|
||||
'address': 'kvm.local',
|
||||
'username': 'root',
|
||||
'driver': 'libvirt',
|
||||
'connection_uri': 'qemu+ssh://ubuntu@host.local/system'
|
||||
}
|
||||
}
|
||||
|
||||
logging.info('# Create connection')
|
||||
distractor = os_faults.connect(cloud_config)
|
||||
logging.info('# Create connection to the cloud')
|
||||
destructor = os_faults.connect(cloud_config)
|
||||
|
||||
logging.info('# Verify connection to the cloud')
|
||||
distractor.verify()
|
||||
destructor.verify()
|
||||
|
||||
# os_faults library operate with 2 types of objects:
|
||||
# service - is software that runs in the cloud, e.g. keystone, mysql,
|
||||
# rabbitmq, nova-api, glance-api
|
||||
# nodes - nodes that host the cloud, e.g. hardware server with hostname
|
||||
|
||||
logging.info('# Get a particular service in the cloud')
|
||||
service = distractor.get_service(name='keystone')
|
||||
logging.info('Keystone API Service: %s', service)
|
||||
|
||||
# Note: Only for Keystone!
|
||||
logging.info('# Restart the service')
|
||||
service.restart()
|
||||
|
||||
logging.info('# Get nodes where the service runs')
|
||||
logging.info('# Get nodes where Nova API service runs')
|
||||
service = destructor.get_service(name='nova-api')
|
||||
nodes = service.get_nodes()
|
||||
logging.info('Nodes: %s', nodes)
|
||||
|
||||
logging.info('# Reboot these nodes')
|
||||
nodes.reboot()
|
||||
logging.info('# Restart Nova API service on all nodes')
|
||||
service.restart()
|
||||
|
||||
logging.info('# Pick one one out of collection of nodes')
|
||||
logging.info('# Pick and reset one of Nova API service nodes')
|
||||
one = nodes.pick()
|
||||
|
||||
logging.info('# Switch the node off')
|
||||
one.poweroff()
|
||||
one.reset()
|
||||
|
||||
logging.info('# Get all nodes in the cloud')
|
||||
nodes = distractor.get_nodes()
|
||||
nodes = destructor.get_nodes()
|
||||
logging.info('All cloud nodes: %s', nodes)
|
||||
|
||||
logging.info('# Reset all these nodes')
|
||||
nodes.reset()
|
||||
|
||||
logging.info('# Get nodes by their FQDNs')
|
||||
nodes = distractor.get_nodes(fqdns=['node-2.domain.tld'])
|
||||
logging.info('Node with specific FQDN: %s', nodes)
|
||||
logging.info('# Get node by FQDN: node-2.domain.tld')
|
||||
nodes = destructor.get_nodes(fqdns=['node-2.domain.tld'])
|
||||
logging.info('Node node-2.domain.tld: %s', nodes)
|
||||
|
||||
logging.info('# Disable public network on these nodes')
|
||||
logging.info('# Disable public network on node-2.domain.tld')
|
||||
nodes.disable_network(network_name='public')
|
||||
|
||||
logging.info('# Enable public network on these nodes')
|
||||
logging.info('# Enable public network on node-2.domain.tld')
|
||||
nodes.enable_network(network_name='public')
|
||||
|
||||
logging.info('# Restart service on a single node')
|
||||
service = distractor.get_service(name='keystone-api')
|
||||
logging.info('# Kill Glance API service on a single node')
|
||||
service = destructor.get_service(name='glance-api')
|
||||
nodes = service.get_nodes().pick()
|
||||
service.restart(nodes)
|
||||
service.kill(nodes)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -17,8 +17,7 @@ from os_faults.drivers import fuel
|
||||
from os_faults.drivers import ipmi
|
||||
from os_faults.drivers import libvirt_driver
|
||||
|
||||
__version__ = pbr.version.VersionInfo(
|
||||
'os_faults').version_string()
|
||||
__version__ = pbr.version.VersionInfo('os_faults').version_string()
|
||||
|
||||
|
||||
def connect(cloud_config):
|
||||
@ -37,8 +36,7 @@ def connect(cloud_config):
|
||||
power_management = libvirt_driver.LibvirtDriver(
|
||||
power_management_params)
|
||||
elif power_management_params.get('driver') == 'ipmi':
|
||||
power_management = ipmi.IPMIDriver(
|
||||
power_management_params)
|
||||
power_management = ipmi.IPMIDriver(power_management_params)
|
||||
|
||||
cloud_management.set_power_management(power_management)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user