summaryrefslogtreecommitdiffstats
path: root/fuel/deploy/cloud_deploy/cloud_deploy.py
diff options
context:
space:
mode:
authorJonas Bjurel <jonas.bjurel@ericsson.com>2015-05-20 13:19:56 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2015-05-20 13:19:56 +0000
commit13f4399c1d0958d3c1943d75269e47058b521c9e (patch)
treec8452efff0376f58050cf8c2019efb95d8f3df2c /fuel/deploy/cloud_deploy/cloud_deploy.py
parent14674941d0e504a942886d36749a0f64490e4ade (diff)
parent945dca48c0b1fd93fec43513afb6680a8d828e33 (diff)
Merge "Autodeploy inspired on Prototype #2"
Diffstat (limited to 'fuel/deploy/cloud_deploy/cloud_deploy.py')
-rw-r--r--fuel/deploy/cloud_deploy/cloud_deploy.py117
1 files changed, 0 insertions, 117 deletions
diff --git a/fuel/deploy/cloud_deploy/cloud_deploy.py b/fuel/deploy/cloud_deploy/cloud_deploy.py
deleted file mode 100644
index 4197519..0000000
--- a/fuel/deploy/cloud_deploy/cloud_deploy.py
+++ /dev/null
@@ -1,117 +0,0 @@
-import os
-import io
-import yaml
-
-from cloud import common
-from cloud.dea import DeploymentEnvironmentAdapter
-from hardware_adapters.dha import DeploymentHardwareAdapter
-from ssh_client import SSHClient
-
-exec_cmd = common.exec_cmd
-err = common.err
-check_file_exists = common.check_file_exists
-LOG = common.LOG
-
-class CloudDeploy(object):
-
- def __init__(self, fuel_ip, fuel_username, fuel_password):
- self.fuel_ip = fuel_ip
- self.fuel_username = fuel_username
- self.fuel_password = fuel_password
- self.shelf_blades_dict = {}
- self.macs_per_shelf_dict = {}
-
- def copy_to_fuel_master(self, dir_path=None, file_path=None, target='~'):
- if dir_path:
- path = '-r ' + dir_path
- elif file_path:
- path = file_path
- LOG.debug('Copying %s to Fuel Master %s' % (path, target))
- if path:
- exec_cmd('sshpass -p %s scp -o UserKnownHostsFile=/dev/null'
- ' -o StrictHostKeyChecking=no -o ConnectTimeout=15'
- ' %s %s@%s:%s'
- % (self.fuel_password, path, self.fuel_username,
- self.fuel_ip, target))
-
- def run_cloud_deploy(self, deploy_dir, deploy_app):
- LOG.debug('START CLOUD DEPLOYMENT')
- ssh = SSHClient(self.fuel_ip, self.fuel_username, self.fuel_password)
- ssh.open()
- ssh.run('python %s/%s' % (deploy_dir, deploy_app))
- ssh.close()
-
- def power_off_blades(self, dea):
- for shelf, blade_list in self.shelf_blades_dict.iteritems():
- type, mgmt_ip, username, password = dea.get_shelf_info(shelf)
- dha = DeploymentHardwareAdapter(type, mgmt_ip, username, password)
- dha.power_off_blades(shelf, blade_list)
-
- def power_on_blades(self, dea):
- for shelf, blade_list in self.shelf_blades_dict.iteritems():
- type, mgmt_ip, username, password = dea.get_shelf_info(shelf)
- dha = DeploymentHardwareAdapter(type, mgmt_ip, username, password)
- dha.power_on_blades(shelf, blade_list)
-
- def set_boot_order(self, dea):
- for shelf, blade_list in self.shelf_blades_dict.iteritems():
- type, mgmt_ip, username, password = dea.get_shelf_info(shelf)
- dha = DeploymentHardwareAdapter(type, mgmt_ip, username, password)
- dha.set_boot_order_blades(shelf, blade_list)
-
- def get_mac_addresses(self, dea, macs_yaml):
- self.macs_per_shelf_dict = {}
- for shelf, blade_list in self.shelf_blades_dict.iteritems():
- type, mgmt_ip, username, password = dea.get_shelf_info(shelf)
- dha = DeploymentHardwareAdapter(type, mgmt_ip, username, password)
- self.macs_per_shelf_dict[shelf] = dha.get_blades_mac_addresses(
- shelf, blade_list)
-
- with io.open(macs_yaml, 'w') as stream:
- yaml.dump(self.macs_per_shelf_dict, stream,
- default_flow_style=False)
-
- def collect_blade_ids_per_shelves(self, dea):
- self.shelf_blades_dict = dea.get_blade_ids_per_shelves()
-
-
-
-def main():
-
- fuel_ip = '10.20.0.2'
- fuel_username = 'root'
- fuel_password = 'r00tme'
- deploy_dir = '~/cloud'
-
- cloud = CloudDeploy(fuel_ip, fuel_username, fuel_password)
-
- base_dir = os.path.dirname(os.path.realpath(__file__))
- deployment_dir = base_dir + '/cloud'
- macs_yaml = base_dir + '/macs.yaml'
- dea_yaml = base_dir + '/dea.yaml'
- check_file_exists(dea_yaml)
-
- cloud.copy_to_fuel_master(dir_path=deployment_dir)
- cloud.copy_to_fuel_master(file_path=dea_yaml, target=deploy_dir)
-
- dea = DeploymentEnvironmentAdapter()
- dea.parse_yaml(dea_yaml)
-
- cloud.collect_blade_ids_per_shelves(dea)
-
- cloud.power_off_blades(dea)
-
- cloud.set_boot_order(dea)
-
- cloud.power_on_blades(dea)
-
- cloud.get_mac_addresses(dea, macs_yaml)
- check_file_exists(dea_yaml)
-
- cloud.copy_to_fuel_master(file_path=macs_yaml, target=deploy_dir)
-
- cloud.run_cloud_deploy(deploy_dir, 'deploy.py')
-
-
-if __name__ == '__main__':
- main() \ No newline at end of file