Пример #1
0
from django.core.exceptions import ValidationError

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 ):
Пример #2
0
from django.db import models
from django.core.exceptions import ValidationError

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.BluePrint.models import FoundationBluePrint

from contractor_plugins.Manual.module import set_power, power_state, wait_for_poweroff

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

FOUNDATION_SUBCLASS_LIST.append('manualfoundation')
FOUNDATION_SUBCLASS_LIST.append('manualcomplexedfoundation')
COMPLEX_SUBCLASS_LIST.append('manualcomplex')


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

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

    def newFoundation(self, hostname, site):
        foundation = ManualComplexedFoundation(
            site=site,
Пример #3
0
from django.core.exceptions import ValidationError

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,
Пример #4
0
from django.db import models
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)
Пример #5
0
from django.core.exceptions import ValidationError

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.BluePrint.models import FoundationBluePrint
from contractor.lib.config import getConfig, mergeValues
from contractor.Foreman.lib import RUNNER_MODULE_LIST

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

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

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


@cinp.model(property_list=('state', 'type'))
class VirtualBoxComplex(Complex):
    """
  Complex for VirtualBox.  Only one member is allowed.  The ip address
  for managing the VirtualBox instance comes from the member's primary ip.
  """
    virtualbox_username = models.CharField(max_length=50)
    virtualbox_password = models.CharField(max_length=50)

    @property
    def subclass(self):
        return self
Пример #6
0
from django.core.exceptions import ValidationError

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
Пример #7
0
from django.db import models
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