示例#1
0
from cinp.orm_django import DjangoCInP as CInP

from contractor.Site.models import Site
from contractor.Building.models import Foundation, Complex, FOUNDATION_SUBCLASS_LIST, COMPLEX_SUBCLASS_LIST
from contractor.Foreman.lib import RUNNER_MODULE_LIST
from contractor.BluePrint.models import FoundationBluePrint
from contractor.lib.config import getConfig, mergeValues

from contractor_plugins.Docker.module import start_stop, state, destroy, map_ports, unmap_ports

cinp = CInP( 'Docker', '0.1' )

FOUNDATION_SUBCLASS_LIST.append( 'dockerfoundation' )
COMPLEX_SUBCLASS_LIST.append( 'dockercomplex' )
RUNNER_MODULE_LIST.append( 'contractor_plugins.Docker.module' )


@cinp.model( property_list=( 'state', 'type' ) )
class DockerComplex( Complex ):
  @property
  def subclass( self ):
    return self

  @property
  def type( self ):
    return 'Docker'

  @property
  def connection_paramaters( self ):
    return {
示例#2
0
from django.db import models

from cinp.orm_django import DjangoCInP as CInP

from contractor.Building.models import Foundation, FOUNDATION_SUBCLASS_LIST
from contractor.Foreman.lib import RUNNER_MODULE_LIST

from contractor_plugins.VirtualBox.module import set_power, power_state, wait_for_poweroff, destroy, set_interface_macs

cinp = CInP( 'VirtualBox', '0.1' )

FOUNDATION_SUBCLASS_LIST.append( 'virtualboxfoundation' )
RUNNER_MODULE_LIST.append( 'contractor_plugins.VirtualBox.module' )


@cinp.model( property_list=( 'state', 'type', 'class_list' ) )
class VirtualBoxFoundation( Foundation ):
  virtualbox_uuid = models.CharField( max_length=36, blank=True, null=True )  # not going to do unique, there could be lots of virtualbox hosts

  @staticmethod
  def getTscriptValues( write_mode=False ):  # locator is handled seperatly
    result = super( VirtualBoxFoundation, VirtualBoxFoundation ).getTscriptValues( write_mode )

    result[ 'virtualbox_uuid' ] = ( lambda foundation: foundation.virtualbox_uuid, None )

    if write_mode is True:
      result[ 'virtualbox_uuid' ] = ( result[ 'virtualbox_uuid' ][0], lambda foundation, val: setattr( foundation, 'virtualbox_uuid', val ) )

    return result

  @staticmethod
示例#3
0
from cinp.orm_django import DjangoCInP as CInP

from contractor.Site.models import Site
from contractor.Building.models import Foundation, Complex, FOUNDATION_SUBCLASS_LIST, COMPLEX_SUBCLASS_LIST
from contractor.Foreman.lib import RUNNER_MODULE_LIST
from contractor.BluePrint.models import FoundationBluePrint
from contractor.lib.config import getConfig, mergeValues

from contractor_plugins.Azure.module import set_power, power_state, destroy

cinp = CInP('Azure', '0.1')

FOUNDATION_SUBCLASS_LIST.append('azurefoundation')
COMPLEX_SUBCLASS_LIST.append('azurecomplex')
RUNNER_MODULE_LIST.append('contractor_plugins.Azure.module')

uuid_regex = re.compile(
    '^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
resource_group_regex = re.compile(
    '^[-\w\._\(\)]+$'
)  # from https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/createorupdate


@cinp.model(property_list=('state', 'type'))
class AzureComplex(Complex):
    azure_subscription_id = models.CharField(max_length=36)
    azure_location = models.CharField(max_length=20)
    azure_resource_group = models.CharField(max_length=90)  # case insensitive
    azure_client_id = models.CharField(max_length=36,
                                       help_text='also called App Id')
示例#4
0
from django.db import models

from cinp.orm_django import DjangoCInP as CInP

from contractor.Building.models import Foundation, FOUNDATION_SUBCLASS_LIST
from contractor.Foreman.lib import RUNNER_MODULE_LIST

from contractor_plugins.VirtualBox.module import set_power, power_state, wait_for_poweroff, destroy, set_interface_macs

cinp = CInP('VirtualBox', '0.1')

FOUNDATION_SUBCLASS_LIST.append('virtualboxfoundation')
RUNNER_MODULE_LIST.append('contractor_plugins.VirtualBox.module')


@cinp.model(property_list=('state', 'type', 'class_list'))
class VirtualBoxFoundation(Foundation):
    virtualbox_uuid = models.CharField(
        max_length=36, blank=True, null=True
    )  # not going to do unique, there could be lots of virtualbox hosts

    @staticmethod
    def getTscriptValues(write_mode=False):  # locator is handled seperatly
        result = super(VirtualBoxFoundation,
                       VirtualBoxFoundation).getTscriptValues(write_mode)

        result['virtualbox_uuid'] = (
            lambda foundation: foundation.virtualbox_uuid, None)

        if write_mode is True:
            result['virtualbox_uuid'] = (
示例#5
0
from django.db import models

from cinp.orm_django import DjangoCInP as CInP

from contractor.Building.models import Foundation, FOUNDATION_SUBCLASS_LIST
from contractor.Foreman.lib import RUNNER_MODULE_LIST

from contractor_plugins.AWS.module import set_power, power_state, destroy, set_interface_macs, set_ip_addresses

cinp = CInP( 'AWS', '0.1' )

FOUNDATION_SUBCLASS_LIST.append( 'awsec2foundation' )
RUNNER_MODULE_LIST.append( 'contractor_plugins.AWS.module' )


@cinp.model( property_list=( 'state', 'type', 'class_list' ) )
class AWSEC2Foundation( Foundation ):
  awsec2_instance_id = models.CharField( max_length=36, blank=True, null=True )  # not going to do unique, there could be multiple AWS accounts

  @staticmethod
  def getTscriptValues( write_mode=False ):  # locator is handled seperatly
    result = super( AWSEC2Foundation, AWSEC2Foundation ).getTscriptValues( write_mode )

    result[ 'awsec2_instance_id' ] = ( lambda foundation: foundation.awsec2_instance_id, None )

    if write_mode is True:
      result[ 'awsec2_instance_id' ] = ( result[ 'awsec2_instance_id' ][0], lambda foundation, val: setattr( foundation, 'awsec2_instance_id', val ) )

    return result

  @staticmethod
示例#6
0
from cinp.orm_django import DjangoCInP as CInP

from contractor.Site.models import Site
from contractor.Building.models import Foundation, Complex, FOUNDATION_SUBCLASS_LIST, COMPLEX_SUBCLASS_LIST
from contractor.Foreman.lib import RUNNER_MODULE_LIST
from contractor.BluePrint.models import FoundationBluePrint
from contractor.lib.config import getConfig, mergeValues

from contractor_plugins.Proxmox.module import set_power, power_state, wait_for_poweroff, destroy, get_interface_map, set_interface_macs

cinp = CInP('Proxmox', '0.1')

FOUNDATION_SUBCLASS_LIST.append('proxmoxfoundation')
COMPLEX_SUBCLASS_LIST.append('proxmoxcomplex')
RUNNER_MODULE_LIST.append('contractor_plugins.Proxmox.module')


@cinp.model(property_list=('state', 'type'))
class ProxmoxComplex(
        Complex
):  # NOTE: will use the first member as the Host to send API requests to
    proxmox_username = models.CharField(max_length=50)
    proxmox_password = models.CharField(max_length=50)

    @property
    def subclass(self):
        return self

    @property
    def type(self):
示例#7
0
from contractor.Foreman.lib import RUNNER_MODULE_LIST

RUNNER_MODULE_LIST.append('contractor_plugins.IPUtils.module')
示例#8
0
from django.core.exceptions import ValidationError

from cinp.orm_django import DjangoCInP as CInP

from contractor.Building.models import Foundation, Complex, Structure, FOUNDATION_SUBCLASS_LIST, COMPLEX_SUBCLASS_LIST, FoundationNetworkInterface
from contractor.Foreman.lib import RUNNER_MODULE_LIST
from contractor.Utilities.models import RealNetworkInterface
from contractor.BluePrint.models import FoundationBluePrint

from contractor_plugins.Vcenter.module import set_power, power_state, wait_for_poweroff, destroy, get_interface_map, set_interface_macs

cinp = CInP( 'Vcenter', '0.1' )

FOUNDATION_SUBCLASS_LIST.append( 'vcenterfoundation' )
COMPLEX_SUBCLASS_LIST.append( 'vcentercomplex' )
RUNNER_MODULE_LIST.append( 'contractor_plugins.Vcenter.module' )

datacenter_name_regex = re.compile( '^[a-zA-Z0-9][a-zA-Z0-9_\-]*$' )
cluster_name_regex = re.compile( '^[a-zA-Z0-9][a-zA-Z0-9_\-\.]*$' )


@cinp.model( property_list=( 'state', 'type' ) )
class VcenterComplex( Complex ):
  vcenter_host = models.ForeignKey( Structure, help_text='set to VCenter or the ESX host, if ESX host, leave members empty' )  # no need for unique, the same vcenter_host can be used for multiple clusters
  vcenter_username = models.CharField( max_length=50 )
  vcenter_password = models.CharField( max_length=50 )
  vcenter_datacenter = models.CharField( max_length=50, help_text='set to "ha-datacenter" for ESX hosts' )
  vcenter_cluster = models.CharField( max_length=50, blank=True, null=True )

  @property
  def subclass( self ):