Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

from slipstream.command.CloudClientCommand import main
from slipstream.command.TerminateInstancesCommand import TerminateInstancesCommand
from slipstream_docker.DockerCommand import DockerCommand
from slipstream.ConfigHolder import ConfigHolder
from slipstream.NodeDecorator import KEY_RUN_CATEGORY


class DockerTerminateInstances(TerminateInstancesCommand, DockerCommand):

    def _set_command_specific_options(self, parser):
        parser.add_option('--' + self.INSTANCE_IDS_KEY, dest=self.INSTANCE_IDS_KEY,
                          help='Instance ID (can be used multiple times)',
                          action='append', default=[], metavar='ID')
        parser.add_option('--' + self.INSTANCES_IDS_FILE_KEY, dest=self.INSTANCES_IDS_FILE_KEY,
                          help='File containing a list of instance ids (one per line)',
                          default=None, metavar='FILE')

    def __init__(self):
        super(DockerTerminateInstances, self).__init__()


if __name__ == "__main__":
    main(DockerTerminateInstances)
        self.parser.add_option('--' + self.CONTEXTUALIZATION_TYPE_KEY, dest=self.CONTEXTUALIZATION_TYPE_KEY,
                               help='Contextualization type (default: "one-context")',
                               default='one-context', metavar='CONTEXTUALIZATION_TYPE')

        self.parser.add_option('--' + self.CPU_RATIO_KEY, dest=self.CPU_RATIO_KEY,
                               help='CPU ratio required for the Virtual Machine. ' +
                                    'This value is used to guide the host overcommitment. (default: 0.5)',
                               default='0.5', metavar='RATIO')

    def get_cloud_specific_user_cloud_params(self):
        user_params = OpenNebulaCommand.get_cloud_specific_user_cloud_params(self)
        user_params[UserInfo.NETWORK_PUBLIC_KEY] = self.get_option(self.NETWORK_PUBLIC_KEY)
        user_params[UserInfo.NETWORK_PRIVATE_KEY] = self.get_option(self.NETWORK_PRIVATE_KEY)
        user_params['cpuRatio'] = self.get_option(self.CPU_RATIO_KEY)
        return user_params

    def get_cloud_specific_node_inst_cloud_params(self):
        return {'cpu': self.get_option(self.CPU_KEY),
                'ram': self.get_option(self.RAM_KEY),
                'custom.vm.template': self.get_option(self.CUSTOM_VM_TEMPLATE_KEY),
                'contextualization.type': self.get_option(self.CONTEXTUALIZATION_TYPE_KEY),
                'network.specific.name': self.get_option(self.NETWORK_SPECIFIC_NAME_KEY)}

    def get_cloud_specific_mandatory_options(self):
        return OpenNebulaCommand.get_cloud_specific_mandatory_options(self) + [self.CPU_RATIO_KEY]


if __name__ == "__main__":
    main(OpenNebulaRunInstances)
 SlipStream Client
 =====
 Copyright (C) 2015 SixSq Sarl (sixsq.com)
 =====
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

from slipstream.command.CloudClientCommand import main
from slipstream.command.TerminateInstancesCommand import TerminateInstancesCommand
from slipstream_opennebula.OpenNebulaCommand import OpenNebulaCommand


class OpenNebulaTerminateInstances(TerminateInstancesCommand, OpenNebulaCommand):

    def __init__(self):
        super(OpenNebulaTerminateInstances, self).__init__()


if __name__ == "__main__":
    main(OpenNebulaTerminateInstances)
Exemplo n.º 4
0
 SlipStream Client
 =====
 Copyright (C) 2015 SixSq Sarl (sixsq.com)
 =====
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

from slipstream.command.CloudClientCommand import main
from slipstream.command.TerminateInstancesCommand import TerminateInstancesCommand
from slipstream_opennebula.OpenNebulaCommand import OpenNebulaCommand


