Exemplo n.º 1
0
    def _cp_template(self, template_name, dest_path, params):
        f = open(utils.abspath("virt/dodai/" + template_name + ".template"), "r")
        content = f.read()
        f.close()

        path = os.path.dirname(dest_path)
        if not os.path.exists(path):
           os.makedirs(path) 

        for key, value in params.iteritems():
            content = content.replace(key, str(value))

        f = open(dest_path, "w")
        f.write(content) 
        f.close 
Exemplo n.º 2
0
    def _cp_template(self, template_name, dest_path, params):
        f = open(utils.abspath("virt/dodai/" + template_name + ".template"),
                 "r")
        content = f.read()
        f.close()

        path = os.path.dirname(dest_path)
        if not os.path.exists(path):
            os.makedirs(path)

        for key, value in params.iteritems():
            content = content.replace(key, str(value))

        f = open(dest_path, "w")
        f.write(content)
        f.close
Exemplo n.º 3
0
import signal

from Cheetah import Template

from nova import context
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova.openstack.common import cfg
from nova import utils


xvp_opts = [
    cfg.StrOpt('console_xvp_conf_template',
               default=utils.abspath('console/xvp.conf.template'),
               help='XVP conf template'),
    cfg.StrOpt('console_xvp_conf',
               default='/etc/xvp.conf',
               help='generated XVP conf file'),
    cfg.StrOpt('console_xvp_pid',
               default='/var/run/xvp.pid',
               help='XVP master process pid file'),
    cfg.StrOpt('console_xvp_log',
               default='/var/log/xvp.log',
               help='XVP log file'),
    cfg.IntOpt('console_xvp_multiplex_port',
               default=5900,
               help='port for XVP to multiplex VNC connections on'),
    ]
Exemplo n.º 4
0
flags.DEFINE_list('allowed_roles',
                  ['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'],
                  'Allowed roles for project')
# NOTE(vish): a user with one of these roles will be a superuser and
#             have access to all api commands
flags.DEFINE_list('superuser_roles', ['cloudadmin'],
                  'Roles that ignore authorization checking completely')

# NOTE(vish): a user with one of these roles will have it for every
#             project, even if he or she is not a member of the project
flags.DEFINE_list('global_roles', ['cloudadmin', 'itsec'],
                  'Roles that apply to all projects')

flags.DEFINE_string('credentials_template',
                    utils.abspath('auth/novarc.template'),
                    'Template for creating users rc file')
flags.DEFINE_string('vpn_client_template',
                    utils.abspath('cloudpipe/client.ovpn.template'),
                    'Template for creating users vpn file')
flags.DEFINE_string('credential_vpn_file', 'nova-vpn.conf',
                    'Filename of certificate in credentials zip')
flags.DEFINE_string('credential_key_file', 'pk.pem',
                    'Filename of private key in credentials zip')
flags.DEFINE_string('credential_cert_file', 'cert.pem',
                    'Filename of certificate in credentials zip')
flags.DEFINE_string('credential_rc_file', '%src',
                    'Filename of rc in credentials zip, %s will be '
                    'replaced by name of the region (nova by default)')
flags.DEFINE_string('auth_driver', 'nova.auth.dbdriver.DbDriver',
                    'Driver that auth manager uses')
Exemplo n.º 5
0
from exception import *
from node import GenericNode, Node
from nova import utils
from nova.utils import runthis
from nova.utils import execute

from nova import flags
import anyjson
import IPy
from IPy import IP
from twisted.internet import defer
from nova.auth.users import UserManager

FLAGS = flags.FLAGS
flags.DEFINE_string('net_libvirt_xml_template',
                    utils.abspath('compute/net.libvirt.xml.template'),
                    'Template file for libvirt networks')
flags.DEFINE_string('networks_path', utils.abspath('../networks'),
                    'Location to keep network config files')
flags.DEFINE_integer('public_vlan', 2000,
                     'VLAN for public IP addresses')  # FAKE!!!
