def __init__(self, host, member_no, template, user, password, rootdir, distribution, dir_name, hosts, ds_seed_nodes, rpc_seed_nodes, replicas, clean=False): self.host = host self.member_no = member_no self.template = template self.user = user self.password = password self.rootdir = rootdir self.clean = clean self.distribution = distribution self.dir_name = dir_name self.hosts = hosts self.ds_seed_nodes = ds_seed_nodes self.rpc_seed_nodes = rpc_seed_nodes self.replicas = replicas # Connect to the remote host and start doing operations self.remote = RemoteHost(self.host, self.user, self.password, self.rootdir)
def main(): hosts = args.hosts.split(",") for x in range(0, len(hosts)): # Connect to the remote host and start doing operations remote = RemoteHost(hosts[x], args.user, args.password, args.rootdir) remote.kill_controller() if args.clean: remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/*journal") remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/snapshots") remote.start_controller(args.rootdir + "/deploy/current")
def main(): hosts = args.hosts.split(",") for x in range(0, len(hosts)): # Connect to the remote host and start doing operations remote = RemoteHost(hosts[x], args.user, args.password, args.rootdir) remote.kill_controller() if(args.clean): remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/journal") remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/snapshots") remote.start_controller(args.rootdir + "/deploy/current")
class Deployer: def __init__(self, host, member_no, template, user, password, rootdir, distribution, dir_name, hosts, ds_seed_nodes, rpc_seed_nodes, replicas, clean=False): self.host = host self.member_no = member_no self.template = template self.user = user self.password = password self.rootdir = rootdir self.clean = clean self.distribution = distribution self.dir_name = dir_name self.hosts = hosts self.ds_seed_nodes = ds_seed_nodes self.rpc_seed_nodes = rpc_seed_nodes self.replicas = replicas # Connect to the remote host and start doing operations self.remote = RemoteHost(self.host, self.user, self.password, self.rootdir) def kill_controller(self): self.remote.copy_file("kill_controller.sh", self.rootdir + "/") self.remote.exec_cmd(self.rootdir + "/kill_controller.sh") def deploy(self): # Determine distribution version distribution_name \ = os.path.splitext(os.path.basename(self.distribution))[0] distribution_ver = re.search('(\d+\.\d+\.\d+-\w+\Z)|' '(\d+\.\d+\.\d+-\w+)(-RC\d+\Z)|' '(\d+\.\d+\.\d+-\w+)(-RC\d+(\.\d+)\Z)|' '(\d+\.\d+\.\d+-\w+)(-SR\d+\Z)|' '(\d+\.\d+\.\d+-\w+)(-SR\d+(\.\d+)\Z)', distribution_name) # noqa if distribution_ver is None: print distribution_name + " is not a valid distribution version." \ " (Must contain version in the form: " \ "\"<#>.<#>.<#>-<name>\" or \"<#>.<#>." \ "<#>-<name>-SR<#>\" or \"<#>.<#>.<#>" \ "-<name>-RC<#>\", e.g. 0.2.0-SNAPSHOT)" sys.exit(1) distribution_ver = distribution_ver.group() # Render all the templates renderer = TemplateRenderer(self.template) akka_conf = renderer.render( "akka.conf.template", "akka.conf", { "HOST": self.host, "MEMBER_NAME": "member-" + str(self.member_no), "DS_SEED_NODES": array_str(self.ds_seed_nodes), "RPC_SEED_NODES": array_str(self.rpc_seed_nodes) }) module_shards_conf = renderer.render("module-shards.conf.template", "module-shards.conf", self.replicas) modules_conf = renderer.render("modules.conf.template", "modules.conf") features_cfg = \ renderer.render("org.apache.karaf.features.cfg.template", "org.apache.karaf.features.cfg", {"ODL_DISTRIBUTION": distribution_ver}) jolokia_xml = renderer.render("jolokia.xml.template", "jolokia.xml") management_cfg = \ renderer.render("org.apache.karaf.management.cfg.template", "org.apache.karaf.management.cfg", {"HOST": self.host}) datastore_cfg = \ renderer.render( "org.opendaylight.controller.cluster.datastore.cfg.template", "org.opendaylight.controller.cluster.datastore.cfg") # Delete all the sub-directories under the deploy directory if # the --clean flag is used if self.clean is True: self.remote.exec_cmd("rm -rf " + self.rootdir + "/deploy/*") # Create the deployment directory self.remote.mkdir(self.dir_name) # Clean the m2 repository self.remote.exec_cmd("rm -rf " + self.rootdir + "/.m2/repository") # Copy the distribution to the host and unzip it odl_file_path = self.dir_name + "/odl.zip" self.remote.copy_file(self.distribution, odl_file_path) self.remote.exec_cmd("unzip -o " + odl_file_path + " -d " + self.dir_name + "/") # Rename the distribution directory to odl self.remote.exec_cmd("mv " + self.dir_name + "/" + distribution_name + " " + self.dir_name + "/odl") # Copy all the generated files to the server self.remote.mkdir(self.dir_name + "/odl/configuration/initial") self.remote.copy_file(akka_conf, self.dir_name + "/odl/configuration/initial/") self.remote.copy_file(module_shards_conf, self.dir_name + "/odl/configuration/initial/") self.remote.copy_file(modules_conf, self.dir_name + "/odl/configuration/initial/") self.remote.copy_file(features_cfg, self.dir_name + "/odl/etc/") self.remote.copy_file(jolokia_xml, self.dir_name + "/odl/deploy/") self.remote.copy_file(management_cfg, self.dir_name + "/odl/etc/") if datastore_cfg is not None: self.remote.copy_file(datastore_cfg, self.dir_name + "/odl/etc/") # Add symlink self.remote.exec_cmd("ln -sfn " + self.dir_name + " " + args.rootdir + "/deploy/current") # Run karaf self.remote.start_controller(self.dir_name)
class Deployer: def __init__(self, host, member_no, template, user, password, rootdir, distribution, dir_name, hosts, ds_seed_nodes, rpc_seed_nodes, replicas, clean=False): self.host = host self.member_no = member_no self.template = template self.user = user self.password = password self.rootdir = rootdir self.clean = clean self.distribution = distribution self.dir_name = dir_name self.hosts = hosts self.ds_seed_nodes = ds_seed_nodes self.rpc_seed_nodes = rpc_seed_nodes self.replicas = replicas # Connect to the remote host and start doing operations self.remote = RemoteHost(self.host, self.user, self.password, self.rootdir) def kill_controller(self): self.remote.copy_file("kill_controller.sh", self.rootdir + "/") self.remote.exec_cmd(self.rootdir + "/kill_controller.sh") def deploy(self): # Determine distribution version distribution_name \ = os.path.splitext(os.path.basename(self.distribution))[0] distribution_ver = re.search('(\d+\.\d+\.\d+-\w+\Z)|' '(\d+\.\d+\.\d+-\w+)(-SR\d+\Z)|' '(\d+\.\d+\.\d+-\w+)(-SR\d+(\.\d+)\Z)', distribution_name) # noqa if distribution_ver is None: print distribution_name + " is not a valid distribution version." \ " (Must contain version in the form: " \ "\"<#>.<#>.<#>-<name>\" or \"<#>.<#>." \ "<#>-<name>-SR<#>\" or \"<#>.<#>.<#>" \ "-<name>\", e.g. 0.2.0-SNAPSHOT)" # noqa sys.exit(1) distribution_ver = distribution_ver.group() # Render all the templates renderer = TemplateRenderer(self.template) akka_conf = renderer.render( "akka.conf.template", "akka.conf", { "HOST": self.host, "MEMBER_NAME": "member-" + str(self.member_no), "DS_SEED_NODES": array_str(self.ds_seed_nodes), "RPC_SEED_NODES": array_str(self.rpc_seed_nodes) }) module_shards_conf = renderer.render("module-shards.conf.template", "module-shards.conf", self.replicas) modules_conf = renderer.render("modules.conf.template", "modules.conf") features_cfg = \ renderer.render("org.apache.karaf.features.cfg.template", "org.apache.karaf.features.cfg", {"ODL_DISTRIBUTION": distribution_ver}) jolokia_xml = renderer.render("jolokia.xml.template", "jolokia.xml") management_cfg = \ renderer.render("org.apache.karaf.management.cfg.template", "org.apache.karaf.management.cfg", {"HOST": self.host}) datastore_cfg = \ renderer.render( "org.opendaylight.controller.cluster.datastore.cfg.template", "org.opendaylight.controller.cluster.datastore.cfg") # Delete all the sub-directories under the deploy directory if # the --clean flag is used if self.clean is True: self.remote.exec_cmd("rm -rf " + self.rootdir + "/deploy/*") # Create the deployment directory self.remote.mkdir(self.dir_name) # Clean the m2 repository self.remote.exec_cmd("rm -rf " + self.rootdir + "/.m2/repository") # Copy the distribution to the host and unzip it odl_file_path = self.dir_name + "/odl.zip" self.remote.copy_file(self.distribution, odl_file_path) self.remote.exec_cmd("unzip " + odl_file_path + " -d " + self.dir_name + "/") # Rename the distribution directory to odl self.remote.exec_cmd("mv " + self.dir_name + "/" + distribution_name + " " + self.dir_name + "/odl") # Copy all the generated files to the server self.remote.mkdir(self.dir_name + "/odl/configuration/initial") self.remote.copy_file(akka_conf, self.dir_name + "/odl/configuration/initial/") self.remote.copy_file(module_shards_conf, self.dir_name + "/odl/configuration/initial/") self.remote.copy_file(modules_conf, self.dir_name + "/odl/configuration/initial/") self.remote.copy_file(features_cfg, self.dir_name + "/odl/etc/") self.remote.copy_file(jolokia_xml, self.dir_name + "/odl/deploy/") self.remote.copy_file(management_cfg, self.dir_name + "/odl/etc/") if datastore_cfg is not None: self.remote.copy_file(datastore_cfg, self.dir_name + "/odl/etc/") # Add symlink self.remote.exec_cmd("ln -sfn " + self.dir_name + " " + args.rootdir + "/deploy/current") # Run karaf self.remote.start_controller(self.dir_name)
def deploy(self): # Determine distribution version distribution_name = os.path.splitext(os.path.basename(self.distribution))[0] distribution_ver = re.search('(\d)\.(\d)\.(\d)-(\w)+', distribution_name) if distribution_ver is None: print distribution_name + " is not a valid distribution version. (Must contain version in the form: \"<#>.<#>.<#>-<name>\", e.g. 0.2.0-SNAPSHOT)" sys.exit(1) distribution_ver = distribution_ver.group() # Render all the templates renderer = TemplateRenderer(self.template) akka_conf = renderer.render("akka.conf.template", "akka.conf", { "HOST" : self.host, "MEMBER_NAME" : "member-" + str(self.member_no), "DS_SEED_NODES" : array_str(self.ds_seed_nodes), "RPC_SEED_NODES" : array_str(self.rpc_seed_nodes) } ) module_shards_conf = renderer.render("module-shards.conf.template", "module-shards.conf", self.replicas) modules_conf = renderer.render("modules.conf.template", "modules.conf") features_cfg = renderer.render("org.apache.karaf.features.cfg.template", "org.apache.karaf.features.cfg", {"ODL_DISTRIBUTION" : distribution_ver}) jolokia_xml = renderer.render("jolokia.xml.template", "jolokia.xml") management_cfg = renderer.render("org.apache.karaf.management.cfg.template", "org.apache.karaf.management.cfg", {"HOST" : self.host}) # Connect to the remote host and start doing operations remote = RemoteHost(self.host, self.user, self.password, self.rootdir) remote.mkdir(self.dir_name) # Delete all the sub-directories under the deploy directory if the --clean flag is used if(self.clean == True): remote.exec_cmd("rm -rf " + self.rootdir + "/deploy/*") # Clean the m2 repository remote.exec_cmd("rm -rf " + self.rootdir + "/.m2/repository") # Kill the controller if it's running remote.kill_controller() # Copy the distribution to the host and unzip it odl_file_path = self.dir_name + "/odl.zip" remote.copy_file(self.distribution, odl_file_path) remote.exec_cmd("unzip " + odl_file_path + " -d " + self.dir_name + "/") # Rename the distribution directory to odl remote.exec_cmd("mv " + self.dir_name + "/" + distribution_name + " " + self.dir_name + "/odl") # Copy all the generated files to the server remote.mkdir(self.dir_name + "/odl/configuration/initial") remote.copy_file(akka_conf, self.dir_name + "/odl/configuration/initial/") remote.copy_file(module_shards_conf, self.dir_name + "/odl/configuration/initial/") remote.copy_file(modules_conf, self.dir_name + "/odl/configuration/initial/") remote.copy_file(features_cfg, self.dir_name + "/odl/etc/") remote.copy_file(jolokia_xml, self.dir_name + "/odl/deploy/") remote.copy_file(management_cfg, self.dir_name + "/odl/etc/") # Add symlink remote.exec_cmd("ln -sfn " + self.dir_name + " " + args.rootdir + "/deploy/current") # Run karaf remote.start_controller(self.dir_name)