Exemplo n.º 1
0
Examples :

firewall allow port XX -- allow only port XX
firewall deny port XX -- disable port XX
firewall disable -- Allow everything!
firewall enable -- Enable firewall.
firewall status -- Show status of firewall."""

if __name__ == '__main__':
    opparser = OptionParser(usage=usage)
    opparser.add_option('-s', '--server',
                        type='string',
                        help="Server List id/name to match")
    (options, args) = opparser.parse_args()    

    c = ChooseServer(CNX)
    if len(c.servers) == 0:
        print "There is no images to process."
        sys.exit(0)
    server_list = c.get_list_of_servers(options.server)
    if not server_list:
        print "No server selected"
        sys.exit(1)

    for server in server_list:
        print "Processing: %s/%s" % (server.name, server.public_ip)
        copy_exec_script(server.public_ip,
                         '%s/firewall/fw-client.sh' % (TOPDIR),
                         args)
        print
Exemplo n.º 2
0
print "Creating Image, please wait...."
cstype = CNX.servers.create(image=IMAGE_TYPE,
                            flavor=IMAGE_FLAVOUR_ID,
                            name=IMAGE_NAME,
                            files={'/root/.ssh/authorized_keys': open(os.path.expanduser("~/.ssh/id_rsa.pub"), 'r')}
                           )
check_image(CNX, cstype.id)

if options.delete_image:
    print "Deleting image of server"
    CNX.images.delete(IMAGE_TYPE)

if options.bootstrap:
    bootstrap_script = os.path.join(os.path.dirname(__file__),
                                    "..", "scripts", "bootstrap.sh")
    copy_exec_script(cstype.public_ip, bootstrap_script)

if options.script:
    copy_exec_script(cstype.public_ip, options.script)

open("/tmp/server-installed-%s.txt" % \
         (os.environ.get("USER", "none")), 'a').write(
    "%s - root@%s -- Password: %s\n" % (cstype.name,
                                        cstype.public_ip,
                                        cstype.adminPass))

if not options.script:
    print
    print
    print "ssh %s -- Password: %s" % (cstype.public_ip, cstype.adminPass)