signature
stringlengths 8
3.44k
| body
stringlengths 0
1.41M
| docstring
stringlengths 1
122k
| id
stringlengths 5
17
|
|---|---|---|---|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install swift proxy service
:param auth_uri: keystone internal endpoint e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: keystone admin endpoint e.g. `http://CONTROLLER_VIP:35357`
:param swift_pass: password of `swift` user
:param memcached_servers: memcache servers e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param with_memcached: install memcached on remote server, if you have other memcached on the controller node, you can use `memcached_serser`
:returns: None
|
f10229:c0:m3
|
def finalize_install(self, *args, **kwargs):
|
return execute(self._finalize_install, *args, **kwargs)<EOL>
|
Finalize swift installation
:param swift_hash_path_suffix: `swift_hash_path_suffix` and `swift_hash_path_prefix` are used as part of the hashing algorithm when determining data placement in the cluster. These values should remain secret and MUST NOT change once a cluster has been deployed
:param swift_hash_path_prefix: `swift_hash_path_suffix` and `swift_hash_path_prefix` are used as part of the hashing algorithm when determining data placement in the cluster. These values should remain secret and MUST NOT change once a cluster has been deployed
:returns: None
|
f10229:c0:m5
|
def _prepare_disks(self, disks_name):
|
fstab = '<STR_LIT>'<EOL>for disk in tqdm(disks_name.split('<STR_LIT:U+002C>')):<EOL><INDENT>sudo('<STR_LIT>'.format(disk), warn_only=True)<EOL>if sudo('<STR_LIT>'.format(disk), warn_only=True).failed:<EOL><INDENT>sudo('<STR_LIT>')<EOL>sudo('<STR_LIT>')<EOL>sudo('<STR_LIT>'.format(disk))<EOL><DEDENT>sudo('<STR_LIT>'.format(disk))<EOL>files.append(<EOL>fstab, '<STR_LIT>'.format(disk, disk), use_sudo=True)<EOL>sudo('<STR_LIT>'.format(disk))<EOL><DEDENT>
|
format disks to xfs and mount it
|
f10230:c0:m0
|
def prepare_disks(self, *args, **kwargs):
|
return execute(self._prepare_disks, *args, **kwargs)<EOL>
|
Prepare the disks for storage
:param disks_name: the device name, e.g. `sdb,sdc`
:returns: None
|
f10230:c0:m1
|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install swift storage
:param address: the management interface ip for rsync
:param bind_ip: the management interface ip for swift storage binding
:returns: None
|
f10230:c0:m3
|
def create_account_builder_file(self, *args, **kwargs):
|
return execute(self._create_account_builder_file, *args, **kwargs)<EOL>
|
Create account ring
:param partitions: 2^10 (1024) maximum partitions e.g. `10`
:param replicas: 3 replicas of each object e.g. `3`
:param moving: 1 hour minimum time between moving a partition more than once e.g. `1`
:returns: None
|
f10230:c0:m5
|
def account_builder_add(self, *args, **kwargs):
|
return execute(self._account_builder_add, *args, **kwargs)<EOL>
|
Add each storage node to the account ring
:param region: swift storage region e.g. `1`
:param zone: swift storage zone e.g. `1`
:param ip: the IP address of the management network on the each storage node e.g. `STORAGE_NODE_IP`
:param device: a storage device name on the same storage node e.g. `sdb`
:param weight: the storage device weight e.g. `100`
:returns: None
|
f10230:c0:m7
|
def account_builder_rebalance(self):
|
return execute(self._account_builder_rebalance)<EOL>
|
Rebalance account builder
:returns: None
|
f10230:c0:m9
|
def create_container_builder_file(self, *args, **kwargs):
|
return execute(self._create_container_builder_file, *args, **kwargs)<EOL>
|
Create container ring
:param partitions: 2^10 (1024) maximum partitions e.g. `10`
:param replicas: 3 replicas of each object e.g. `3`
:param moving: 1 hour minimum time between moving a partition more than once e.g. `1`
:returns: None
|
f10230:c0:m11
|
def container_builder_add(self, *args, **kwargs):
|
return execute(self._container_builder_add, *args, **kwargs)<EOL>
|
Add each storage node to the container ring
:param region: swift storage region e.g. `1`
:param zone: swift storage zone e.g. `1`
:param ip: the IP address of the management network on the storage node e.g. `STORAGE_NODE_IP`
:param device: a storage device name on the same storage node e.g. `sdb`
:param weight: the storage device weight e.g. `100`
:returns: None
|
f10230:c0:m13
|
def container_builder_rebalance(self):
|
return execute(self._container_builder_rebalance)<EOL>
|
Rebalance container builder
:returns: None
|
f10230:c0:m15
|
def create_object_builder_file(self, *args, **kwargs):
|
return execute(self._create_object_builder_file, *args, **kwargs)<EOL>
|
Create object ring
:param partitions: 2^10 (1024) maximum partitions e.g. `10`
:param replicas: 3 replicas of each object e.g. `3`
:param moving: 1 hour minimum time between moving a partition more than once e.g. `1`
:returns: None
|
f10230:c0:m17
|
def object_builder_add(self, *args, **kwargs):
|
return execute(self._object_builder_add, *args, **kwargs)<EOL>
|
Add each storage node to the object ring
:param region: swift storage region e.g. `1`
:param zone: swift storage zone e.g. `1`
:param ip: the IP address of the management network on the storage node e.g. `STORAGE_NODE_IP`
:param device: a storage device name on the same storage node e.g. `sdb`
:param weight: the storage device weight e.g. `100`
:returns: None
|
f10230:c0:m19
|
def object_builder_rebalance(self):
|
return execute(self._object_builder_rebalance)<EOL>
|
Rebalance object builder
:returns: None
|
f10230:c0:m21
|
def get_builder_file(self):
|
return execute(self._get_builder_file)<EOL>
|
Copy *.ring.gz to local
:returns: None
|
f10230:c0:m23
|
def sync_builder_file(self, hosts):
|
return execute(self._sync_builder_file, hosts=hosts)<EOL>
|
Copy the account.ring.gz, container.ring.gz, and object.ring.gz files from local to the /etc/swift directory on each storage node and any additional nodes running the proxy service
:returns: None
|
f10230:c0:m25
|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install neutron agent
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user: The RabbitMQ userid. (string value) e.g. `openstack`
:param rabbit_pass: The RabbitMQ password. (string value)
:param auth_uri: Complete public Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: keystone admin endpoint e.g. `http://CONTROLLER_VIP:35357`
:param neutron_pass: the password of `neutron` user
:param public_interface: public interface e.g. `eth1`
:param local_ip: underlying physical network interface that handles overlay networks(uses the management interface IP)
:param memcached_servers: Optionally specify a list of memcached server(s) to use for caching. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:returns: None
|
f10231:c0:m1
|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install nova compute
:param my_ip: (String) IP address of this host
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user: The RabbitMQ userid. (string value) e.g. `openstack`
:param rabbit_pass: The RabbitMQ password. (string value)
:param auth_uri: (String) Complete public Identity API endpoint. e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: (String) Authentication endpoint e.g. `http://CONTROLLER_VIP:35357`
:param nova_pass: passowrd of `nova` user
:param novncproxy_base_url: (String) Public address of noVNC VNC console proxy. The VNC proxy is an OpenStack component that enables compute service users to access their instances through VNC clients. noVNC provides VNC support through a websocket-based client. This option sets the public base URL to which client systems will connect. noVNC clients can use this address to connect to the noVNC instance and, by extension, the VNC sessions. Possible values: * A URL Services which consume this: * nova-compute Related options: * novncproxy_host * novncproxy_port e.g. `http://CONTROLLER_VIP:6080/vnc_auto.html`
:param glance_api_servers: (List) A list of the glance api servers endpoints available to nova. These should be fully qualified urls of the form scheme://hostname:port[/path] e.g. `http://CONTROLLER_VIP:9292`
:param neutron_endpoint: neutron endpoint e.g. `http://CONTROLLER_VIP:9696`
:param neutron_pass: the password of `neutron` user
:param rbd_secret_uuid: ceph rbd secret for nova libvirt , generated by `uuidgen`
:param memcached_servers: A list of memcached server(s) to use for caching. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:returns: None
|
f10232:c0:m1
|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install rabbitmq
:param erlang_cookie: setup elang cookie
:param rabbit_user: set rabbit user name
:param rabbit_pass: set rabbit password of `rabbit_user`
:returns: None
|
f10233:c0:m1
|
def join_cluster(self, *args, **kwargs):
|
return execute(self._join_cluster, *args, **kwargs)<EOL>
|
Join to the cluster
:param name: the joined name, e.g. `rabbit@CONTROLLER1`, ensure the `CONTROLLER1` can be accessed by target host
:returns: None
|
f10233:c0:m3
|
def update_mysql_config(self, *args, **kwargs):
|
return execute(self._update_mysql_config, *args, **kwargs)<EOL>
|
If trusty setup Galera Cluster for MySQL. If xenial setup MariaDB Galera Cluster
:param wsrep_cluster_address: the IP addresses for each cluster node e.g. `gcomm://CONTROLLER1_IP,CONTROLLER2_IP`
:param wsrep_node_name: the logical name of the cluster node e.g. `galera1`
:param wsrep_node_address: the IP address of the cluster node e.g. `CONTROLLER1_IP`
:returns: None
|
f10234:c0:m1
|
@runs_once<EOL><INDENT>def _create_glance_db(self, root_db_pass, glance_db_pass):<DEDENT>
|
print(red(env.host_string + '<STR_LIT>'))<EOL>sudo(<EOL>"<STR_LIT>".format(root_db_pass), shell=False)<EOL>sudo("<STR_LIT>".format(<EOL>root_db_pass, glance_db_pass), shell=False)<EOL>sudo("<STR_LIT>".format(<EOL>root_db_pass, glance_db_pass), shell=False)<EOL>
|
Create the glance database
|
f10235:c0:m0
|
def create_glance_db(self, *args, **kwargs):
|
execute(self._create_glance_db, *args, **kwargs)<EOL>
|
Create the `glance` database and the user named `glance`
:param root_db_pass: the mysql database `root` passowrd
:param glance_db_pass: the password of `glance` user
:returns: None
|
f10235:c0:m1
|
def create_service_credentials(self, *args, **kwargs):
|
return execute(self._create_service_credentials, *args, **kwargs)<EOL>
|
Create the glance service credentials
:param os_password: the password of openstack `admin` user
:param os_auth_url: keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param glance_pass: create a passowrd of `glance` user
:param public_endpoint: public endpoint for glance service e.g. `http://CONTROLLER_VIP:9292`
:param internal_endpoint: internal endpoint for glance service e.g. `http://CONTROLLER_VIP:9292`
:param admin_endpoint: admin endpoint for glance service e.g. `http://CONTROLLER_VIP:9292`
:returns: None
|
f10235:c0:m3
|
def install_glance(self, *args, **kwargs):
|
return execute(self._install_glance, *args, **kwargs)<EOL>
|
Install glance, default store is ceph
:param connection: The SQLAlchemy connection string to use to connect to the database. (string value) e.g. `mysql+pymysql://glance:GLANCE_PASS@CONTROLLER_VIP/glance`
:param auth_uri: Complete public Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: The URL to the keystone service. If "use_user_token" is not in effect and using keystone auth, then URL of keystone can be specified. (string value) e.g. `http://CONTROLLER_VIP:35357`
:param glance_pass: passowrd of `glance` user
:param swift_store_auth_address: DEPRECATED! the address where the Swift authentication service is listening e.g. `http://CONTROLLER_VIP:5000/v3/`
:param memcached_servers: Optionally specify a list of memcached server(s) to use for caching. If left undefined, tokens will instead be cached in-process. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param populate: populate the glance database
:returns: None
|
f10235:c0:m5
|
def create_cinder_db(self, *args, **kwargs):
|
return execute(self._create_cinder_db, *args, **kwargs)<EOL>
|
Create a database named `cinder` and the `cinder` user
:param root_db_pass(str): the password of mysql `root` account
:param cinder_db_pass(str): the password of `cinder` user:
|
f10236:c0:m1
|
def create_service_credentials(self, *args, **kwargs):
|
return execute(self._create_service_credentials, *args, **kwargs)<EOL>
|
r"""
Create the cinder service credentials
:param os_password(str): the password of OpenStack `admin` user
:param os_auth_url(str): keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param cinder_pass(str): password of `cinder` user
:param public_endpoint_v1(str): public endpoint for volume service e.g. `http://CONTROLLER_VIP:8776/v1/%\\(tenant_id\\)s`
:param internal_endpoint_v1(str): internal endpoint for volume service e.g. `http://CONTROLLER_VIP:8776/v1/%\\(tenant_id\\)s`
:param admin_endpoint_v1(str): admin endpoint for volume service e.g. `http://CONTROLLER_VIP:8776/v1/%\\(tenant_id\\)s`
:param public_endpoint_v2(str): public endpoint v2 for volumev2 service e.g. `http://CONTROLLER_VIP:8776/v2/%\\(tenant_id\\)s`
:param internal_endpoint_v2(str): internal endpoint v2 for volumev2 service e.g. `http://CONTROLLER_VIP:8776/v2/%\\(tenant_id\\)s`
:param admin_endpoint_v2(str): admin endpoint v2 for volumev2 service e.g. `http://CONTROLLER_VIP:8776/v2/%\\(tenant_id\\)s`
|
f10236:c0:m3
|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install cinder and volume service
:param connection: The SQLAlchemy connection string to use to connect to the database. (string value) e.g. `mysql+pymysql://cinder:CINDER_PASS@CONTROLLER_VIP/cinde`
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user(str): The RabbitMQ userid. (string value) e.g. `openstack`
:param rabbit_pass(str): The RabbitMQ password. (string value)
:param auth_uri(str): Complete public Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:5000`
:param auth_url(str): Complete admin Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:35357`
:param cinder_pass(str): create a password of `cinder` database user
:param my_ip(str): IP address of this host (string value)
:param glance_api_servers(str): A list of the URLs of glance API servers available to cinder ([http[s]://][hostname|ip]:port). If protocol is not specified it defaults to http. (list value) e.g. `http://CONTROLLER_VIP:9292`
:param rbd_secret_uuid(str): (String) The libvirt uuid of the secret for the rbd_user volumes (string value) , use `uuidgen` to generate the ceph uuid
:param memcached_servers(str): Optionally specify a list of memcached server(s) to use for caching. If left undefined, tokens will instead be cached in-process. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param populate(bool): Populate the cinder database, default `False`
|
f10236:c0:m5
|
def install(self):
|
return execute(self._install)<EOL>
|
Install HAProxy and Keepalived
:returns: None
|
f10237:c0:m1
|
def create_nova_db(self, *args, **kwargs):
|
return execute(self._create_nova_db, *args, **kwargs)<EOL>
|
Create the nova and nova_api database and the user named nova
:param root_db_pass: the password of mysql database root user
:param nova_db_pass: the password of nova database user
:returns: None
|
f10238:c0:m1
|
def create_service_credentials(self, *args, **kwargs):
|
return execute(self._create_service_credentials, *args, **kwargs)<EOL>
|
r"""
Create the nova service credentials
:param os_password: the password of openstack `admin` user
:param os_auth_url: keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param nova_pass: passowrd of `nova` user
:param public_endpoint: public endpoint for nova service e.g. `http://CONTROLLER_VIP:8774/v2.1/%\\(tenant_id\\)s`
:param internal_endpoint: internal endpoint for nova service e.g. `http://CONTROLLER_VIP:8774/v2.1/%\\(tenant_id\\)s`
:param admin_endpoint: admin endpoint for nova service e.g. `http://CONTROLLER_VIP:8774/v2.1/%\\(tenant_id\\)s`
:returns: None
|
f10238:c0:m3
|
def install_nova(self, *args, **kwargs):
|
return execute(self._install_nova, *args, **kwargs)<EOL>
|
Install nova
:param connection: (String) The SQLAlchemy connection string to use to connect to the Nova API database. e.g. `mysql+pymysql://nova:NOVA_PASS@CONTROLLER_VIP/nova`
:param api_connection: mysql nova_api database SQLAlchemy connection string e.g. `mysql+pymysql://nova:NOVA_PASS@CONTROLLER_VIP/nova_api`
:param auth_uri: (String) Complete public Identity API endpoint. e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: (String) Authentication endpoint e.g. `http://CONTROLLER_VIP:35357`
:param nova_pass: passowrd of `nova` user
:param my_ip: (String) IP address of this host
:param memcached_servers: A list of memcached server(s) to use for caching. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user: The RabbitMQ userid. (string value) e.g. `openstack`
:param rabbit_pass: The RabbitMQ password. (string value)
:param glance_api_servers: (List) A list of the glance api servers endpoints available to nova. These should be fully qualified urls of the form scheme://hostname:port[/path] e.g. `http://CONTROLLER_VIP:9292`
:param neutron_endpoint: neutron endpoint e.g. `http://CONTROLLER_VIP:9696`
:param neutron_pass: the password of `neutron` user
:param metadata_proxy_shared_secret: (String) Shared secret to validate proxies Neutron metadata requests
:param populate: populate the nova database
:returns: None
|
f10238:c0:m5
|
def enable_repo(self):
|
return execute(self._enable_repo)<EOL>
|
Setup repository for trusty only
:returns: None
|
f10239:c0:m1
|
def install(self):
|
return execute(self._install)<EOL>
|
Install Galera Cluster for MySQL if trusty, install MariaDB Galera Cluster if xenial
:returns: None
|
f10239:c0:m3
|
def install(self, *args, **kwargs):
|
return execute(self._install, *args, **kwargs)<EOL>
|
Install horizon
:param openstack_host: configure the dashboard to use OpenStack services on the controller node e.g. `CONTROLLER_VIP`
:param memcached_servers: django memcache e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param time_zone: the timezone of the server. This should correspond with the timezone of your entire OpenStack installation e.g. `America/New_York`
:returns: None
|
f10240:c0:m1
|
def create_keystone_db(self, *args, **kwargs):
|
return execute(self._create_keystone_db, *args, **kwargs)<EOL>
|
Create the `keystone` database and the user named keystone
:param root_db_pass: the mysql database `root` passowrd
:param keystone_db_pass: the password of `keystone` database user
:returns: None
|
f10241:c0:m1
|
def install_keystone(self, *args, **kwargs):
|
return execute(self._install_keystone, *args, **kwargs)<EOL>
|
Install keystone
:param admin_token: define the value of the initial administration token
:param connection: (String) The SQLAlchemy connection string to use to connect to the database. e.g. `mysql+pymysql://keystone:PASS@CONTROLLER_VIP/keystone`
:param memcached_servers: (List) Optionally specify a list of memcached server(s) to use for caching. If left undefined, tokens will instead be cached in-process. e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param populate: populate the `keystone` database
:returns: None
|
f10241:c0:m3
|
def create_entity_and_endpoint(self, *args, **kwargs):
|
return execute(self._create_entity_and_endpoint, *args, **kwargs)<EOL>
|
Create the service entity and API endpoints
:param os_token: the openstack admin token
:param os_url: keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param public_endpoint: the public endpoint e.g. `http://CONTROLLER_VIP:5000/v3`
:param internal_endpoint: the internal endpoint e.g. `http://CONTROLLER_VIP:5000/v3`
:param admin_endpoint: the admin endpoint e.g. `http://CONTROLLER_VIP:35357/v3`
:returns: None
|
f10241:c0:m5
|
def create_projects_users_roles(self, *args, **kwargs):
|
return execute(self._create_projects_users_roles, *args, **kwargs)<EOL>
|
Create an administrative and demo project, user, and role for administrative and testing operations in your environment
:param os_token: the openstack admin token
:param os_url: keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param admin_pass: passowrd of openstack `admin` user
:param demo_pass: passowrd of openstack `demo` user
:returns: None
|
f10241:c0:m7
|
def _update_keystone_paste_ini(self):
|
with open('<STR_LIT>' + env.host_string, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(conf_keystone_paste_ini)<EOL><DEDENT>files.upload_template(filename='<STR_LIT>' + env.host_string,<EOL>destination='<STR_LIT>',<EOL>use_sudo=True,<EOL>backup=True)<EOL>os.remove('<STR_LIT>' + env.host_string)<EOL>
|
remove admin_token_auth from the [pipeline:public_api],
[pipeline:admin_api], and [pipeline:api_v3] sections
|
f10241:c0:m8
|
def update_keystone_paste_ini(self):
|
return execute(self._update_keystone_paste_ini)<EOL>
|
Remove admin_token_auth from the [pipeline:public_api],
[pipeline:admin_api], and [pipeline:api_v3] sections in `/etc/keystone/keystone-paste.ini`
:returns: None
|
f10241:c0:m9
|
def create_manila_db(self, *args, **kwargs):
|
return execute(self._create_manila_db, *args, **kwargs)<EOL>
|
Create manila database and the user named manila
:param root_db_pass: the password of mysql root user
:param manila_db_pass: the password of manila database user
:returns: None
|
f10242:c0:m1
|
def create_service_credentials(self, *args, **kwargs):
|
return execute(self._create_service_credentials, *args, **kwargs)<EOL>
|
r"""
create the manila service credentials
:param os_password: the password of openstack `admin` user
:param os_auth_url: keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param manila_pass: passowrd of `manila` user
:param public_endpoint_v1: public endpoint for manila service e.g. `http://CONTROLLER_VIP:8786/v1/%\\(tenant_id\\)s`
:param internal_endpoint_v1: internal endpoint for manila service e.g. `http://CONTROLLER_VIP:8786/v1/%\\(tenant_id\\)s`
:param admin_endpoint_v1: admin endpoint for manila service e.g. `http://CONTROLLER_VIP:8786/v1/%\\(tenant_id\\)s`
:param public_endpoint_v2: public endpoint for manila service e.g. `http://CONTROLLER_VIP:8786/v2/%\\(tenant_id\\)s`
:param internal_endpoint_v2: internal endpoint for manila service e.g. `http://CONTROLLER_VIP:8786/v2/%\\(tenant_id\\)s`
:param admin_endpoint_v2: admin endpoint for manila service e.g. `http://CONTROLLER_VIP:8786/v2/%\\(tenant_id\\)s`
:returns: None
|
f10242:c0:m3
|
def install_manila(self, *args, **kwargs):
|
return execute(self._install_manila, *args, **kwargs)<EOL>
|
Install manila
:param connection: The SQLAlchemy connection string to use to connect to the database. (string value) e.g. `mysql+pymysql://manila:MANILA_PASS@CONTROLLER_VIP/manila`
:param auth_uri: Complete public Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: keystone admin endpoint e.g. `http://CONTROLLER_VIP:35357`
:param manila_pass: passowrd of `manila` user
:param my_ip: IP address of this host. (string value)
:param memcached_servers: Memcached servers or None for in process cache. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user: The RabbitMQ userid. (string value) e.g. `openstack`
:param rabbit_pass: The RabbitMQ password. (string value)
:param populate: populate the manila database
:returns: None
|
f10242:c0:m5
|
def install_manila_share(self, *args, **kwargs):
|
return execute(self._install_manila_share, *args, **kwargs)<EOL>
|
Install manila share service
:param connection: The SQLAlchemy connection string to use to connect to the database. (string value) e.g. `mysql+pymysql://manila:MANILA_PASS@CONTROLLER_VIP/manila`
:param auth_uri: Complete public Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: Authentication URL (unknown value) e.g. `http://CONTROLLER_VIP:35357`
:param manila_pass: passowrd of `manila` user
:param my_ip: IP address of this host. (string value)
:param memcached_servers: Memcached servers or None for in process cache. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user: The RabbitMQ userid. (string value) e.g. openstack
:param rabbit_pass: The RabbitMQ password. (string value)
:param neutron_endpoint: neutron endpoint e.g. `http://CONTROLLER_VIP:9696`
:param neutron_pass: the password of `neutron` user
:param nova_pass: the passowrd of `nova` user
:param cinder_pass: the passowrd of `cinder` user
:returns: None
|
f10244:c0:m1
|
@priority(<NUM_LIT:15>)<EOL>def make(parser):
|
s = parser.add_subparsers(<EOL>title='<STR_LIT>',<EOL>metavar='<STR_LIT>',<EOL>help='<STR_LIT:description>',<EOL>)<EOL>
|
DEPRECATED
provison Glance with HA
|
f10290:m4
|
@priority(<NUM_LIT>)<EOL>def make(parser):
|
s = parser.add_subparsers(<EOL>title='<STR_LIT>',<EOL>metavar='<STR_LIT>',<EOL>help='<STR_LIT:description>',<EOL>)<EOL>def create_manila_db_f(args):<EOL><INDENT>create_manila_db(args)<EOL><DEDENT>create_manila_db_parser = create_manila_db_subparser(s)<EOL>create_manila_db_parser.set_defaults(func=create_manila_db_f)<EOL>def create_service_credentials_f(args):<EOL><INDENT>create_service_credentials(args)<EOL><DEDENT>create_service_credentials_parser = create_service_credentials_subparser(s)<EOL>create_service_credentials_parser.set_defaults(func=create_service_credentials_f)<EOL>def install_f(args):<EOL><INDENT>install(args)<EOL><DEDENT>install_parser = install_subparser(s)<EOL>install_parser.set_defaults(func=install_f)<EOL>
|
provison Manila with HA
|
f10296:m7
|
def gen_pass():
|
os.system('<STR_LIT>')<EOL>
|
DEPRECATED
|
f10297:m1
|
def cmd(user, hosts, key_filename, password, run):
|
try:<EOL><INDENT>remote = Cmd(user, hosts, key_filename, password)<EOL><DEDENT>except AttributeError:<EOL><INDENT>sys.stderr.write('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>remote.cmd(run)<EOL>
|
DEPRECATED
|
f10297:m2
|
@priority(<NUM_LIT:10>)<EOL>def make(parser):
|
s = parser.add_subparsers(<EOL>title='<STR_LIT>',<EOL>metavar='<STR_LIT>',<EOL>help='<STR_LIT:description>',<EOL>)<EOL>def gen_pass_f(args):<EOL><INDENT>gen_pass()<EOL><DEDENT>gen_pass_parser = s.add_parser('<STR_LIT>', help='<STR_LIT>')<EOL>gen_pass_parser.set_defaults(func=gen_pass_f)<EOL>def cmd_f(args):<EOL><INDENT>cmd(args.user, args.hosts.split('<STR_LIT:U+002C>'), args.key_filename, args.password, args.run)<EOL><DEDENT>cmd_parser = s.add_parser('<STR_LIT>', help='<STR_LIT>')<EOL>cmd_parser.add_argument('<STR_LIT>', help='<STR_LIT>', action='<STR_LIT:store>', default=None, dest='<STR_LIT>')<EOL>cmd_parser.set_defaults(func=cmd_f)<EOL>
|
DEPRECATED
prepare OpenStack basic environment
|
f10297:m3
|
@priority(<NUM_LIT>)<EOL>def make(parser):
|
s = parser.add_subparsers(<EOL>title='<STR_LIT>',<EOL>metavar='<STR_LIT>',<EOL>help='<STR_LIT:description>',<EOL>)<EOL>def install_f(args):<EOL><INDENT>install(args)<EOL><DEDENT>install_parser = install_subparser(s)<EOL>install_parser.set_defaults(func=install_f)<EOL>
|
provison Manila Share with HA
|
f10298:m3
|
def priority(num):
|
def add_priority(fn):<EOL><INDENT>fn.priority = num<EOL>return fn<EOL><DEDENT>return add_priority<EOL>
|
DEPRECATED
Decorator to add a `priority` attribute to the function.
|
f10302:m0
|
def create_neutron_db(self, *args, **kwargs):
|
return execute(self._create_neutron_db, *args, **kwargs)<EOL>
|
Create the neutron database and the user named neutron
:param root_db_pass: the password of openstack database `root` user
:param neutron_db_pass: the password of `neutron` database user
:returns: None
|
f10303:c0:m1
|
def create_service_credentials(self, *args, **kwargs):
|
return execute(self._create_service_credentials, *args, **kwargs)<EOL>
|
create the neutron service credentials
:param os_password: the password of openstack `admin` user
:param os_auth_url: keystone endpoint url e.g. `http://CONTROLLER_VIP:35357/v3`
:param neutron_pass: the password of `neutron` user
:param public_endpoint: public endpoint for neutron service e.g. `http://CONTROLLER_VIP:9696`
:param internal_endpoint: internal endpoint for neutron service e.g. `http://CONTROLLER_VIP:9696`
:param admin_endpoint: admin endpoint for neutron service e.g. `http://CONTROLLER_VIP:9696`
:returns: None
|
f10303:c0:m3
|
def install_self_service(self, *args, **kwargs):
|
return execute(self._install_self_service, *args, **kwargs)<EOL>
|
Install neutron for self-service
:param connection: The SQLAlchemy connection string to use to connect to the database. (string value) e.g. `mysql+pymysql://neutron:NEUTRON_PASS@CONTROLLER_VIP/neutron`
:param rabbit_hosts: RabbitMQ HA cluster host:port pairs. (list value) e.g. `CONTROLLER1,CONTROLLER2`
:param rabbit_user: The RabbitMQ userid. (string value) e.g. `openstack`
:param rabbit_pass: The RabbitMQ password. (string value)
:param auth_uri: Complete public Identity API endpoint. (string value) e.g. `http://CONTROLLER_VIP:5000`
:param auth_url: keystone admin endpoint e.g. `http://CONTROLLER_VIP:35357`
:param neutron_pass: the password of `neutron` user
:param nova_url: URL for connection to nova (Only supports one nova region currently) e.g. `http://CONTROLLER_VIP:8774/v2.1`
:param nova_pass: passowrd of `nova` user
:param public_interface: public interface e.g. `eth1`
:param local_ip: underlying physical network interface that handles overlay networks(uses the management interface IP) (ip address value)
:param nova_metadata_ip: IP address used by Nova metadata server. (string value) e.g. `CONTROLLER_VIP`
:param metadata_proxy_shared_secret: When proxying metadata requests, Neutron signs the Instance-ID header with a shared secret to prevent spoofing. You may select any string for a secret, but it must match here and in the configuration used by the Nova Metadata Server. NOTE: Nova uses the same config key, but in [neutron] section. (string value)
:param memcached_servers: Optionally specify a list of memcached server(s) to use for caching. (list value) e.g. `CONTROLLER1:11211,CONTROLLER2:11211`
:param populate: populate the neutron database
:returns: None
|
f10303:c0:m5
|
def upload_conf(self, *args, **kwargs):
|
return execute(self._upload_conf, *args, **kwargs)<EOL>
|
Upload configuration file to the target host
:param file: the path of haproxy configration file
:returns: None
|
f10304:c0:m1
|
def configure_keepalived(self, *args, **kwargs):
|
return execute(self._configure_keepalived, *args, **kwargs)<EOL>
|
Configure keepalived
:param router_id: Keepalived router id e.g. `lb1`
:param priority: Keepalived priority e.g. `150`
:param state: Keepalived state e.g. `MASTER` or 'SLAVE'
:param interface: Keepalived binding interface e.g. `eth0`
:param vip: Keepalived virtual ip e.g. `CONTROLLER_VIP`
:returns: None
|
f10304:c0:m3
|
def cmd(self, *args, **kwargs):
|
return execute(self._cmd, *args, **kwargs)<EOL>
|
The command line to be executed on the remote node
:param command_line(str): command line
:returns: None
|
f10305:c0:m1
|
def start_wsrep_new_cluster(self):
|
return execute(self._start_wsrep_new_cluster)<EOL>
|
Initialize the primary component on one cluster node
:returns: None
|
f10307:c0:m1
|
def start_mysql(self):
|
return execute(self._start_mysql)<EOL>
|
Start the database server to join the cluster
:returns: None
|
f10307:c0:m3
|
def stop_mysql(self):
|
return execute(self._stop_mysql)<EOL>
|
Stop the mysql service
:returns: None
|
f10307:c0:m5
|
def change_root_password(self, *args, **kwargs):
|
return execute(self._change_root_password, *args, **kwargs)<EOL>
|
Change the mysql root password
:param pwd: the new password of root user
:returns: None
|
f10307:c0:m7
|
def show_cluster_status(self, *args, **kwargs):
|
return execute(self._show_cluster_status, *args, **kwargs)<EOL>
|
Display the cluster status
:param root_db_pass: the password of mysql root user
:returns: None
|
f10307:c0:m9
|
def _apply_base_theme(app):
|
if QT_VERSION < (<NUM_LIT:5>,):<EOL><INDENT>app.setStyle('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>app.setStyle('<STR_LIT>')<EOL><DEDENT>with open(_STYLESHEET) as stylesheet:<EOL><INDENT>app.setStyleSheet(stylesheet.read())<EOL><DEDENT>
|
Apply base theme to the application.
Args:
app (QApplication): QApplication instance.
|
f10309:m0
|
def dark(app):
|
_apply_base_theme(app)<EOL>darkPalette = QPalette()<EOL>darkPalette.setColor(QPalette.WindowText, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Button, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Light, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Midlight, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Dark, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Text, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.BrightText, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.ButtonText, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Base, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Window, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Shadow, QColor(<NUM_LIT:20>, <NUM_LIT:20>, <NUM_LIT:20>))<EOL>darkPalette.setColor(QPalette.Highlight, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.HighlightedText, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Link, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.AlternateBase, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.ToolTipBase, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.ToolTipText, QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Disabled, QPalette.WindowText,<EOL>QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Disabled, QPalette.Text,<EOL>QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Disabled, QPalette.ButtonText,<EOL>QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Disabled, QPalette.Highlight,<EOL>QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>darkPalette.setColor(QPalette.Disabled, QPalette.HighlightedText,<EOL>QColor(<NUM_LIT>, <NUM_LIT>, <NUM_LIT>))<EOL>app.setPalette(darkPalette)<EOL>
|
Apply Dark Theme to the Qt application instance.
Args:
app (QApplication): QApplication instance.
|
f10309:m1
|
def setWindowTitle(self, title):
|
self.lblTitle.setText(title)<EOL>
|
Set window title.
Args:
title (str): Title.
|
f10310:c1:m3
|
@classmethod<EOL><INDENT>def from_file(cls, filename, **kwargs):<DEDENT>
|
filename = os.path.expanduser(filename)<EOL>if not os.path.isfile(filename):<EOL><INDENT>raise exceptions.PyKubeError("<STR_LIT>".format(filename))<EOL><DEDENT>with open(filename) as f:<EOL><INDENT>doc = yaml.safe_load(f.read())<EOL><DEDENT>self = cls(doc, **kwargs)<EOL>self.filename = filename<EOL>return self<EOL>
|
Creates an instance of the KubeConfig class from a kubeconfig file.
:Parameters:
- `filename`: The full path to the configuration file
|
f10316:c0:m1
|
@classmethod<EOL><INDENT>def from_url(cls, url, **kwargs):<DEDENT>
|
doc = {<EOL>"<STR_LIT>": [<EOL>{<EOL>"<STR_LIT:name>": "<STR_LIT>",<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": url,<EOL>},<EOL>},<EOL>],<EOL>"<STR_LIT>": [<EOL>{<EOL>"<STR_LIT:name>": "<STR_LIT>",<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>},<EOL>}<EOL>],<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>}<EOL>self = cls(doc, **kwargs)<EOL>return self<EOL>
|
Creates an instance of the KubeConfig class from a single URL (useful
for interacting with kubectl proxy).
|
f10316:c0:m2
|
def __init__(self, doc, current_context=None):
|
self.doc = doc<EOL>self._current_context = None<EOL>if current_context is not None:<EOL><INDENT>self.set_current_context(current_context)<EOL><DEDENT>elif "<STR_LIT>" in doc and doc["<STR_LIT>"]:<EOL><INDENT>self.set_current_context(doc["<STR_LIT>"])<EOL><DEDENT>
|
Creates an instance of the KubeConfig class.
|
f10316:c0:m3
|
def set_current_context(self, value):
|
self._current_context = value<EOL>
|
Sets the context to the provided value.
:Parameters:
- `value`: The value for the current context
|
f10316:c0:m4
|
@property<EOL><INDENT>def clusters(self):<DEDENT>
|
if not hasattr(self, "<STR_LIT>"):<EOL><INDENT>cs = {}<EOL>for cr in self.doc["<STR_LIT>"]:<EOL><INDENT>cs[cr["<STR_LIT:name>"]] = c = copy.deepcopy(cr["<STR_LIT>"])<EOL>if "<STR_LIT>" not in c:<EOL><INDENT>c["<STR_LIT>"] = "<STR_LIT>"<EOL><DEDENT>BytesOrFile.maybe_set(c, "<STR_LIT>")<EOL><DEDENT>self._clusters = cs<EOL><DEDENT>return self._clusters<EOL>
|
Returns known clusters by exposing as a read-only property.
|
f10316:c0:m6
|
@property<EOL><INDENT>def users(self):<DEDENT>
|
if not hasattr(self, "<STR_LIT>"):<EOL><INDENT>us = {}<EOL>if "<STR_LIT>" in self.doc:<EOL><INDENT>for ur in self.doc["<STR_LIT>"]:<EOL><INDENT>us[ur["<STR_LIT:name>"]] = u = copy.deepcopy(ur["<STR_LIT:user>"])<EOL>BytesOrFile.maybe_set(u, "<STR_LIT>")<EOL>BytesOrFile.maybe_set(u, "<STR_LIT>")<EOL><DEDENT><DEDENT>self._users = us<EOL><DEDENT>return self._users<EOL>
|
Returns known users by exposing as a read-only property.
|
f10316:c0:m7
|
@property<EOL><INDENT>def contexts(self):<DEDENT>
|
if not hasattr(self, "<STR_LIT>"):<EOL><INDENT>cs = {}<EOL>for cr in self.doc["<STR_LIT>"]:<EOL><INDENT>cs[cr["<STR_LIT:name>"]] = copy.deepcopy(cr["<STR_LIT>"])<EOL><DEDENT>self._contexts = cs<EOL><DEDENT>return self._contexts<EOL>
|
Returns known contexts by exposing as a read-only property.
|
f10316:c0:m8
|
@property<EOL><INDENT>def cluster(self):<DEDENT>
|
return self.clusters[self.contexts[self.current_context]["<STR_LIT>"]]<EOL>
|
Returns the current selected cluster by exposing as a
read-only property.
|
f10316:c0:m9
|
@property<EOL><INDENT>def user(self):<DEDENT>
|
return self.users.get(self.contexts[self.current_context].get("<STR_LIT:user>", "<STR_LIT>"), {})<EOL>
|
Returns the current user set by current context
|
f10316:c0:m10
|
@property<EOL><INDENT>def namespace(self):<DEDENT>
|
return self.contexts[self.current_context].get("<STR_LIT>", "<STR_LIT:default>")<EOL>
|
Returns the current context namespace by exposing as a read-only property.
|
f10316:c0:m11
|
def __init__(self, filename=None, data=None):
|
self._filename = None<EOL>self._bytes = None<EOL>if filename is not None and data is not None:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>elif filename is not None:<EOL><INDENT>if not os.path.isfile(filename):<EOL><INDENT>raise exceptions.PyKubeError("<STR_LIT>".format(filename))<EOL><DEDENT>self._filename = filename<EOL><DEDENT>elif data is not None:<EOL><INDENT>self._bytes = base64.b64decode(data)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>
|
Creates a new instance of BytesOrFile.
:Parameters:
- `filename`: A full path to a file
- `data`: base64 encoded bytes
|
f10316:c1:m1
|
def bytes(self):
|
if self._filename:<EOL><INDENT>with open(self._filename, "<STR_LIT:rb>") as f:<EOL><INDENT>return f.read()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return self._bytes<EOL><DEDENT>
|
Returns the provided data as bytes.
|
f10316:c1:m2
|
def filename(self):
|
if self._filename:<EOL><INDENT>return self._filename<EOL><DEDENT>else:<EOL><INDENT>with tempfile.NamedTemporaryFile(delete=False) as f:<EOL><INDENT>f.write(self._bytes)<EOL><DEDENT>return f.name<EOL><DEDENT>
|
Returns the provided data as a file location.
|
f10316:c1:m3
|
def object_factory(api, api_version, kind):
|
resource_list = api.resource_list(api_version)<EOL>resource = next((resource for resource in resource_list["<STR_LIT>"] if resource["<STR_LIT>"] == kind), None)<EOL>base = NamespacedAPIObject if resource["<STR_LIT>"] else APIObject<EOL>return type(kind, (base,), {<EOL>"<STR_LIT:version>": api_version,<EOL>"<STR_LIT>": resource["<STR_LIT:name>"],<EOL>"<STR_LIT>": kind<EOL>})<EOL>
|
Dynamically builds a Python class for the given Kubernetes object in an API.
For example:
api = pykube.HTTPClient(...)
NetworkPolicy = pykube.object_factory(api, "networking.k8s.io/v1", "NetworkPolicy")
This enables construction of any Kubernetes object kind without explicit support
from pykube.
Currently, the HTTPClient passed to this function will not be bound to the returned type.
It is planned to fix this, but in the mean time pass it as you would normally.
|
f10318:m0
|
def rollout_undo(self, target_revision=None):
|
if target_revision is None:<EOL><INDENT>revision = {}<EOL><DEDENT>else:<EOL><INDENT>revision = {<EOL>"<STR_LIT>": target_revision<EOL>}<EOL><DEDENT>params = {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": self.version,<EOL>"<STR_LIT:name>": self.name,<EOL>"<STR_LIT>": revision<EOL>}<EOL>kwargs = {<EOL>"<STR_LIT:version>": self.version,<EOL>"<STR_LIT>": self.namespace,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>}<EOL>r = self.api.post(**self.api_kwargs(data=json.dumps(params), **kwargs))<EOL>r.raise_for_status()<EOL>return r.text<EOL>
|
Produces same action as kubectl rollout undo deployment command.
Input variable is revision to rollback to (in kubectl, --to-revision)
|
f10318:c6:m1
|
def logs(self, container=None, pretty=None, previous=False,<EOL>since_seconds=None, since_time=None, timestamps=False,<EOL>tail_lines=None, limit_bytes=None):
|
log_call = "<STR_LIT>"<EOL>params = {}<EOL>if container is not None:<EOL><INDENT>params["<STR_LIT>"] = container<EOL><DEDENT>if pretty is not None:<EOL><INDENT>params["<STR_LIT>"] = pretty<EOL><DEDENT>if previous:<EOL><INDENT>params["<STR_LIT>"] = "<STR_LIT:true>"<EOL><DEDENT>if since_seconds is not None and since_time is None:<EOL><INDENT>params["<STR_LIT>"] = int(since_seconds)<EOL><DEDENT>elif since_time is not None and since_seconds is None:<EOL><INDENT>params["<STR_LIT>"] = since_time<EOL><DEDENT>if timestamps:<EOL><INDENT>params["<STR_LIT>"] = "<STR_LIT:true>"<EOL><DEDENT>if tail_lines is not None:<EOL><INDENT>params["<STR_LIT>"] = int(tail_lines)<EOL><DEDENT>if limit_bytes is not None:<EOL><INDENT>params["<STR_LIT>"] = int(limit_bytes)<EOL><DEDENT>query_string = urlencode(params)<EOL>log_call += "<STR_LIT>".format(query_string) if query_string else "<STR_LIT>"<EOL>kwargs = {<EOL>"<STR_LIT:version>": self.version,<EOL>"<STR_LIT>": self.namespace,<EOL>"<STR_LIT>": log_call,<EOL>}<EOL>r = self.api.get(**self.api_kwargs(**kwargs))<EOL>r.raise_for_status()<EOL>return r.text<EOL>
|
Produces the same result as calling kubectl logs pod/<pod-name>.
Check parameters meaning at
http://kubernetes.io/docs/api-reference/v1/operations/,
part 'read log of the specified Pod'. The result is plain text.
|
f10318:c17:m1
|
def iterator(self):
|
for obj in (self.execute().json().get("<STR_LIT>") or []):<EOL><INDENT>yield self.api_obj_class(self.api, obj)<EOL><DEDENT>
|
Execute the API request and return an iterator over the objects. This
method does not use the query cache.
|
f10320:c1:m5
|
def __init__(self, config):
|
self.config = config<EOL>self.url = self.config.cluster["<STR_LIT>"]<EOL>session = requests.Session()<EOL>session.mount("<STR_LIT>", KubernetesHTTPAdapter(self.config))<EOL>session.mount("<STR_LIT>", KubernetesHTTPAdapter(self.config))<EOL>self.session = session<EOL>
|
Creates a new instance of the HTTPClient.
:Parameters:
- `config`: The configuration instance
|
f10322:c2:m0
|
@property<EOL><INDENT>def version(self):<DEDENT>
|
response = self.get(version="<STR_LIT>", base="<STR_LIT>")<EOL>response.raise_for_status()<EOL>data = response.json()<EOL>return (data["<STR_LIT>"], data["<STR_LIT>"])<EOL>
|
Get Kubernetes API version
|
f10322:c2:m3
|
def get_kwargs(self, **kwargs):
|
version = kwargs.pop("<STR_LIT:version>", "<STR_LIT>")<EOL>if version == "<STR_LIT>":<EOL><INDENT>base = kwargs.pop("<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>elif "<STR_LIT:/>" in version:<EOL><INDENT>base = kwargs.pop("<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>if "<STR_LIT>" not in kwargs:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>base = kwargs.pop("<STR_LIT>")<EOL><DEDENT>bits = [base, version]<EOL>if "<STR_LIT>" in kwargs:<EOL><INDENT>n = kwargs.pop("<STR_LIT>")<EOL>if n is not None:<EOL><INDENT>if n:<EOL><INDENT>namespace = n<EOL><DEDENT>else:<EOL><INDENT>namespace = self.config.namespace<EOL><DEDENT>if namespace:<EOL><INDENT>bits.extend([<EOL>"<STR_LIT>",<EOL>namespace,<EOL>])<EOL><DEDENT><DEDENT><DEDENT>url = kwargs.get("<STR_LIT:url>", "<STR_LIT>")<EOL>if url.startswith("<STR_LIT:/>"):<EOL><INDENT>url = url[<NUM_LIT:1>:]<EOL><DEDENT>bits.append(url)<EOL>kwargs["<STR_LIT:url>"] = self.url + posixpath.join(*bits)<EOL>return kwargs<EOL>
|
Creates a full URL to request based on arguments.
:Parametes:
- `kwargs`: All keyword arguments to build a kubernetes API endpoint
|
f10322:c2:m5
|
def request(self, *args, **kwargs):
|
return self.session.request(*args, **self.get_kwargs(**kwargs))<EOL>
|
Makes an API request based on arguments.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m7
|
def get(self, *args, **kwargs):
|
return self.session.get(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP GET.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m8
|
def options(self, *args, **kwargs):
|
return self.session.options(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP OPTIONS.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m9
|
def head(self, *args, **kwargs):
|
return self.session.head(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP HEAD.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m10
|
def post(self, *args, **kwargs):
|
return self.session.post(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP POST.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m11
|
def put(self, *args, **kwargs):
|
return self.session.put(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP PUT.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m12
|
def patch(self, *args, **kwargs):
|
return self.session.patch(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP PATCH.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m13
|
def delete(self, *args, **kwargs):
|
return self.session.delete(*args, **self.get_kwargs(**kwargs))<EOL>
|
Executes an HTTP DELETE.
:Parameters:
- `args`: Non-keyword arguments
- `kwargs`: Keyword arguments
|
f10322:c2:m14
|
@staticmethod<EOL><INDENT>def status(s):<DEDENT>
|
print('<STR_LIT>'.format(s))<EOL>
|
Prints things in bold.
|
f10331:c0:m0
|
def create_queryall_job(self, object_name, **kwargs):
|
return self.create_job(object_name, "<STR_LIT>", **kwargs)<EOL>
|
only supported since version 39.0
|
f10337:c3:m4
|
def get_query_batch_request(self, batch_id, job_id=None):
|
if not job_id:<EOL><INDENT>job_id = self.lookup_job_id(batch_id)<EOL><DEDENT>url = self.endpoint + "<STR_LIT>".format(job_id, batch_id)<EOL>resp = requests.get(url, headers=self.headers())<EOL>self.check_status(resp)<EOL>return resp.text<EOL>
|
Fetch the request sent for the batch. Note should only used for query batches
|
f10337:c3:m12
|
def abort_job(self, job_id):
|
doc = self.create_abort_job_doc()<EOL>url = self.endpoint + "<STR_LIT>" % job_id<EOL>resp = requests.post(<EOL>url,<EOL>headers=self.headers(),<EOL>data=doc<EOL>)<EOL>self.check_status(resp)<EOL>
|
Abort a given bulk job
|
f10337:c3:m14
|
def create_abort_job_doc(self):
|
root = ET.Element("<STR_LIT>")<EOL>root.set("<STR_LIT>", self.jobNS)<EOL>state = ET.SubElement(root, "<STR_LIT:state>")<EOL>state.text = "<STR_LIT>"<EOL>buf = StringIO()<EOL>tree = ET.ElementTree(root)<EOL>tree.write(buf, encoding="<STR_LIT>")<EOL>return buf.getvalue()<EOL>
|
Create XML doc for aborting a job
|
f10337:c3:m17
|
def get_all_results_for_query_batch(self, batch_id, job_id=None, chunk_size=<NUM_LIT>):
|
result_ids = self.get_query_batch_result_ids(batch_id, job_id=job_id)<EOL>if not result_ids:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>for result_id in result_ids:<EOL><INDENT>yield self.get_query_batch_results(<EOL>batch_id,<EOL>result_id,<EOL>job_id=job_id,<EOL>chunk_size=chunk_size<EOL>)<EOL><DEDENT>
|
Gets result ids and generates each result set from the batch and returns it
as an generator fetching the next result set when needed
Args:
batch_id: id of batch
job_id: id of job, if not provided, it will be looked up
|
f10337:c3:m31
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.