Skip to main content

Python package to manage hypervisor/docker/kubernetes stacks

Project description

PyCloudStack (Unified Cloud Stack Operator Framework)

1. Overview

PyCloudStack abstracts the common objects/operations/resources for diverse cloud architectures like hypervisor stack based on libvirt or direct qemu command, container stack orchestrated by Kubernetes or direct docker command, and the running or remote IaaS host.

It can be used to create advance deployment CI/CD operator via python plugin for ansible, end-to-end validation framework with customized the components/configurations in full vertical stack.

The architecture diagram is as follows:

2. Getting Start

Install from PyPI

pip3 install pycloudstack

Install from source

cd ~/pycloudstack
pip3 install --user --upgrade .

3. Examples

Example 1: Operate VM via Libvirt

from pycloudstack.vmguest import VMGuestFactory
from pycloudstack.vmparam import VM_STATE_SHUTDOWN, VM_STATE_RUNNING, \
    VM_STATE_PAUSE, VM_TYPE_TD

vm_factory = VMGuestFactory(vm_image, vm_kernel)

LOG.info("Create TD guest")
inst = vm_factory.new_vm(VM_TYPE_TD, auto_start=True)
inst.wait_for_ssh_ready()

LOG.info("Suspend TD guest")
inst.suspend()
ret = inst.wait_for_state(VM_STATE_PAUSE)
assert ret, "Suspend timeout"

LOG.info("Resume TD guest")
inst.resume()
ret = inst.wait_for_state(VM_STATE_RUNNING)
assert ret, "Resume timeout"

Example 2: Operate VM via Qemu (QMP)

from gpl.vmmqmp import VMMQemu
from pycloudstack.vmparam import VM_TYPE_TD, VM_TYPE_LEGACY,

vm_factory = VMGuestFactory(vm_image, vm_kernel)
inst = vm_factory.new_vm(vm_instance_type, vm_class=VMMQemu,
                         auto_start=True)
inst.wait_for_ssh_ready()

Example 3: Operate Kubernetes Cluster

from pycloudstack.cluster import SGXCluster

DEPLOYMENT_TEMPLATE='''
apiVersion: apps/v1
kind: Deployment
metadata:
  name: %(name)s
spec:
  selector:
    matchLabels:
      app: testapp-redis-gsc-sgx
  template:
    metadata:
      labels:
        app: testapp-redis-gsc-sgx
    spec:
      containers:
      - name: redis-gsc-sgx
        image: gar-registry.caas.intel.com/cpio/gsc-centos8-redis:latest
        ports:
          - containerPort: 6379
        env:
        - name: GSC
          value: %(gsc)s
        resources:
          limits:
            sgx.intel.com/enclave: '1'
            sgx.intel.com/epc: '524288000'
'''
SERVICE_TEMPLATE='''
apiVersion: v1
kind: Service
metadata:
  name: %(name)s
spec:
  ports:
  - port: 6379
    protocol: TCP
  selector:
    app: testapp-redis-gsc-sgx
  type: NodePort
'''

cluster_instance = SGXCluster()
deploy_name = 'deployment-redis-gsc-sgx-' + str(uuid.uuid4())
cluster_instance.create_deployment(
        deploy_name,
        yaml.safe_load(DEPLOYMENT_TEMPLATE % {"name":deploy_name, "gsc":gsc}),
        TEST_NAMESPACE)

svc_name = 'svc-redis-gsc-sgx-' + str(uuid.uuid4())
cluster_instance.create_service(
        svc_name,
        yaml.safe_load(SERVICE_TEMPLATE % {"name":svc_name}),
        TEST_NAMESPACE)
cluster_instance.delete_service(svc_name, TEST_NAMESPACE)
cluster_instance.delete_deployment(deploy_name, TEST_NAMESPACE)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycloudstack-0.0.10.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

pycloudstack-0.0.10-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file pycloudstack-0.0.10.tar.gz.

File metadata

  • Download URL: pycloudstack-0.0.10.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pycloudstack-0.0.10.tar.gz
Algorithm Hash digest
SHA256 e65cef34d07807f542ad692b8caef75d75ec5571fce53fcca7126eed8d1152f3
MD5 0ca778303242f5c9c1adebd7cff7b40e
BLAKE2b-256 b9baa24a5cb8084bc5d4b8e899a706b589175a51bd855d5962b4c48f31a9f7d2

See more details on using hashes here.

File details

Details for the file pycloudstack-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for pycloudstack-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 83d04231d4b80af45e2a7f2da7ac5035c6ad4045a5d897fa9ff9841b9fae5acc
MD5 3d54668e436593334b834431f397ec71
BLAKE2b-256 910d837081547e8e6196e28a0135bb326565556d2e58809d6bc386c79af5ec5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page