j.system.fs.writeFile(configurepath, result) def main(args): print 'Updating Metadata' j.packages.updateMetaDataAll() jp = getJPackage(args.name, args.description) print 'Cleanup old stuff' cleanup(jp) print 'Downloading Image' imagepath = downloadImage(jp, args.url) print 'Writing configure tasklet' writeConfigure(jp, args.name, args.description, imagepath, args.type) print 'Uploading Image' jp.upload() print 'Publishing' j.packages.publishDomain(DOMAIN, 'Automated image updater') if __name__ == '__main__': j.application.start('packager') parser = ArgumentParser() parser.add_argument('-n', '--name') parser.add_argument('-d', '--description') parser.add_argument('-u', '--url') parser.add_argument('-t', '--type') parser.add_argument('-s', '--size', help='Size in GB') args = parser.parse_args() main(args) j.application.stop()
cloudspace.location, whereami) return # delete routeros fws = netmgr.fw_list(gridid, str(cloudspace.id)) if fws: netmgr.fw_delete(fws[0]['guid']) if cloudspace.networkId: libvirt_actor.releaseNetworkId(cloudspace.networkId) if cloudspace.publicipaddress: network.releasePublicIpAddress(cloudspace.publicipaddress) cloudspace.networkId = None cloudspace.publicipaddress = None cloudspace.status = 'VIRTUAL' cbcl.cloudspace.set(cloudspace) if __name__ == '__main__': portalcfgpath = j.system.fs.joinPaths(j.dirs.baseDir, 'apps', 'cloudbroker', 'cfg', 'portal') portalcfg = j.config.getConfig(portalcfgpath).get('main', {}) port = int(portalcfg.get('webserverport', 9999)) secret = portalcfg.get('secret') parser = ArgumentParser() parser.add_argument("-c", "--cloudspaceid") opts = parser.parse_args() cl = j.clients.portal.get('127.0.0.1', port, secret) cl.getActor('libcloud', 'libvirt') cl.getActor('jumpscale', 'netmgr') _release_resources(opts.cloudspaceid)
ccl.publicipv4pool.set(pool) for spaced in cloudspaces: if spaced["status"] != "DESTROYED": space = ccl.cloudspace.get(spaced["id"]) space.status = "DEPLOYED" if "/" not in space.publicipaddress and space.publicipaddress: space.publicipaddress = "%s/%s" % ( space.publicipaddress, network.prefixlen, ) ccl.cloudspace.set(space) if __name__ == "__main__": j.application.start("migrator") parser = ArgumentParser(description="Migrate Public IP addresses from hrd to osis") parser.add_argument( "-n", "--network", required=True, help="Network including cidr eg. 10.101.190.0/24", ) parser.add_argument("-g", "--gateway", required=True, help="Gatewat of network") options = parser.parse_args() network = netaddr.IPNetwork(options.network) gateway = netaddr.IPAddress(options.gateway) if gateway not in network: print "Gateway is not in network" sys.exit(1) migrate(network, gateway) j.application.stop(0)
j.system.fs.writeFile(configurepath, result) def main(args): print "Updating Metadata" j.packages.updateMetaDataAll() jp = getJPackage(args.name, args.description) print "Cleanup old stuff" cleanup(jp) print "Downloading Image" imagepath = downloadImage(jp, args.url) print "Writing configure tasklet" writeConfigure(jp, args.name, args.description, imagepath, args.type) print "Uploading Image" jp.upload() print "Publishing" j.packages.publishDomain(DOMAIN, "Automated image updater") if __name__ == "__main__": j.application.start("packager") parser = ArgumentParser() parser.add_argument("-n", "--name") parser.add_argument("-d", "--description") parser.add_argument("-u", "--url") parser.add_argument("-t", "--type") parser.add_argument("-s", "--size", help="Size in GB") args = parser.parse_args() main(args) j.application.stop()
freeipsinpool.add(freeip) pool.pubips = list(freeipsinpool) ccl.publicipv4pool.set(pool) for spaced in cloudspaces: if spaced['status'] != 'DESTROYED': space = ccl.cloudspace.get(spaced['id']) space.status = 'DEPLOYED' if '/' not in space.publicipaddress and space.publicipaddress: space.publicipaddress = '%s/%s' % (space.publicipaddress, network.prefixlen) ccl.cloudspace.set(space) if __name__ == '__main__': j.application.start('migrator') parser = ArgumentParser( description='Migrate Public IP addresses from hrd to osis') parser.add_argument('-n', '--network', required=True, help="Network including cidr eg. 10.101.190.0/24") parser.add_argument('-g', '--gateway', required=True, help="Gatewat of network") options = parser.parse_args() network = netaddr.IPNetwork(options.network) gateway = netaddr.IPAddress(options.gateway) if gateway not in network: print "Gateway is not in network" sys.exit(1) migrate(network, gateway)
#!/usr/bin/env python import sys, time from JumpScale import j from JumpScale.baselib.cmdutils import ArgumentParser def migrate(): import JumpScale.grid.osis ccl = j.clients.osis.getNamespace("cloudbroker") cloudspaces = ccl.cloudspace.simpleSearch({}) for spaced in cloudspaces: if spaced["status"] != "DESTROYED": space = ccl.cloudspace.get(spaced["id"]) space.creationTime = int(time.time()) ccl.cloudspace.set(space) if __name__ == "__main__": j.application.start("migrator") parser = ArgumentParser( description="set creation and deletiontimes of cloudspaces") options = parser.parse_args() migrate() j.application.stop(0)