class OpenNebulaTerminateInstances(TerminateInstancesCommand,
                                   OpenNebulaCommand):
    def __init__(self):
        super(OpenNebulaTerminateInstances, self).__init__()


if __name__ == "__main__":
    main(OpenNebulaTerminateInstances)
Exemplo n.º 5
0
    #     return vm['metadata']['uid']

    def _print_results(self, cc, vms):
        print "id, name, namespace, node name, image, state, ip, " \
                "port mappings [containerPort:hostPort], restart policy, " \
                "cpu request, ram request, instance-type, creation time, start time"
        for vm in vms:
            print ', '.join([
                cc._vm_get_id(vm),
                cc._vm_get_name(vm),
                cc._vm_get_namespace(vm),
                cc._vm_get_node_name(vm),
                cc._vm_get_image_name(vm),
                cc._vm_get_state(vm) or 'Unknown',
                cc._vm_get_ip(vm),
                cc._vm_get_port_mappings(vm),
                cc._vm_get_restart_policy(vm),
                cc._vm_get_cpu(vm),
                cc._vm_get_ram(vm),
                cc._vm_get_instance_type(vm),
                cc._vm_get_creation_time(vm),
                cc._vm_get_start_time(vm)
            ])

    def __init__(self):
        super(KubernetesDescribeInstances, self).__init__()


if __name__ == "__main__":
    main(KubernetesDescribeInstances)
Exemplo n.º 6
0
 Copyright (C) 2015 SixSq Sarl (sixsq.com)
 =====
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)

from slipstream.command.CloudClientCommand import main
from slipstream.command.DescribeInstancesCommand import DescribeInstancesCommand
from slipstream_opennebula.OpenNebulaCommand import OpenNebulaCommand


class OpenNebulaDescribeInstances(DescribeInstancesCommand, OpenNebulaCommand):
    def __init__(self):
        super(OpenNebulaDescribeInstances, self).__init__()


if __name__ == "__main__":
    main(OpenNebulaDescribeInstances)
Exemplo n.º 7
0
        self.parser.add_option('--' + self.NETWORK_SPECIFIC_NAME_KEY, dest=self.NETWORK_SPECIFIC_NAME_KEY,
                               help='Override network in Cloud configuration section! ' +
                                    'Connect VM network interface on specified virtual network name. ' +
                                    'Format: <NETWORK_NAME> or <NETWORK_NAME;NETWORK_UNAME>',
                               default='', metavar='NETWORK_NAME')

        self.parser.add_option('--' + self.CONTEXTUALIZATION_TYPE_KEY, dest=self.CONTEXTUALIZATION_TYPE_KEY,
                               help='Contextualization type (default: "one-context")',
                               default='one-context', metavar='CONTEXTUALIZATION_TYPE')

    def get_cloud_specific_user_cloud_params(self):
        user_params = OpenNebulaCommand.get_cloud_specific_user_cloud_params(self)
        user_params['network.public'] = self.get_option(self.NETWORK_PUBLIC_KEY)
        user_params['network.private'] = self.get_option(self.NETWORK_PRIVATE_KEY)
        return user_params

    def get_cloud_specific_node_inst_cloud_params(self):
        return {'cpu': self.get_option(self.CPU_KEY),
                'ram': self.get_option(self.RAM_KEY),
                'custom.vm.template': self.get_option(self.CUSTOM_VM_TEMPLATE_KEY),
                'contextualization.type': self.get_option(self.CONTEXTUALIZATION_TYPE_KEY),
                'network.specific.name': self.get_option(self.NETWORK_SPECIFIC_NAME_KEY)}

    def get_cloud_specific_mandatory_options(self):
        return OpenNebulaCommand.get_cloud_specific_mandatory_options(self)


if __name__ == "__main__":
    main(OpenNebulaRunInstances)
