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