Example #1
0
def static_network(request):
    geppetto_service = utils.get_geppetto_web_service_client()
    text = "Please specify the static network settings for the VPX for " + \
            "your public network."
    header = "Publish Service - Static Network"

    def on_form_valid(form, service, roles):
        ipaddress = form.cleaned_data["ip_address"]
        netmask = form.cleaned_data["netmask"]
        worker = request.session[SESSION_VAR_WORKER]
        overrides = {
            ConfigClassParameter.PUBLIC_NW_VIF_IP: ipaddress,
            ConfigClassParameter.PUBLIC_NW_VIF_NETMASK: netmask
        }
        service.Config.add_node_overrides(worker, overrides)
        request.session[SESSION_VAR_WORKER] = None
        return redirect('install_checklist')

    def update_form(form, service, roles):
        form.update_worker(request.session[SESSION_VAR_WORKER])

    return utils.generate_form_request_handler(
        header,
        text,
        on_form_valid=on_form_valid,
        django_form=DefineStaticNetwork,
        update_form=update_form,
        svc_proxy=geppetto_service)(request)
Example #2
0
    def on_form_valid(form, service, roles):
        geppetto_service = utils.get_geppetto_web_service_client()
        auth_token = geppetto_service.Config.get(\
                              ConfigClassParameter.KEYSTONE_SUPERUSER_TOKEN)
        requested_ostype = None
        if ('kernel' in request.session) and ('ramdisk' in request.session):
            _nova_manage_register(auth_token, request.session['label'],
                                  request.session['machine'],
                                  request.session['kernel'],
                                  request.session['ramdisk'],
                                  request.session['hypervisor'])

        else:
            if request.session['hypervisor'] == 'esx':
                requested_ostype = request.session['ostype']
            _nova_manage_register(auth_token, request.session['label'],
                                  request.session['machine'], None, None,
                                  request.session['hypervisor'],
                                  requested_ostype)
        return redirect('install_checklist')
Example #3
0
    def is_valid_interface(cleaned_data):
        iface = cleaned_data["device"]
        is_valid = True
        service = utils.get_geppetto_web_service_client()
        worker = cleaned_data["worker"]
        worker_details = service.Node.get_details([worker])
        group_overrides = worker_details.get('group_overrides', {})
        node_overrides = worker_details.get('node_overrides', {})
        # validate chosen interface (which is a public interface)
        bridge_if = node_overrides.get(
            ConfigClassParameter.BRIDGE_INTERFACE,
            group_overrides.get(
                ConfigClassParameter.BRIDGE_INTERFACE,
                service.Config.get(ConfigClassParameter.BRIDGE_INTERFACE)))
        if iface == bridge_if:
            is_valid = False
        err_msg = not is_valid and "Invalid interface. This interface is " \
                                   "already being used. Please choose " \
                                   "another interface from the list."

        return (is_valid, err_msg)
Example #4
0
def add_compute_node(request):
    text = "You need an OpenStack Compute Worker running on every " \
            "Hypervisor on which you wish to run VM instances. There "  \
            "must be only one per physical machine."
    header = "OpenStack Compute Worker"
    svc = utils.get_geppetto_web_service_client()

    def on_form_valid(form, service, roles):
        worker = form.get_clean_worker()
        copute_worker_task_id = service.Compute.add_workers([worker], {})
        request.session[COMPUTE_WORKER_TASK_ID] = copute_worker_task_id
        return redirect('install_checklist')

    def update_form(form, service, roles):
        node_fqdns = service.Node.exclude_by_roles([Role.NOVA_COMPUTE])
        node_details = service.Node.get_details(node_fqdns)
        form.add_workers_into_form(node_details)

    return utils.generate_form_request_handler(header, text,
                                           on_form_valid=on_form_valid,
                                           update_form=update_form,
                                           svc_proxy=svc)(request)
Example #5
0
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect

from geppetto.ui.forms.install import MultipleChoiceWorkerForm
from geppetto.ui.forms.install import SwiftStorageSizeForm
from geppetto.ui.forms.install import SwiftHashPathSuffixForm
from geppetto.ui.views import utils
from geppetto.core.models import Role
from geppetto.core.models import ConfigClassParameter

svc = utils.get_geppetto_web_service_client()