flags.DEFINE_string('bridge_dev', 'eth2', 'network device for bridges')
flags.DEFINE_integer('vlan_start', 2020, 'First VLAN for private networks')
flags.DEFINE_integer('vlan_end', 2039, 'Last VLAN for private networks')
flags.DEFINE_integer('network_size', 256,
                     'Number of addresses in each private subnet')
flags.DEFINE_string('public_interface', 'vlan124',
                    'Interface for public IP addresses')
flags.DEFINE_string('public_range', '198.10.124.128-198.10.124.191',
                    'Public IP address block')
flags.DEFINE_string('private_range', '10.128.0.0/12',
Exemplo n.º 6
0
FLAGS = flags.FLAGS

flags.DEFINE_string('ldap_url', 'ldap://localhost',
                    'Point this at your ldap server')
flags.DEFINE_string('ldap_password', 'changeme', 'LDAP password')
flags.DEFINE_string('user_dn', 'cn=Manager,dc=example,dc=com',
                    'DN of admin user')
flags.DEFINE_string('user_unit', 'Users', 'OID for Users')
flags.DEFINE_string('user_ldap_subtree', 'ou=Users,dc=example,dc=com',
                    'OU for Users')
flags.DEFINE_string('project_ldap_subtree', 'ou=Groups,dc=example,dc=com',
                    'OU for Projects')

flags.DEFINE_string('credentials_template',
                    utils.abspath('auth/novarc.template'),
                    'Template for creating users rc file')
flags.DEFINE_string('credential_key_file', 'pk.pem',
                    'Filename of private key in credentials zip')
flags.DEFINE_string('credential_cert_file', 'cert.pem',
                    'Filename of certificate in credentials zip')
flags.DEFINE_string('credential_rc_file', 'novarc',
                    'Filename of rc in credentials zip')


class AuthBase(object):
    @classmethod
    def safe_id(cls, obj):
        """this method will return the id of the object if the object is of this class, otherwise
        it will return the original object.  This allows methods to accept objects or
        ids as paramaters"""
Exemplo n.º 7
0
import logging
import os
import tempfile
import zipfile

from nova import exception
from nova import flags
from nova import utils
from nova.auth import manager
from nova.endpoint import api


FLAGS = flags.FLAGS

flags.DEFINE_string('boot_script_template',
                    utils.abspath('cloudpipe/bootscript.sh'),
                    'Template for script to run on cloudpipe instance boot')

class CloudPipe(object):
    def __init__(self, cloud_controller):
        self.controller = cloud_controller
        self.manager = manager.AuthManager()

    def launch_vpn_instance(self, project_id):
        logging.debug( "Launching VPN for %s" % (project_id))
        project = self.manager.get_project(project_id)
        # Make a payload.zip
        tmpfolder = tempfile.mkdtemp()
        filename = "payload.zip"
        zippath = os.path.join(tmpfolder, filename)
        z = zipfile.ZipFile(zippath, "w", zipfile.ZIP_DEFLATED)
Exemplo n.º 8
0
Simple object store using Blobs and JSON files on disk.
"""

import datetime
import glob
import json
import os
import bisect

from nova import exception
from nova import flags
from nova import utils
from nova.objectstore import stored

FLAGS = flags.FLAGS
flags.DEFINE_string('buckets_path', utils.abspath('../buckets'),
                    'path to s3 buckets')


class Bucket(object):
    def __init__(self, name):
        self.name = name
        self.path = os.path.abspath(os.path.join(FLAGS.buckets_path, name))
        if not self.path.startswith(os.path.abspath(FLAGS.buckets_path)) or \
           not os.path.isdir(self.path):
            raise exception.NotFound()

        self.ctime = os.path.getctime(self.path)

    def __repr__(self):
        return "<Bucket: %s>" % self.name
Exemplo n.º 9
0
import json
import logging
import os
import sqlite3
import time

from nova import vendor
import redis

from nova import flags
from nova import utils


FLAGS = flags.FLAGS
flags.DEFINE_string('datastore_path', utils.abspath('../keeper'),
                    'where keys are stored on disk')
flags.DEFINE_string('redis_host', '127.0.0.1',
                    'Host that redis is running on.')
flags.DEFINE_integer('redis_port', 6379,
                    'Port that redis is running on.')
flags.DEFINE_integer('redis_db', 0, 'Multiple DB keeps tests away')
flags.DEFINE_string('keeper_backend', 'redis',
                    'which backend to use for keeper')


class Redis(object):
    def __init__(self):
        if hasattr(self.__class__, '_instance'):
            raise Exception('Attempted to instantiate singleton')
Exemplo n.º 10
0
Arquivo: image.py Projeto: sorenh/cc
import glob
import json
import os
import shutil
import tarfile
import tempfile
from xml.etree import ElementTree

from nova import exception
from nova import flags
from nova import utils
from nova.objectstore import bucket


FLAGS = flags.FLAGS
flags.DEFINE_string('images_path', utils.abspath('../images'),
                        'path to decrypted images')

class Image(object):
    def __init__(self, image_id):
        self.image_id = image_id
        self.path = os.path.abspath(os.path.join(FLAGS.images_path, image_id))
        if not self.path.startswith(os.path.abspath(FLAGS.images_path)) or \
           not os.path.isdir(self.path):
             raise exception.NotFound

    @property
    def image_path(self):
        return os.path.join(self.path, 'image')

    def delete(self):
Exemplo n.º 11
0
import IPy
import logging
import os
import time

from nova import datastore
from nova import exception
from nova import flags
from nova import utils
from nova.auth import manager
from nova.compute import exception as compute_exception
from nova.compute import linux_net


FLAGS = flags.FLAGS
flags.DEFINE_string('networks_path', utils.abspath('../networks'),
                    'Location to keep network config files')
flags.DEFINE_integer('public_vlan', 1, 'VLAN for public IP addresses')
flags.DEFINE_string('public_interface', 'vlan1',
                        'Interface for public IP addresses')
flags.DEFINE_string('bridge_dev', 'eth1',
                        'network device for bridges')
flags.DEFINE_integer('vlan_start', 100, 'First VLAN for private networks')
flags.DEFINE_integer('vlan_end', 4093, 'Last VLAN for private networks')
flags.DEFINE_integer('network_size', 256,
                        'Number of addresses in each private subnet')
flags.DEFINE_string('public_range', '4.4.4.0/24', 'Public IP address block')
flags.DEFINE_string('private_range', '10.0.0.0/8', 'Private IP address block')
flags.DEFINE_integer('cnt_vpn_clients', 5,
                        'Number of addresses reserved for vpn clients')
flags.DEFINE_integer('cloudpipe_start_port', 12000,
Exemplo n.º 12
0
from nova.auth import manager
from nova.network import linux_net
from nova.compute import power_state
from nova.compute import instance_types
from nova.exception import ProcessExecutionError
from nova.virt import disk
from nova.virt import images
from nova.virt import driver

FLAGS = flags.FLAGS
flags.DEFINE_string("ovz_template_path", "/var/lib/vz/template/cache", "Path to use for local storage of OVz templates")
flags.DEFINE_string("ovz_ve_private_dir", "/var/lib/vz/private", "Path where VEs will get placed")
flags.DEFINE_string("ovz_image_template_dir", "/var/lib/vz/template/cache", "Path where OpenVZ images are")
flags.DEFINE_string("ovz_bridge_device", "br100", "Bridge device to map veth devices to")
flags.DEFINE_string(
    "ovz_network_template", utils.abspath("virt/openvz_interfaces.template"), "OpenVz network interface template file"
)

LOG = logging.getLogger("nova.virt.openvz")


def get_connection(read_only):
    return OpenVzConnection(read_only)


class OpenVzConnection(driver.ComputeDriver):
    def __init__(self, read_only):
        self.read_only = read_only

    @classmethod
    def instance(cls):
Exemplo n.º 13
0
import nova.contrib
from gflags import *
from nova.utils import abspath

if not FLAGS.has_key('s3_port'):
    DEFINE_integer('s3_port', 3333, 's3 port')
    DEFINE_integer('s3_internal_port', 3334, 's3 port')
    DEFINE_string('s3_host', '172.24.226.1', 's3 host')
    DEFINE_string('buckets_path', abspath('../buckets'), 'path to s3 buckets')
    DEFINE_string('images_path', abspath('../images'),
                  'path to decrypted images')
Exemplo n.º 14
0
# TODO(termie): clean up these imports
from nova import vendor
import IPy

from nova import datastore
import nova.exception
from nova.compute import exception
from nova import flags
from nova import utils
from nova.auth import users

import linux_net

FLAGS = flags.FLAGS
flags.DEFINE_string('networks_path', utils.abspath('../networks'),
                    'Location to keep network config files')
flags.DEFINE_integer('public_vlan', 1, 'VLAN for public IP addresses')
flags.DEFINE_string('public_interface', 'vlan1',
                    'Interface for public IP addresses')
flags.DEFINE_string('bridge_dev', 'eth1', 'network device for bridges')
flags.DEFINE_integer('vlan_start', 100, 'First VLAN for private networks')
flags.DEFINE_integer('vlan_end', 4093, 'Last VLAN for private networks')
flags.DEFINE_integer('network_size', 256,
                     'Number of addresses in each private subnet')
flags.DEFINE_string('public_range', '4.4.4.0/24', 'Public IP address block')
flags.DEFINE_string('private_range', '10.0.0.0/8', 'Private IP address block')

logging.getLogger().setLevel(logging.DEBUG)

Exemplo n.º 15
0
import nova.contrib
from gflags import *
from nova.utils import abspath

if not FLAGS.has_key('s3_port'):
    DEFINE_integer('s3_port', 3333, 's3 port')
    DEFINE_integer('s3_internal_port', 3334, 's3 port')
    DEFINE_string('s3_host', '172.24.226.1', 's3 host')
    DEFINE_string('buckets_path', abspath('../buckets'), 'path to s3 buckets')
    DEFINE_string('images_path', abspath('../images'), 'path to decrypted images')
Exemplo n.º 16
0
from exception import *
from node import GenericNode, Node
from nova import utils
from nova.utils import runthis
from nova.utils import execute

from nova import flags
import anyjson
import IPy
from IPy import IP
from twisted.internet import defer
from nova.auth.users import UserManager

FLAGS = flags.FLAGS
flags.DEFINE_string('net_libvirt_xml_template',
                    utils.abspath('compute/net.libvirt.xml.template'),
                    'Template file for libvirt networks')
flags.DEFINE_string('networks_path', utils.abspath('../networks'),
                    'Location to keep network config files')
flags.DEFINE_integer('public_vlan', 2000, 'VLAN for public IP addresses') # FAKE!!! 
flags.DEFINE_string('bridge_dev', 'eth2',
                        'network device for bridges')
flags.DEFINE_integer('vlan_start', 2020, 'First VLAN for private networks')
flags.DEFINE_integer('vlan_end', 2039, 'Last VLAN for private networks')
flags.DEFINE_integer('network_size', 256, 'Number of addresses in each private subnet') 
flags.DEFINE_string('public_interface', 'vlan124', 'Interface for public IP addresses')
flags.DEFINE_string('public_range', '198.10.124.128-198.10.124.191', 'Public IP address block')
flags.DEFINE_string('private_range', '10.128.0.0/12', 'Private IP address block')
flags.DEFINE_string('cloudpipe_ami', 'ami-A7370FE3', 'CloudPipe image')
flags.DEFINE_integer('cloudpipe_start_port', 8000, 'Starting port for mapped CloudPipe external ports')
Exemplo n.º 17
0
Arquivo: network.py Projeto: jxta/cc
# TODO(termie): clean up these imports
from nova import vendor
import IPy

from nova import datastore
import nova.exception
from nova.compute import exception
from nova import flags
from nova import utils
from nova.auth import users

import linux_net

FLAGS = flags.FLAGS
flags.DEFINE_string('networks_path', utils.abspath('../networks'),
                    'Location to keep network config files')
flags.DEFINE_integer('public_vlan', 1, 'VLAN for public IP addresses')
flags.DEFINE_string('public_interface', 'vlan1',
                        'Interface for public IP addresses')
flags.DEFINE_string('bridge_dev', 'eth1',
                        'network device for bridges')
flags.DEFINE_integer('vlan_start', 100, 'First VLAN for private networks')
flags.DEFINE_integer('vlan_end', 4093, 'Last VLAN for private networks')
flags.DEFINE_integer('network_size', 256,
                        'Number of addresses in each private subnet')
flags.DEFINE_string('public_range', '4.4.4.0/24', 'Public IP address block')
flags.DEFINE_string('private_range', '10.0.0.0/8', 'Private IP address block')

logging.getLogger().setLevel(logging.DEBUG)
Exemplo n.º 18
0
auth_opts = [
    cfg.BoolOpt("use_deprecated_auth", default=False, help="This flag must be set to use old style auth"),
    cfg.ListOpt(
        "allowed_roles",
        default=["cloudadmin", "itsec", "sysadmin", "netadmin", "developer"],
        help="Allowed roles for project",
    ),
    # NOTE(vish): a user with one of these roles will be a superuser and
    #             have access to all api commands
    cfg.ListOpt("superuser_roles", default=["cloudadmin"], help="Roles that ignore authorization checking completely"),
    # NOTE(vish): a user with one of these roles will have it for every
    #             project, even if he or she is not a member of the project
    cfg.ListOpt("global_roles", default=["cloudadmin", "itsec"], help="Roles that apply to all projects"),
    cfg.StrOpt(
        "credentials_template",
        default=utils.abspath("auth/novarc.template"),
        help="Template for creating users rc file",
    ),
    cfg.StrOpt(
        "vpn_client_template",
        default=utils.abspath("cloudpipe/client.ovpn.template"),
        help="Template for creating users vpn file",
    ),
    cfg.StrOpt("credential_vpn_file", default="nova-vpn.conf", help="Filename of certificate in credentials zip"),
    cfg.StrOpt("credential_key_file", default="pk.pem", help="Filename of private key in credentials zip"),
    cfg.StrOpt("credential_cert_file", default="cert.pem", help="Filename of certificate in credentials zip"),
    cfg.StrOpt(
        "credential_rc_file",
        default="%src",
        help="Filename of rc in credentials zip %s will be replaced by " "name of the region (nova by default)",
    ),
Exemplo n.º 19
0
import binascii
import glob
import json
import os
import shutil
import tarfile
import tempfile
from xml.etree import ElementTree

from nova import exception
from nova import flags
from nova import utils
from nova.objectstore import bucket

FLAGS = flags.FLAGS
flags.DEFINE_string('images_path', utils.abspath('../images'),
                    'path to decrypted images')


class Image(object):
    def __init__(self, image_id):
        self.image_id = image_id
        self.path = os.path.abspath(os.path.join(FLAGS.images_path, image_id))
        if not self.path.startswith(os.path.abspath(FLAGS.images_path)) or \
           not os.path.isdir(self.path):
            raise exception.NotFound

    @property
    def image_path(self):
        return os.path.join(self.path, 'image')
Exemplo n.º 20
0
import os
import signal
import subprocess

from Cheetah import Template

from nova import context
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils

FLAGS = flags.FLAGS
flags.DEFINE_string('console_xvp_conf_template',
                    utils.abspath('console/xvp.conf.template'),
                    'XVP conf template')
flags.DEFINE_string('console_xvp_conf', '/etc/xvp.conf',
                    'generated XVP conf file')
flags.DEFINE_string('console_xvp_pid', '/var/run/xvp.pid',
                    'XVP master process pid file')
flags.DEFINE_string('console_xvp_log', '/var/log/xvp.log', 'XVP log file')
flags.DEFINE_integer('console_xvp_multiplex_port', 5900,
                     'port for XVP to multiplex VNC connections on')


class XVPConsoleProxy(object):
    """Sets up XVP config, and manages XVP daemon."""
    def __init__(self):
        self.xvpconf_template = open(FLAGS.console_xvp_conf_template).read()
        self.host = FLAGS.host  # default, set by manager.
Exemplo n.º 21
0
import time

from nova import context
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils


LOG = logging.getLogger("nova.compute.disk")
FLAGS = flags.FLAGS
flags.DEFINE_integer("minimum_root_size", 1024 * 1024 * 1024 * 10, "minimum size in bytes of root partition")
flags.DEFINE_integer("block_size", 1024 * 1024 * 256, "block_size to use for dd")
flags.DEFINE_string(
    "injected_network_template", utils.abspath("virt/interfaces.template"), "Template file for injected network"
)
flags.DEFINE_integer("timeout_nbd", 10, "time to wait for a NBD device coming up")
flags.DEFINE_integer("max_nbd_devices", 16, "maximum number of possible nbd devices")


def extend(image, size):
    """Increase image to size"""
    file_size = os.path.getsize(image)
    if file_size >= size:
        return
    utils.execute("truncate", "-s", size, image)
    # NOTE(vish): attempts to resize filesystem
    utils.execute("e2fsck", "-fp", image, check_exit_code=False)
    utils.execute("resize2fs", image, check_exit_code=False)
Exemplo n.º 22
0
from nova import context
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils

LOG = logging.getLogger('nova.compute.disk')
FLAGS = flags.FLAGS
flags.DEFINE_integer('minimum_root_size', 1024 * 1024 * 1024 * 10,
                     'minimum size in bytes of root partition')
flags.DEFINE_integer('block_size', 1024 * 1024 * 256,
                     'block_size to use for dd')
flags.DEFINE_string('injected_network_template',
                    utils.abspath('virt/interfaces.template'),
                    'Template file for injected network')
flags.DEFINE_integer('timeout_nbd', 10,
                     'time to wait for a NBD device coming up')
flags.DEFINE_integer('max_nbd_devices', 16,
                     'maximum number of possible nbd devices')


def extend(image, size):
    """Increase image to size"""
    file_size = os.path.getsize(image)
    if file_size >= size:
        return
    utils.execute('truncate', '-s', size, image)
    # NOTE(vish): attempts to resize filesystem
    utils.execute('e2fsck', '-fp', image, check_exit_code=False)
Exemplo n.º 23
0
Arquivo: node.py Projeto: sorenh/cc
    logging.warning('no libvirt found')

from nova import exception
from nova import fakevirt
from nova import flags
from nova import process
from nova import utils
from nova.compute import disk
from nova.compute import model
from nova.compute import network
from nova.volume import storage
from nova.objectstore import image # for image_path flag

FLAGS = flags.FLAGS
flags.DEFINE_string('libvirt_xml_template',
                        utils.abspath('compute/libvirt.xml.template'),
                        'Network XML Template')
flags.DEFINE_bool('use_s3', True,
                      'whether to get images from s3 or use local copy')
flags.DEFINE_string('instances_path', utils.abspath('../instances'),
                        'where instances are stored on disk')

INSTANCE_TYPES = {}
INSTANCE_TYPES['m1.tiny'] = {'memory_mb': 512, 'vcpus': 1, 'local_gb': 0}
INSTANCE_TYPES['m1.small'] = {'memory_mb': 1024, 'vcpus': 1, 'local_gb': 10}
INSTANCE_TYPES['m1.medium'] = {'memory_mb': 2048, 'vcpus': 2, 'local_gb': 10}
INSTANCE_TYPES['m1.large'] = {'memory_mb': 4096, 'vcpus': 4, 'local_gb': 10}
INSTANCE_TYPES['m1.xlarge'] = {'memory_mb': 8192, 'vcpus': 4, 'local_gb': 10}
INSTANCE_TYPES['c1.medium'] = {'memory_mb': 2048, 'vcpus': 4, 'local_gb': 10}

Exemplo n.º 24
0
    logging.warning('no libvirt found')

from nova import exception
from nova import fakevirt
from nova import flags
from nova import process
from nova import utils
from nova.compute import disk
from nova.compute import model
from nova.compute import network
from nova.volume import storage
from nova.objectstore import image  # for image_path flag

FLAGS = flags.FLAGS
flags.DEFINE_string('libvirt_xml_template',
                    utils.abspath('compute/libvirt.xml.template'),
                    'Network XML Template')
flags.DEFINE_bool('use_s3', True,
                  'whether to get images from s3 or use local copy')
flags.DEFINE_string('instances_path', utils.abspath('../instances'),
                    'where instances are stored on disk')

INSTANCE_TYPES = {}
INSTANCE_TYPES['m1.tiny'] = {'memory_mb': 512, 'vcpus': 1, 'local_gb': 0}
INSTANCE_TYPES['m1.small'] = {'memory_mb': 1024, 'vcpus': 1, 'local_gb': 10}
INSTANCE_TYPES['m1.medium'] = {'memory_mb': 2048, 'vcpus': 2, 'local_gb': 10}
INSTANCE_TYPES['m1.large'] = {'memory_mb': 4096, 'vcpus': 4, 'local_gb': 10}
INSTANCE_TYPES['m1.xlarge'] = {'memory_mb': 8192, 'vcpus': 4, 'local_gb': 10}
INSTANCE_TYPES['c1.medium'] = {'memory_mb': 2048, 'vcpus': 4, 'local_gb': 10}

Exemplo n.º 25
0
import logging
import os
import tempfile
import base64
from zipfile import ZipFile, ZIP_DEFLATED

from nova import exception
from nova import flags
from nova.auth import users
from nova import utils
from nova.endpoint import api

FLAGS = flags.FLAGS

flags.DEFINE_string('boot_script_template',
                    utils.abspath('cloudpipe/bootscript.sh'),
                    'Template for script to run on cloudpipe instance boot')


class CloudPipe(object):
    def __init__(self, cloud_controller):
        self.controller = cloud_controller
        self.manager = users.UserManager.instance()

    def launch_vpn_instance(self, project_id):
        logging.debug("Launching VPN for %s" % (project_id))
        project = self.manager.get_project(project_id)
        # Make a payload.zip
        tmpfolder = tempfile.mkdtemp()
        filename = "payload.zip"
        zippath = os.path.join(tmpfolder, filename)
Exemplo n.º 26
0
import tempfile
import zipfile

from nova import context
from nova import crypto
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova import utils
# TODO(eday): Eventually changes these to something not ec2-specific
from nova.api.ec2 import cloud

FLAGS = flags.FLAGS
flags.DEFINE_string('boot_script_template',
                    utils.abspath('cloudpipe/bootscript.template'),
                    _('Template for script to run on cloudpipe instance boot'))
flags.DEFINE_string('dmz_net', '10.0.0.0',
                    _('Network to push into openvpn config'))
flags.DEFINE_string('dmz_mask', '255.255.255.0',
                    _('Netmask to push into openvpn config'))

LOG = logging.getLogger('nova.cloudpipe')


class CloudPipe(object):
    def __init__(self):
        self.controller = cloud.CloudController()

    def get_encoded_zip(self, project_id):
        # Make a payload.zip
Exemplo n.º 27
0
Arquivo: bucket.py Projeto: sorenh/cc
Simple object store using Blobs and JSON files on disk.
"""

import datetime
import glob
import json
import os
import bisect

from nova import exception
from nova import flags
from nova import utils
from nova.objectstore import stored

FLAGS = flags.FLAGS
flags.DEFINE_string('buckets_path', utils.abspath('../buckets'),
                    'path to s3 buckets')

class Bucket(object):
    def __init__(self, name):
        self.name = name
        self.path = os.path.abspath(os.path.join(FLAGS.buckets_path, name))
        if not self.path.startswith(os.path.abspath(FLAGS.buckets_path)) or \
           not os.path.isdir(self.path):
            raise exception.NotFound()

        self.ctime = os.path.getctime(self.path)

    def __repr__(self):
        return "<Bucket: %s>" % self.name
Exemplo n.º 28
0
from nova import context
from nova import crypto
from nova import db
from nova import exception
from nova import flags
from nova import log as logging
from nova.openstack.common import cfg
from nova import utils
# TODO(eday): Eventually changes these to something not ec2-specific
from nova.api.ec2 import cloud
from nova.api.ec2 import ec2utils


cloudpipe_opts = [
    cfg.StrOpt('boot_script_template',
               default=utils.abspath('cloudpipe/bootscript.template'),
               help=_('Template for cloudpipe instance boot script')),
    cfg.StrOpt('dmz_net',
               default='10.0.0.0',
               help=_('Network to push into openvpn config')),
    cfg.StrOpt('dmz_mask',
               default='255.255.255.0',
               help=_('Netmask to push into openvpn config')),
    ]

FLAGS = flags.FLAGS
FLAGS.add_options(cloudpipe_opts)


LOG = logging.getLogger('nova.cloudpipe')
Exemplo n.º 29
0
Arquivo: pipelib.py Projeto: sorenh/cc
import os
import tempfile
import base64
from zipfile import ZipFile, ZIP_DEFLATED

from nova import exception
from nova import flags
from nova.auth import users
from nova import utils
from nova.endpoint import api

FLAGS = flags.FLAGS

flags.DEFINE_string(
    "boot_script_template",
    utils.abspath("cloudpipe/bootscript.sh"),
    "Template for script to run on cloudpipe instance boot",
)


class CloudPipe(object):
    def __init__(self, cloud_controller):
        self.controller = cloud_controller
        self.manager = users.UserManager.instance()

    def launch_vpn_instance(self, project_id):
        logging.debug("Launching VPN for %s" % (project_id))
        project = self.manager.get_project(project_id)
        # Make a payload.zip
        tmpfolder = tempfile.mkdtemp()
        filename = "payload.zip"
Exemplo n.º 30
0
from nova import exception
from nova import flags
from nova import log as logging
from nova.openstack.common import cfg
from nova import utils
from nova.virt.disk import guestfs
from nova.virt.disk import loop
from nova.virt.disk import nbd


LOG = logging.getLogger('nova.compute.disk')

disk_opts = [
    cfg.StrOpt('injected_network_template',
               default=utils.abspath('virt/interfaces.template'),
               help='Template file for injected network'),
    cfg.ListOpt('img_handlers',
                default=['loop', 'nbd', 'guestfs'],
                help='Order of methods used to mount disk images'),

    # NOTE(yamahata): ListOpt won't work because the command may include a
    #                 comma. For example:
    #
    #                 mkfs.ext3 -O dir_index,extent -E stride=8,stripe-width=16
    #                           --label %(fs_label)s %(target)s
    #
    #                 list arguments are comma separated and there is no way to
    #                 escape such commas.
    #
    cfg.MultiStrOpt('virt_mkfs',
Exemplo n.º 31
0
Arquivo: users.py Projeto: jxta/cc
from nova import crypto
from nova import utils

from nova import objectstore # for flags

FLAGS = flags.FLAGS

flags.DEFINE_string('ldap_url', 'ldap://localhost', 'Point this at your ldap server')
flags.DEFINE_string('ldap_password',  'changeme', 'LDAP password')
flags.DEFINE_string('user_dn', 'cn=Manager,dc=example,dc=com', 'DN of admin user')
flags.DEFINE_string('user_unit', 'Users', 'OID for Users')
flags.DEFINE_string('user_ldap_subtree', 'ou=Users,dc=example,dc=com', 'OU for Users')
flags.DEFINE_string('project_ldap_subtree', 'ou=Groups,dc=example,dc=com', 'OU for Projects')

flags.DEFINE_string('credentials_template',
                    utils.abspath('auth/novarc.template'),
                    'Template for creating users rc file')
flags.DEFINE_string('credential_key_file', 'pk.pem',
                    'Filename of private key in credentials zip')
flags.DEFINE_string('credential_cert_file', 'cert.pem',
                    'Filename of certificate in credentials zip')
flags.DEFINE_string('credential_rc_file', 'novarc',
                    'Filename of rc in credentials zip')

class AuthBase(object):
    @classmethod
    def safe_id(cls, obj):
        """this method will return the id of the object if the object is of this class, otherwise
        it will return the original object.  This allows methods to accept objects or
        ids as paramaters"""
        if isinstance(obj, cls):