Exemplo n.º 8
0
class DockerDescribeInstances(DescribeInstancesCommand, DockerCommand):
    def _print_results(self, cc, vms):
        # print "id, name, node name, image, state, ip, " \
        #         "port mappings [containerPort:hostPort], restart policy, " \
        #         "cpu request, ram request, instance-type, creation time, start time"
        print "SERVICES: \n" \
                "id, name, image, ip, " \
                "port mappings [containerPort:hostPort], restart policy, " \
                "creation time, update time, replicas"
        for vm in vms:
            print ', '.join([
                cc._vm_get_id(vm),
                cc._vm_get_name(vm),
                cc._vm_get_image_name(vm),
                cc._vm_get_ip(vm),
                cc._vm_get_port_mappings(vm),
                cc._vm_get_restart_policy(vm),
                cc._vm_get_creation_time(vm),
                cc._vm_get_start_time(vm),
                cc._vm_get_replicas(vm)
                # cc._vm_get_node_name(vm)
            ])

    def __init__(self):
        super(DockerDescribeInstances, self).__init__()


if __name__ == "__main__":
    main(DockerDescribeInstances)
Exemplo n.º 9
0
"""

from slipstream.command.CloudClientCommand import main
from slipstream.command.TerminateInstancesCommand import TerminateInstancesCommand
from slipstream_docker.DockerCommand import DockerCommand
from slipstream.ConfigHolder import ConfigHolder
from slipstream.NodeDecorator import KEY_RUN_CATEGORY


class DockerTerminateInstances(TerminateInstancesCommand, DockerCommand):
    def _set_command_specific_options(self, parser):
        parser.add_option('--' + self.INSTANCE_IDS_KEY,
                          dest=self.INSTANCE_IDS_KEY,
                          help='Instance ID (can be used multiple times)',
                          action='append',
                          default=[],
                          metavar='ID')
        parser.add_option(
            '--' + self.INSTANCES_IDS_FILE_KEY,
            dest=self.INSTANCES_IDS_FILE_KEY,
            help='File containing a list of instance ids (one per line)',
            default=None,
            metavar='FILE')

    def __init__(self):
        super(DockerTerminateInstances, self).__init__()


if __name__ == "__main__":
    main(DockerTerminateInstances)
Exemplo n.º 10
0
    def _get_node_instance(self):
        # the runtime parameters are not the same as for VMs
        runtime_parameters = {
            NodeDecorator.NODE_INSTANCE_NAME_KEY: self.get_node_instance_name(),
            'cloudservice': self._cloud_instance_name
        }

        return NodeInstance(runtime_parameters)

    def get_cloud_specific_node_inst_cloud_params(self):
        node_params = DockerCommand.get_cloud_specific_node_inst_cloud_params(self)
        node_params[self.SERVICE_REQUEST] = self.get_option(self.SERVICE_REQUEST)
        return node_params

    def _get_command_specific_node_inst_cloud_params(self):
        # LOGIN_PASS_KEY does not apply to the Docker connector
        cloud_params = {}
        return cloud_params

    def get_cloud_specific_mandatory_options(self):
        return DockerCommand.get_cloud_specific_mandatory_options(self)

    def _get_command_mandatory_options(self):
        # Remove USER PASS from mandatory parameters as we might be dealing
        # with a no protected cluster
        return [self.SERVICE_REQUEST]

if __name__ == "__main__":
    main(DockerRunInstances)
Exemplo n.º 11
0
        ch = ConfigHolder(options={
            'verboseLevel': self.options.verbose and 3 or 0,
            'retry': False,
            KEY_RUN_CATEGORY: ''
        },
                          context={'foo': 'bar'})
        cc = self.get_connector_class()(ch)

        # pylint: disable=protected-access
        cc._initialization(self.user_info,
                           **self.get_initialization_extra_kwargs())

        fname = self.get_option(self.INSTANCES_IDS_FILE_KEY)
        if fname:
            with open(fname) as f:
                ids += f.read().splitlines()

        if cc.has_capability(cc.CAPABILITY_VAPP):
            cc.stop_vapps_by_ids(ids,
                                 self.get_option(self.INSTANCES_NAMESPACE))
        else:
            cc._stop_instances_in_namespace(
                ids, self.get_option(self.INSTANCES_NAMESPACE))

    def __init__(self):
        super(KubernetesTerminateInstances, self).__init__()


if __name__ == "__main__":
    main(KubernetesTerminateInstances)
            NodeDecorator.NODE_INSTANCE_NAME_KEY: self.get_node_instance_name(),
            'cloudservice': self._cloud_instance_name,
            'image.id': self.get_option(self.IMAGE_ID_KEY)}

        return NodeInstance(runtime_parameters)

    def get_cloud_specific_node_inst_cloud_params(self):
        node_params = DockerCommand.get_cloud_specific_node_inst_cloud_params(self)
        return node_params

    def _get_command_specific_node_inst_cloud_params(self):
        return {self.NETWORK_PORTS_MAPPINGS_KEY: self.get_option(self.NETWORK_PORTS_MAPPINGS_KEY),
                self.MOUNTS_KEY: self.get_option(self.MOUNTS_KEY),
                self.RESTART_POLICY_KEY: self.get_option(self.RESTART_POLICY_KEY),
                self.ENV_KEY: self.get_option(self.ENV_KEY),
                self.WORKING_DIR_KEY: self.get_option(self.WORKING_DIR_KEY),
                self.COMMAND_KEY: self.get_option(self.COMMAND_KEY),
                self.ARGS_KEY: self.get_option(self.ARGS_KEY),
                self.CPU_RATIO_KEY: self.get_option(self.CPU_RATIO_KEY),
                self.MEMORY_KEY: self.get_option(self.MEMORY_KEY)}

    def get_cloud_specific_mandatory_options(self):
        return DockerCommand.get_cloud_specific_mandatory_options(self)

    def _get_command_mandatory_options(self):
        return [self.IMAGE_ID_KEY]


if __name__ == "__main__":
    main(DockerRunInstances)
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""

import warnings

warnings.filterwarnings("ignore", category=DeprecationWarning)

from slipstream.command.CloudClientCommand import main
from slipstream.command.DescribeInstancesCommand import DescribeInstancesCommand
from slipstream_docker.DockerCommand import DockerCommand


class DockerDescribeInstances(DescribeInstancesCommand, DockerCommand):

    def __init__(self):
        super(DockerDescribeInstances, self).__init__()


if __name__ == "__main__":
    main(DockerDescribeInstances)
Exemplo n.º 14
0

class KubernetesRunInstances(RunInstancesCommand, KubernetesCommand):

    NETWORK_PUBLIC_KEY = 'network-public'
    NETWORK_PRIVATE_KEY = 'network-private'
    CPU_KEY = 'cpu'
    RAM_KEY = 'ram'
    CUSTOM_VM_TEMPLATE_KEY = 'custom-vm-template'
    NETWORK_SPECIFIC_NAME_KEY = 'network-specific-name'
    CONTEXTUALIZATION_TYPE_KEY = 'contextualization-type'
    INSTANCES_NAMESPACE = "instance-namespace"

    def __init__(self):
        super(KubernetesRunInstances, self).__init__()

    def set_cloud_specific_options(self, parser):
        KubernetesCommand.set_cloud_specific_options(self, parser)

        self.parser.add_option('--' + self.INSTANCES_NAMESPACE, dest=self.INSTANCES_NAMESPACE,
                          help='Namespace where the instances are',
                          default=[], metavar='NAMESPACE')

    def get_cloud_specific_mandatory_options(self):
        # return KubernetesCommand.get_cloud_specific_mandatory_options(self).append(self.INSTANCES_NAMESPACE)
        return KubernetesCommand.get_cloud_specific_mandatory_options(self)


if __name__ == "__main__":
    main(KubernetesRunInstances)