SWIFT_PROXY_SETUP_TASK_ID = "geppetto-swift-proxy-setup-task-id"
SWIFT_RING_SETUP_TASK_ID = "geppetto-swift-ring-setup-task-id"
SWIFT_DISK_SIZE = "geppetto-swift-disk-size"
SWIFT_HASH_PATH_SUFFIX = "geppetto-swift-hash-path-suffix"
SWIFT_STORAGE_NODE_HOSTNAMES = "geppetto-swift-storage-node-hostnames"


@login_required
def setup_swift_start(request):
    return redirect('setup_swift_hash_path_suffix')


@login_required
def setup_swift_hash_path_suffix(request):
    text = ("A suffix value should be set to some random string of text "
            "to be used as a salt when hashing to determine mappings "
            "in the swift ring. This should be the same on every node "
            "in the cluster.")
Example #6
0
def publish(request):
    geppetto_service = utils.get_geppetto_web_service_client()
    text = "Please specify which XenServer network that is attached to " + \
            "your Public Network. This will be connected to device 2 of " + \
            "the selected os-vpx instance. Ensure you choose the correct " + \
            "network type for the public network. If you select static " + \
            "networking, you will prompted for the IP Address details on " + \
            "the next screen. This interface will also be used for " + \
            "binding floating ips."
    header = "Publish Service"

    def is_valid_interface(cleaned_data):
        iface = cleaned_data["device"]
        is_valid = True
        service = utils.get_geppetto_web_service_client()
        worker = cleaned_data["worker"]
        worker_details = service.Node.get_details([worker])
        group_overrides = worker_details.get('group_overrides', {})
        node_overrides = worker_details.get('node_overrides', {})
        # validate chosen interface (which is a public interface)
        bridge_if = node_overrides.get(
            ConfigClassParameter.BRIDGE_INTERFACE,
            group_overrides.get(
                ConfigClassParameter.BRIDGE_INTERFACE,
                service.Config.get(ConfigClassParameter.BRIDGE_INTERFACE)))
        if iface == bridge_if:
            is_valid = False
        err_msg = not is_valid and "Invalid interface. This interface is " \
                                   "already being used. Please choose " \
                                   "another interface from the list."

        return (is_valid, err_msg)

    def on_form_valid(form, service, roles):
        network_type = form.cleaned_data["network_type"]
        host_network = form.cleaned_data["host_network"]
        device = form.cleaned_data["device"]
        worker = form.get_clean_worker()
        request.session[SESSION_VAR_WORKER] = worker
        overrides = {
            ConfigClassParameter.PUBLIC_NETWORK_BRIDGE: host_network,
            ConfigClassParameter.PUBLIC_INTERFACE: device,
            ConfigClassParameter.PUBLIC_NW_VIF_MODE: network_type
        }
        service.Config.add_node_overrides(worker, overrides)
        redirect_to = (network_type == 'dhcp') and 'install_checklist' \
                       or 'publish_service_static_network'
        return redirect(redirect_to)

    def update_form(form, service, roles):
        form.validation_callback = is_valid_interface
        # Don't allow empty IP configuration as it won't make any sense
        form.update_choices((("dhcp", "DHCP"), ("static", "Static")),
                            initial='dhcp')
        form.set_initial_device(
            service.Config.get(ConfigClassParameter.PUBLIC_INTERFACE))
        form.add_workers_into_form(_get_api_nodes(service))

    return utils.generate_form_request_handler(
        header,
        text,
        on_form_valid=on_form_valid,
        django_form=PublishService,
        update_form=update_form,
        svc_proxy=geppetto_service)(request)
Example #7
0
 def on_form_valid(form, service, roles):
     worker = form.get_clean_worker()
     geppetto_service = utils.get_geppetto_web_service_client()
     identity_task_id = geppetto_service.Identity.add_auth(worker, {})
     request.session[IDENTITY_TASK_ID] = identity_task_id
     return redirect('install_checklist')
Example #8
0
def _make_request(request, form, task_id, f):
    service = utils.get_geppetto_web_service_client()
    worker = form.get_clean_worker()
    request.session[task_id] = f(service, worker)
Example #9
0
 def __init__(self):
     self.svc = ui_utils.get_geppetto_web_service_client()