Esempio n. 1
0
 def add_glance_server(self,
                       authentication_url=None,
                       certificates=None,
                       comment=None,
                       description=None,
                       id=None,
                       images=None,
                       name=None,
                       password=None,
                       properties=None,
                       requires_authentication=None,
                       tenant_name=None,
                       url=None,
                       username=None):
     self._glance_servers_service.add(
         types.OpenStackImageProvider(
             name=name,
             description=description,
             url=url,
             requires_authentication=requires_authentication,
             authentication_url=authentication_url,
             username=username,
             password=password,
             tenant_name=tenant_name,
             certificates=certificates,
             comment=comment,
             id=id,
             images=images,
             properties=properties))
     wait_for(self.does_glance_server_exist,
              func_args=[name],
              delay=5,
              num_sec=240)
Esempio n. 2
0
    def add_image(self, image, pool, short=None, cmd=None, name=None, size=1):
        """

        :param image:
        :param pool:
        :param short:
        :param cmd:
        :param name:
        :param size:
        :return:
        """
        image = os.path.basename(image)
        if image not in otemplates:
            return {'result': 'failure', 'reason': "Image not supported"}
        if image in self.volumes():
            common.pprint("Image %s already there" % image)
            return {'result': 'success'}
        system_service = self.conn.system_service()
        sds_service = system_service.storage_domains_service()
        poolcheck = sds_service.list(search='name=%s' % pool)
        if not poolcheck:
            return {'result': 'failure', 'reason': "Pool %s not found" % pool}
        sd = sds_service.list(search='name=%s' % self.imagerepository)
        common.pprint("Using %s glance repository" % self.imagerepository,
                      color='green')
        if not sd:
            common.confirm(
                "No glance repo found. Do you want public glance repo to be installed?"
            )
            providers_service = system_service.openstack_image_providers_service(
            )
            sd_service = providers_service.add(
                provider=types.OpenStackImageProvider(
                    name='ovirt-image-repository',
                    url='http://glance.ovirt.org:9292',
                    requires_authentication=False))
            common.pprint("Relaunch kcli download now", color='green')
            return {'result': 'success'}
        else:
            sd_service = sds_service.storage_domain_service(sd[0].id)
        images_service = sd_service.images_service()
        images = images_service.list()
        imageobject = next((i for i in images if i.name == otemplates[image]),
                           None)
        image_service = images_service.image_service(imageobject.id)
        image_service.import_(import_as_template=True,
                              template=types.Template(name=image),
                              cluster=types.Cluster(name=self.cluster),
                              storage_domain=types.StorageDomain(name=pool))
        return {'result': 'success'}
import logging

import ovirtsdk4 as sdk
import ovirtsdk4.types as types

logging.basicConfig(level=logging.DEBUG, filename='example.log')

# This example will connect to the server and create a new Openstack image provider:

# Create the connection to the server:
connection = sdk.Connection(
    url='https://engine40.example.com/ovirt-engine/api',
    username='******',
    password='******',
    ca_file='ca.pem',
    debug=True,
    log=logging.getLogger(),
)

# Get the reference to the "openstack_image_providers_service" service:
openstack_image_providers_service = connection.system_service(
).openstack_image_providers_service()

# Use the "add" method to create a new Openstack image provider:
openstack_image_providers_service.add(
    types.OpenStackImageProvider(name='GlanceProvider',
                                 url='http://glance.ovirt.org:9292/'), )

# Close the connection to the server:
connection.close()
Esempio n. 4
0
 def create(self, name, url, requires_authentication):
     sdk_type = types.OpenStackImageProvider(
         name=name,
         url=url,
         requires_authentication=requires_authentication)
     self._create_sdk_entity(sdk_type)
# Get the root of the services tree:
system_service = connection.system_service()

# Get the list of OpenStack image providers (a.k.a. Glance providers)
# that match the name that we want to use:
providers_service = system_service.openstack_image_providers_service()
providers = [
    provider for provider in providers_service.list() if provider.name == name
]

# If there is no such provider, then add it:
if len(providers) == 0:
    providers_service.add(provider=types.OpenStackImageProvider(
        name=name,
        description='My Glance',
        url='http://glance.ovirt.org:9292',
        requires_authentication=False))

# Note that the provider that we are using in this example is public
# and doesn't require any authentication. If your provider requires
# authentication then you will need to specify additional security
# related attributes:
#
#  types.OpenStackImageProvider(
#    name=name,
#    description='My private Glance',
#    url='http://myglance',
#    requires_authentication=True,
#    authentication_url='http://mykeystone',
#    username='******',